mirror of https://gitee.com/xiaonuobase/snowy
【更新】用户单独授权(待完善)
parent
2801b730c5
commit
e4b4c782e3
|
@ -19,7 +19,6 @@ import cn.hutool.core.convert.Convert;
|
|||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.dfa.SensitiveUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
|
|
|
@ -29,6 +29,12 @@ public enum SysRelationCategoryEnum {
|
|||
/** 用户日程数据 */
|
||||
SYS_USER_SCHEDULE_DATA("SYS_USER_SCHEDULE_DATA"),
|
||||
|
||||
/** 用户拥有资源 */
|
||||
SYS_USER_HAS_RESOURCE("SYS_USER_HAS_RESOURCE"),
|
||||
|
||||
/** 用户拥有权限 */
|
||||
SYS_USER_HAS_PERMISSION("SYS_USER_HAS_PERMISSION"),
|
||||
|
||||
/** 用户拥有角色 */
|
||||
SYS_USER_HAS_ROLE("SYS_USER_HAS_ROLE"),
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public interface SysRoleService extends IService<SysRole> {
|
|||
* @author xuyuxiang
|
||||
* @date 2022/5/13 20:51
|
||||
*/
|
||||
SysRoleOwnMobileMenuResult ownMobileMenu(SysRoleIdParam SysRoleIdParam);
|
||||
SysRoleOwnMobileMenuResult ownMobileMenu(SysRoleIdParam sysRoleIdParam);
|
||||
|
||||
/**
|
||||
* 给角色授权移动端菜单
|
||||
|
|
|
@ -31,6 +31,8 @@ import vip.xiaonuo.sys.modular.position.entity.SysPosition;
|
|||
import vip.xiaonuo.sys.modular.role.entity.SysRole;
|
||||
import vip.xiaonuo.sys.modular.user.entity.SysUser;
|
||||
import vip.xiaonuo.sys.modular.user.param.*;
|
||||
import vip.xiaonuo.sys.modular.user.result.SysUserOwnPermissionResult;
|
||||
import vip.xiaonuo.sys.modular.user.result.SysUserOwnResourceResult;
|
||||
import vip.xiaonuo.sys.modular.user.service.SysUserService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -201,12 +203,68 @@ public class SysUserController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 用户导入
|
||||
* 获取用户拥有资源
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/24 20:00
|
||||
*/
|
||||
@ApiOperationSupport(order = 11)
|
||||
@ApiOperation("获取用户拥有资源")
|
||||
@GetMapping("/sys/user/ownResource")
|
||||
public CommonResult<SysUserOwnResourceResult> ownResource(@Valid SysUserIdParam sysUserIdParam) {
|
||||
return CommonResult.data(sysUserService.ownResource(sysUserIdParam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 给用户授权资源
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/24 20:00
|
||||
*/
|
||||
@ApiOperationSupport(order = 12)
|
||||
@ApiOperation("给用户授权资源")
|
||||
@CommonLog("给用户授权资源")
|
||||
@PostMapping("/sys/user/grantResource")
|
||||
public CommonResult<String> grantResource(@RequestBody @Valid SysUserGrantResourceParam sysUserGrantResourceParam) {
|
||||
sysUserService.grantResource(sysUserGrantResourceParam);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户拥有权限
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/24 20:00
|
||||
*/
|
||||
@ApiOperationSupport(order = 13)
|
||||
@ApiOperation("获取用户拥有权限")
|
||||
@GetMapping("/sys/user/ownPermission")
|
||||
public CommonResult<SysUserOwnPermissionResult> ownPermission(@Valid SysUserIdParam sysUserIdParam) {
|
||||
return CommonResult.data(sysUserService.ownPermission(sysUserIdParam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 给用户授权权限
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/24 20:00
|
||||
*/
|
||||
@ApiOperationSupport(order = 14)
|
||||
@ApiOperation("给用户授权权限")
|
||||
@CommonLog("给用户授权权限")
|
||||
@PostMapping("/sys/user/grantPermission")
|
||||
public CommonResult<String> grantPermission(@RequestBody @Valid SysUserGrantPermissionParam sysUserGrantPermissionParam) {
|
||||
sysUserService.grantPermission(sysUserGrantPermissionParam);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户导入
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/24 20:00
|
||||
*/
|
||||
@ApiOperationSupport(order = 15)
|
||||
@ApiOperation("用户导入")
|
||||
@CommonLog("用户导入")
|
||||
@PostMapping("/sys/user/import")
|
||||
|
@ -221,7 +279,7 @@ public class SysUserController {
|
|||
* @author xuyuxiang
|
||||
* @date 2022/4/24 20:00
|
||||
*/
|
||||
@ApiOperationSupport(order = 12)
|
||||
@ApiOperationSupport(order = 16)
|
||||
@ApiOperation("用户导出")
|
||||
@CommonLog("用户导出")
|
||||
@GetMapping(value = "/sys/user/export", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
|
@ -237,7 +295,7 @@ public class SysUserController {
|
|||
* @author xuyuxiang
|
||||
* @date 2022/4/24 20:00
|
||||
*/
|
||||
@ApiOperationSupport(order = 13)
|
||||
@ApiOperationSupport(order = 17)
|
||||
@ApiOperation("获取组织树选择器")
|
||||
@GetMapping("/sys/user/orgTreeSelector")
|
||||
public CommonResult<List<Tree<String>>> orgTreeSelector() {
|
||||
|
@ -250,7 +308,7 @@ public class SysUserController {
|
|||
* @author xuyuxiang
|
||||
* @date 2022/4/24 20:00
|
||||
*/
|
||||
@ApiOperationSupport(order = 14)
|
||||
@ApiOperationSupport(order = 18)
|
||||
@ApiOperation("获取组织列表选择器")
|
||||
@GetMapping("/sys/user/orgListSelector")
|
||||
public CommonResult<List<SysOrg>> orgListSelector(SysUserSelectorOrgListParam sysUserSelectorOrgListParam) {
|
||||
|
@ -263,7 +321,7 @@ public class SysUserController {
|
|||
* @author xuyuxiang
|
||||
* @date 2022/4/24 20:00
|
||||
*/
|
||||
@ApiOperationSupport(order = 15)
|
||||
@ApiOperationSupport(order = 19)
|
||||
@ApiOperation("获取职位选择器")
|
||||
@GetMapping("/sys/user/positionSelector")
|
||||
public CommonResult<List<SysPosition>> positionSelector(SysUserSelectorPositionParam sysUserSelectorPositionParam) {
|
||||
|
@ -276,7 +334,7 @@ public class SysUserController {
|
|||
* @author xuyuxiang
|
||||
* @date 2022/4/24 20:00
|
||||
*/
|
||||
@ApiOperationSupport(order = 16)
|
||||
@ApiOperationSupport(order = 20)
|
||||
@ApiOperation("获取角色选择器")
|
||||
@GetMapping("/sys/user/roleSelector")
|
||||
public CommonResult<List<SysRole>> roleSelector(SysUserSelectorRoleParam sysUserSelectorRoleParam) {
|
||||
|
@ -289,7 +347,7 @@ public class SysUserController {
|
|||
* @author xuyuxiang
|
||||
* @date 2022/4/24 20:00
|
||||
*/
|
||||
@ApiOperationSupport(order = 17)
|
||||
@ApiOperationSupport(order = 21)
|
||||
@ApiOperation("获取用户选择器")
|
||||
@GetMapping("/sys/user/userSelector")
|
||||
public CommonResult<List<SysUser>> userSelector(SysUserSelectorUserParam sysUserSelectorUserParam) {
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package vip.xiaonuo.sys.modular.user.param;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户授权权限参数
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/7/27 15:05
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SysUserGrantPermissionParam {
|
||||
|
||||
/** 用户id */
|
||||
@ApiModelProperty(value = "用户id", required = true, position = 1)
|
||||
@NotBlank(message = "id不能为空")
|
||||
private String id;
|
||||
|
||||
/** 授权权限信息 */
|
||||
@Valid
|
||||
@ApiModelProperty(value = "授权权限信息", required = true, position = 2)
|
||||
@NotNull(message = "grantInfoList不能为空")
|
||||
private List<SysUserGrantPermission> grantInfoList;
|
||||
|
||||
/**
|
||||
* 用户授权权限类
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/28 23:19
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class SysUserGrantPermission {
|
||||
|
||||
/** 接口地址 */
|
||||
@ApiModelProperty(value = "接口地址", position = 1)
|
||||
@NotBlank(message = "apiUrl不能为空")
|
||||
private String apiUrl;
|
||||
|
||||
/** 数据范围分类 */
|
||||
@ApiModelProperty(value = "数据范围分类", position = 2)
|
||||
@NotBlank(message = "category不能为空")
|
||||
private String scopeCategory;
|
||||
|
||||
/** 自定义范围组织id集合 */
|
||||
@ApiModelProperty(value = "自定义范围组织id集合", position = 3)
|
||||
@NotNull(message = "scopeDefineOrgIdList不能为空")
|
||||
private List<String> scopeDefineOrgIdList;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package vip.xiaonuo.sys.modular.user.param;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户授权资源参数
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/7/27 15:05
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SysUserGrantResourceParam {
|
||||
|
||||
/** 用户id */
|
||||
@ApiModelProperty(value = "用户id", required = true, position = 1)
|
||||
@NotBlank(message = "id不能为空")
|
||||
private String id;
|
||||
|
||||
/** 授权资源信息 */
|
||||
@Valid
|
||||
@ApiModelProperty(value = "授权资源信息", required = true, position = 2)
|
||||
@NotNull(message = "grantInfoList不能为空")
|
||||
private List<SysUserGrantResource> grantInfoList;
|
||||
|
||||
/**
|
||||
* 用户授权资源类
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/28 23:19
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class SysUserGrantResource {
|
||||
|
||||
/** 菜单id */
|
||||
@ApiModelProperty(value = "菜单id", position = 1)
|
||||
@NotBlank(message = "menuId不能为空")
|
||||
private String menuId;
|
||||
|
||||
/** 按钮id集合 */
|
||||
@ApiModelProperty(value = "按钮id集合", position = 2)
|
||||
@NotNull(message = "buttonInfo不能为空")
|
||||
private List<String> buttonInfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package vip.xiaonuo.sys.modular.user.result;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户授权资源树结果
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/7/27 15:09
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SysUserGrantResourceTreeResult {
|
||||
|
||||
/** 模块id */
|
||||
@ApiModelProperty(value = "模块id", position = 1)
|
||||
private String id;
|
||||
|
||||
/** 模块名称*/
|
||||
@ApiModelProperty(value = "模块名称", position = 2)
|
||||
private String title;
|
||||
|
||||
/** 模块图标 */
|
||||
@ApiModelProperty(value = "模块图标", position = 3)
|
||||
private String icon;
|
||||
|
||||
/** 模块下菜单集合*/
|
||||
@ApiModelProperty(value = "模块下菜单集合", position = 4)
|
||||
private List<SysUserGrantResourceMenuResult> menu;
|
||||
|
||||
/**
|
||||
* 授权菜单类
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/8/13 16:54
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class SysUserGrantResourceMenuResult {
|
||||
|
||||
/** 菜单id */
|
||||
@ApiModelProperty(value = "菜单id", position = 1)
|
||||
private String id;
|
||||
|
||||
/** 父id */
|
||||
@ApiModelProperty(value = "父id", position = 2)
|
||||
private String parentId;
|
||||
|
||||
/** 父名称 */
|
||||
@ApiModelProperty(value = "菜单名称", position = 3)
|
||||
private String parentName;
|
||||
|
||||
/** 标题 */
|
||||
@ApiModelProperty(value = "菜单标题", position = 4)
|
||||
private String title;
|
||||
|
||||
/** 模块 */
|
||||
@ApiModelProperty(value = "菜单模块", position = 5)
|
||||
private String module;
|
||||
|
||||
/** 菜单下按钮集合 */
|
||||
@ApiModelProperty(value = "菜单下按钮集合", position = 6)
|
||||
private List<SysUserGrantResourceButtonResult> button;
|
||||
|
||||
/**
|
||||
* 授权按钮类
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/8/13 16:54
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class SysUserGrantResourceButtonResult {
|
||||
|
||||
/** 按钮id */
|
||||
@ApiModelProperty(value = "按钮id", position = 1)
|
||||
private String id;
|
||||
|
||||
/** 标题 */
|
||||
@ApiModelProperty(value = "按钮标题", position = 2)
|
||||
private String title;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package vip.xiaonuo.sys.modular.user.result;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户拥有的权限结果
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/7/27 15:08
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SysUserOwnPermissionResult {
|
||||
|
||||
/** 用户id */
|
||||
@ApiModelProperty(value = "角色id", position = 1)
|
||||
private String id;
|
||||
|
||||
/** 已授权权限信息 */
|
||||
@ApiModelProperty(value = "已授权权限信息", position = 2)
|
||||
private List<SysUserOwnPermission> grantInfoList;
|
||||
|
||||
/**
|
||||
* 用户拥有资源类
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/28 23:19
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class SysUserOwnPermission {
|
||||
|
||||
/** 菜单id */
|
||||
@ApiModelProperty(value = "接口地址", position = 1)
|
||||
private String apiUrl;
|
||||
|
||||
/** 数据范围分类 */
|
||||
@ApiModelProperty(value = "数据范围分类", position = 1)
|
||||
private String scopeCategory;
|
||||
|
||||
/** 自定义范围组织id集合 */
|
||||
@ApiModelProperty(value = "自定义范围组织id集合", position = 2)
|
||||
private List<String> scopeDefineOrgIdList;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package vip.xiaonuo.sys.modular.user.result;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户拥有的资源结果
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/7/27 15:08
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SysUserOwnResourceResult {
|
||||
|
||||
/** 用户id */
|
||||
@ApiModelProperty(value = "用户id", position = 1)
|
||||
private String id;
|
||||
|
||||
/** 已授权资源信息 */
|
||||
@ApiModelProperty(value = "已授权资源信息", position = 2)
|
||||
private List<SysUserOwnResource> grantInfoList;
|
||||
|
||||
/**
|
||||
* 用户拥有资源类
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/28 23:19
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class SysUserOwnResource {
|
||||
|
||||
/** 菜单id */
|
||||
@ApiModelProperty(value = "菜单id", position = 1)
|
||||
private String menuId;
|
||||
|
||||
/** 按钮id集合 */
|
||||
@ApiModelProperty(value = "按钮id集合", position = 2)
|
||||
private List<String> buttonInfo;
|
||||
}
|
||||
}
|
|
@ -244,6 +244,38 @@ public interface SysUserService extends IService<SysUser> {
|
|||
**/
|
||||
void grantRole(SysUserGrantRoleParam sysUserGrantRoleParam);
|
||||
|
||||
/**
|
||||
* 获取用户拥有资源
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/5/13 20:51
|
||||
*/
|
||||
SysUserOwnResourceResult ownResource(SysUserIdParam sysUserIdParam);
|
||||
|
||||
/**
|
||||
* 给用户授权资源
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/29 10:12
|
||||
**/
|
||||
void grantResource(SysUserGrantResourceParam sysUserGrantResourceParam);
|
||||
|
||||
/**
|
||||
* 获取用户拥有权限
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/5/13 20:51
|
||||
*/
|
||||
SysUserOwnPermissionResult ownPermission(SysUserIdParam sysUserIdParam);
|
||||
|
||||
/**
|
||||
* 给用户授权权限
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/29 10:12
|
||||
**/
|
||||
void grantPermission(SysUserGrantPermissionParam sysUserGrantPermissionParam);
|
||||
|
||||
/**
|
||||
* 获取用户组织树
|
||||
*
|
||||
|
|
|
@ -745,6 +745,48 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
SysRelationCategoryEnum.SYS_USER_HAS_ROLE.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserOwnResourceResult ownResource(SysUserIdParam sysUserIdParam) {
|
||||
SysUserOwnResourceResult sysUserOwnResourceResult = new SysUserOwnResourceResult();
|
||||
sysUserOwnResourceResult.setId(sysUserIdParam.getId());
|
||||
sysUserOwnResourceResult.setGrantInfoList(sysRelationService.getRelationListByObjectIdAndCategory(sysUserIdParam.getId(),
|
||||
SysRelationCategoryEnum.SYS_USER_HAS_RESOURCE.getValue()).stream().map(sysRelation ->
|
||||
JSONUtil.toBean(sysRelation.getExtJson(), SysUserOwnResourceResult.SysUserOwnResource.class)).collect(Collectors.toList()));
|
||||
return sysUserOwnResourceResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void grantResource(SysUserGrantResourceParam sysUserGrantResourceParam) {
|
||||
String id = sysUserGrantResourceParam.getId();
|
||||
List<String> menuIdList = sysUserGrantResourceParam.getGrantInfoList().stream()
|
||||
.map(SysUserGrantResourceParam.SysUserGrantResource::getMenuId).collect(Collectors.toList());
|
||||
List<String> extJsonList = sysUserGrantResourceParam.getGrantInfoList().stream()
|
||||
.map(JSONUtil::toJsonStr).collect(Collectors.toList());
|
||||
sysRelationService.saveRelationBatchWithClear(id, menuIdList, SysRelationCategoryEnum.SYS_USER_HAS_RESOURCE.getValue(),
|
||||
extJsonList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserOwnPermissionResult ownPermission(SysUserIdParam sysUserIdParam) {
|
||||
SysUserOwnPermissionResult sysUserOwnPermissionResult = new SysUserOwnPermissionResult();
|
||||
sysUserOwnPermissionResult.setId(sysUserIdParam.getId());
|
||||
sysUserOwnPermissionResult.setGrantInfoList(sysRelationService.getRelationListByObjectIdAndCategory(sysUserIdParam.getId(),
|
||||
SysRelationCategoryEnum.SYS_USER_HAS_PERMISSION.getValue()).stream().map(sysRelation ->
|
||||
JSONUtil.toBean(sysRelation.getExtJson(), SysUserOwnPermissionResult.SysUserOwnPermission.class)).collect(Collectors.toList()));
|
||||
return sysUserOwnPermissionResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void grantPermission(SysUserGrantPermissionParam sysUserGrantPermissionParam) {
|
||||
String id = sysUserGrantPermissionParam.getId();
|
||||
List<String> apiUrlList = sysUserGrantPermissionParam.getGrantInfoList().stream()
|
||||
.map(SysUserGrantPermissionParam.SysUserGrantPermission::getApiUrl).collect(Collectors.toList());
|
||||
List<String> extJsonList = sysUserGrantPermissionParam.getGrantInfoList().stream()
|
||||
.map(JSONUtil::toJsonStr).collect(Collectors.toList());
|
||||
sysRelationService.saveRelationBatchWithClear(id, apiUrlList, SysRelationCategoryEnum.SYS_USER_HAS_PERMISSION.getValue(),
|
||||
extJsonList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tree<String>> loginOrgTree(SysUserIdParam sysUserIdParam) {
|
||||
LambdaQueryWrapper<SysOrg> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
@ -832,6 +874,26 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
|
||||
@Override
|
||||
public List<String> getButtonCodeList(String userId) {
|
||||
List<String> buttonCodeListGrantUser = this.getButtonCodeListGrantUser(userId);
|
||||
List<String> buttonCodeListGrantRole = this.getButtonCodeListGrantRole(userId);
|
||||
return CollectionUtil.newArrayList(CollectionUtil.unionDistinct(buttonCodeListGrantUser, buttonCodeListGrantRole));
|
||||
}
|
||||
|
||||
public List<String> getButtonCodeListGrantUser(String userId) {
|
||||
List<String> buttonIdList = CollectionUtil.newArrayList();
|
||||
sysRelationService.getRelationListByObjectIdAndCategory(userId,
|
||||
SysRelationCategoryEnum.SYS_USER_HAS_RESOURCE.getValue()).forEach(sysRelation -> {
|
||||
if (ObjectUtil.isNotEmpty(sysRelation.getExtJson())) {
|
||||
buttonIdList.addAll(JSONUtil.parseObj(sysRelation.getExtJson()).getBeanList("buttonInfo", String.class));
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(buttonIdList)) {
|
||||
return sysButtonService.listByIds(buttonIdList).stream().map(SysButton::getCode).collect(Collectors.toList());
|
||||
}
|
||||
return CollectionUtil.newArrayList();
|
||||
}
|
||||
|
||||
public List<String> getButtonCodeListGrantRole(String userId) {
|
||||
List<String> roleIdList = sysRelationService.getRelationTargetIdListByObjectIdAndCategory(userId,
|
||||
SysRelationCategoryEnum.SYS_USER_HAS_ROLE.getValue());
|
||||
if (ObjectUtil.isNotEmpty(roleIdList)) {
|
||||
|
@ -868,6 +930,24 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
|
||||
@Override
|
||||
public List<JSONObject> getPermissionList(String userId, String orgId) {
|
||||
List<JSONObject> permissionListGrantUser = this.getPermissionListGrantUser(userId, orgId);
|
||||
List<JSONObject> permissionListGrantRole = this.getPermissionListGrantRole(userId, orgId);
|
||||
// TODO 执行合并
|
||||
return permissionListGrantUser;
|
||||
}
|
||||
|
||||
public List<JSONObject> getPermissionListGrantUser(String userId, String orgId) {
|
||||
if (ObjectUtil.isNotEmpty(orgId)) {
|
||||
Map<String, List<SysRelation>> groupMap = sysRelationService.getRelationListByObjectIdAndCategory(userId,
|
||||
SysRelationCategoryEnum.SYS_USER_HAS_PERMISSION.getValue()).stream().collect(Collectors.groupingBy(SysRelation::getTargetId));
|
||||
if (ObjectUtil.isNotEmpty(groupMap)) {
|
||||
return getScopeListByMap(groupMap, orgId);
|
||||
}
|
||||
}
|
||||
return CollectionUtil.newArrayList();
|
||||
}
|
||||
|
||||
public List<JSONObject> getPermissionListGrantRole(String userId, String orgId) {
|
||||
if (ObjectUtil.isNotEmpty(orgId)) {
|
||||
List<String> roleIdList = sysRelationService.getRelationTargetIdListByObjectIdAndCategory(userId,
|
||||
SysRelationCategoryEnum.SYS_USER_HAS_ROLE.getValue());
|
||||
|
@ -875,6 +955,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
Map<String, List<SysRelation>> groupMap = sysRelationService.getRelationListByObjectIdListAndCategory(roleIdList,
|
||||
SysRelationCategoryEnum.SYS_ROLE_HAS_PERMISSION.getValue()).stream().collect(Collectors.groupingBy(SysRelation::getTargetId));
|
||||
if (ObjectUtil.isNotEmpty(groupMap)) {
|
||||
return getScopeListByMap(groupMap, orgId);
|
||||
}
|
||||
}
|
||||
}
|
||||
return CollectionUtil.newArrayList();
|
||||
}
|
||||
|
||||
public List<JSONObject> getScopeListByMap(Map<String, List<SysRelation>> groupMap, String orgId) {
|
||||
List<JSONObject> resultList = CollectionUtil.newArrayList();
|
||||
List<SysOrg> sysOrgList = sysOrgService.list();
|
||||
List<String> scopeAllList = sysOrgList.stream().map(SysOrg::getId).collect(Collectors.toList());
|
||||
|
@ -903,10 +991,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
});
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
return CollectionUtil.newArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRoleCodeList(String userId) {
|
||||
|
|
|
@ -12,6 +12,11 @@
|
|||
*/
|
||||
package vip.xiaonuo;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* TestMain方法
|
||||
*
|
||||
|
@ -20,5 +25,7 @@ package vip.xiaonuo;
|
|||
*/
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
Set<Integer> integers = CollectionUtil.unionDistinct(CollectionUtil.newArrayList(), CollectionUtil.newArrayList(1, 2, 4));
|
||||
System.out.println(integers);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue