|
|
|
@ -21,6 +21,7 @@ import apelet.tenantadmin.upms.service.SysUserService; |
|
|
|
import apelet.tenantadmin.upms.vo.SysDeptVo; |
|
|
|
import apelet.tenantadmin.upms.vo.SysDeptVo; |
|
|
|
import apelet.tenantadmin.upms.vo.SysRoleVo; |
|
|
|
import apelet.tenantadmin.upms.vo.SysRoleVo; |
|
|
|
import apelet.tenantadmin.upms.vo.SysUserVo; |
|
|
|
import apelet.tenantadmin.upms.vo.SysUserVo; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.github.pagehelper.Page; |
|
|
|
import com.github.pagehelper.Page; |
|
|
|
import com.github.pagehelper.page.PageMethod; |
|
|
|
import com.github.pagehelper.page.PageMethod; |
|
|
|
@ -59,7 +60,7 @@ public class SysRoleController { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param sysRoleDto 新增角色对象。 |
|
|
|
* @param sysRoleDto 新增角色对象。 |
|
|
|
* @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。 |
|
|
|
* @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。 |
|
|
|
* @param deptId 组织Id(可选)。 |
|
|
|
* @param deptIdListString 组织Id列表(可选,多对多关联),多个deptId之间逗号分隔。 |
|
|
|
* @param buttonConfigList 按钮权限配置列表(可选,不传不影响原有逻辑)。 |
|
|
|
* @param buttonConfigList 按钮权限配置列表(可选,不传不影响原有逻辑)。 |
|
|
|
* @return 应答结果对象,包含新增角色的主键Id。 |
|
|
|
* @return 应答结果对象,包含新增角色的主键Id。 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -69,22 +70,25 @@ public class SysRoleController { |
|
|
|
public ResponseResult<Long> add( |
|
|
|
public ResponseResult<Long> add( |
|
|
|
@MyRequestBody SysRoleDto sysRoleDto, |
|
|
|
@MyRequestBody SysRoleDto sysRoleDto, |
|
|
|
@MyRequestBody String menuIdListString, |
|
|
|
@MyRequestBody String menuIdListString, |
|
|
|
@MyRequestBody Long deptId, |
|
|
|
@MyRequestBody String deptIdListString, |
|
|
|
@MyRequestBody List<RoleFormButtonDto> buttonConfigList) { |
|
|
|
@MyRequestBody List<RoleFormButtonDto> buttonConfigList) { |
|
|
|
String errorMessage = MyCommonUtil.getModelValidationError(sysRoleDto); |
|
|
|
String errorMessage = MyCommonUtil.getModelValidationError(sysRoleDto); |
|
|
|
if (errorMessage != null) { |
|
|
|
if (errorMessage != null) { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); |
|
|
|
} |
|
|
|
} |
|
|
|
SysRole sysRole = MyModelUtil.copyTo(sysRoleDto, SysRole.class); |
|
|
|
SysRole sysRole = MyModelUtil.copyTo(sysRoleDto, SysRole.class); |
|
|
|
CallResult result = sysRoleService.verifyRelatedData(sysRole, null, menuIdListString, deptId); |
|
|
|
CallResult result = sysRoleService.verifyRelatedData(sysRole, null, menuIdListString, deptIdListString); |
|
|
|
if (!result.isSuccess()) { |
|
|
|
if (!result.isSuccess()) { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
Set<Long> menuIdSet = null; |
|
|
|
Set<Long> menuIdSet = null; |
|
|
|
|
|
|
|
Set<Long> deptIdSet = null; |
|
|
|
if (result.getData() != null) { |
|
|
|
if (result.getData() != null) { |
|
|
|
menuIdSet = result.getData().getObject("menuIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
JSONObject data = result.getData(); |
|
|
|
|
|
|
|
menuIdSet = data.getObject("menuIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
|
|
|
|
deptIdSet = data.getObject("deptIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
} |
|
|
|
} |
|
|
|
sysRoleService.saveNew(sysRole, menuIdSet, deptId); |
|
|
|
sysRoleService.saveNew(sysRole, menuIdSet, deptIdSet); |
|
|
|
// 按钮权限配置(可选,不传不影响原有逻辑)
|
|
|
|
// 按钮权限配置(可选,不传不影响原有逻辑)
|
|
|
|
if (buttonConfigList != null && !buttonConfigList.isEmpty()) { |
|
|
|
if (buttonConfigList != null && !buttonConfigList.isEmpty()) { |
|
|
|
buttonConfigList.forEach(dto -> dto.setRoleId(sysRole.getRoleId())); |
|
|
|
buttonConfigList.forEach(dto -> dto.setRoleId(sysRole.getRoleId())); |
|
|
|
@ -98,7 +102,7 @@ public class SysRoleController { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param sysRoleDto 更新角色对象。 |
|
|
|
* @param sysRoleDto 更新角色对象。 |
|
|
|
* @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。 |
|
|
|
* @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。 |
|
|
|
* @param deptId 组织Id(可选)。 |
|
|
|
* @param deptIdListString 组织Id列表(可选,多对多关联),多个deptId之间逗号分隔。 |
|
|
|
* @param buttonConfigList 按钮权限配置列表(可选,不传不影响原有逻辑)。 |
|
|
|
* @param buttonConfigList 按钮权限配置列表(可选,不传不影响原有逻辑)。 |
|
|
|
* @return 应答结果对象。 |
|
|
|
* @return 应答结果对象。 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -107,7 +111,7 @@ public class SysRoleController { |
|
|
|
public ResponseResult<Void> update( |
|
|
|
public ResponseResult<Void> update( |
|
|
|
@MyRequestBody SysRoleDto sysRoleDto, |
|
|
|
@MyRequestBody SysRoleDto sysRoleDto, |
|
|
|
@MyRequestBody String menuIdListString, |
|
|
|
@MyRequestBody String menuIdListString, |
|
|
|
@MyRequestBody Long deptId, |
|
|
|
@MyRequestBody String deptIdListString, |
|
|
|
@MyRequestBody List<RoleFormButtonDto> buttonConfigList) { |
|
|
|
@MyRequestBody List<RoleFormButtonDto> buttonConfigList) { |
|
|
|
String errorMessage = MyCommonUtil.getModelValidationError(sysRoleDto, Default.class, UpdateGroup.class); |
|
|
|
String errorMessage = MyCommonUtil.getModelValidationError(sysRoleDto, Default.class, UpdateGroup.class); |
|
|
|
if (errorMessage != null) { |
|
|
|
if (errorMessage != null) { |
|
|
|
@ -119,15 +123,18 @@ public class SysRoleController { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); |
|
|
|
} |
|
|
|
} |
|
|
|
SysRole sysRole = MyModelUtil.copyTo(sysRoleDto, SysRole.class); |
|
|
|
SysRole sysRole = MyModelUtil.copyTo(sysRoleDto, SysRole.class); |
|
|
|
CallResult result = sysRoleService.verifyRelatedData(sysRole, originalSysRole, menuIdListString, deptId); |
|
|
|
CallResult result = sysRoleService.verifyRelatedData(sysRole, originalSysRole, menuIdListString, deptIdListString); |
|
|
|
if (!result.isSuccess()) { |
|
|
|
if (!result.isSuccess()) { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
Set<Long> menuIdSet = null; |
|
|
|
Set<Long> menuIdSet = null; |
|
|
|
|
|
|
|
Set<Long> deptIdSet = null; |
|
|
|
if (result.getData() != null) { |
|
|
|
if (result.getData() != null) { |
|
|
|
menuIdSet = result.getData().getObject("menuIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
JSONObject data = result.getData(); |
|
|
|
|
|
|
|
menuIdSet = data.getObject("menuIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
|
|
|
|
deptIdSet = data.getObject("deptIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!sysRoleService.update(sysRole, originalSysRole, menuIdSet, deptId)) { |
|
|
|
if (!sysRoleService.update(sysRole, originalSysRole, menuIdSet, deptIdSet)) { |
|
|
|
errorMessage = "更新失败,数据不存在,请刷新后重试!"; |
|
|
|
errorMessage = "更新失败,数据不存在,请刷新后重试!"; |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -201,6 +208,8 @@ public class SysRoleController { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); |
|
|
|
} |
|
|
|
} |
|
|
|
SysRoleVo sysRoleVo = MyModelUtil.copyTo(sysRole, SysRoleVo.class); |
|
|
|
SysRoleVo sysRoleVo = MyModelUtil.copyTo(sysRole, SysRoleVo.class); |
|
|
|
|
|
|
|
// 填充关联的组织列表(多对多,仅需要deptId和deptName)
|
|
|
|
|
|
|
|
sysRoleVo.setDeptList(sysRoleService.getRoleDept(roleId)); |
|
|
|
return ResponseResult.success(sysRoleVo); |
|
|
|
return ResponseResult.success(sysRoleVo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -376,18 +385,18 @@ public class SysRoleController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 查询角色关联的组织(用于编辑页回显)。 |
|
|
|
* 查询角色关联的组织列表(用于编辑页回显,多对多)。 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param roleId 角色Id。 |
|
|
|
* @param roleId 角色Id。 |
|
|
|
* @return 应答结果对象,包含角色关联的组织信息。 |
|
|
|
* @return 应答结果对象,包含角色关联的组织信息列表。 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@GetMapping("/getRoleDept") |
|
|
|
@GetMapping("/getRoleDept") |
|
|
|
public ResponseResult<SysDeptVo> getRoleDept(@RequestParam Long roleId) { |
|
|
|
public ResponseResult<List<SysDeptVo>> getRoleDept(@RequestParam Long roleId) { |
|
|
|
if (MyCommonUtil.existBlankArgument(roleId)) { |
|
|
|
if (MyCommonUtil.existBlankArgument(roleId)) { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); |
|
|
|
} |
|
|
|
} |
|
|
|
SysDeptVo deptVo = sysRoleService.getRoleDept(roleId); |
|
|
|
List<SysDeptVo> deptVoList = sysRoleService.getRoleDept(roleId); |
|
|
|
return ResponseResult.success(deptVo); |
|
|
|
return ResponseResult.success(deptVoList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|