|
|
|
@ -3,23 +3,21 @@ package cn.estsh.i3plus.core.apiservice.controller.busi;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.IPersonnelService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysRoleService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysPosition;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysRefRoleMenu;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserRole;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysRole;
|
|
|
|
|
import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
|
|
|
|
import cn.estsh.impp.framework.base.controller.CrudBaseController;
|
|
|
|
|
import cn.estsh.impp.framework.base.service.ICrudService;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
@ -57,11 +55,27 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
return sysRoleService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public SysRole validatorInsertBean(SysRole role) throws Exception {
|
|
|
|
|
//条件验证
|
|
|
|
|
ValidatorBean.beginValid(role)
|
|
|
|
|
.notNull("name", role.getName());
|
|
|
|
|
|
|
|
|
|
sysRoleService.checkSysRoleOnly(role);
|
|
|
|
|
|
|
|
|
|
//新增初始化
|
|
|
|
|
ConvertBean.modelInitialize(role, AuthUtil.getSessionUser());
|
|
|
|
|
role.setRoleStatus(CommonEnumUtil.DATA_STATUS.ENABLE.getValue());
|
|
|
|
|
role.setMenuNumber(0);
|
|
|
|
|
role.setModuleNumber(0);
|
|
|
|
|
return role;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/list-user")
|
|
|
|
|
@ApiOperation(value = "查询角色", notes = "查询用户所拥有的角色信息")
|
|
|
|
|
public ResultBean findSysRoleByUser() {
|
|
|
|
|
try {
|
|
|
|
|
if(!AuthUtil.getUserType().equals(CommonEnumUtil.USER_TYPE.ADMIN)){
|
|
|
|
|
if (!AuthUtil.getUserType().equals(CommonEnumUtil.USER_TYPE.ADMIN)) {
|
|
|
|
|
List<SysRole> result = personnelService.findSysRoleByUserId(getSessionUser().getUser().getId());
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
|
|
|
|
|
.setResultList(result);
|
|
|
|
@ -78,6 +92,7 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询所有角色
|
|
|
|
|
*
|
|
|
|
|
* @param ids 角色id数组
|
|
|
|
|
* @return 处理结果
|
|
|
|
|
*/
|
|
|
|
@ -96,6 +111,7 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询角色的所有角色权限关系
|
|
|
|
|
*
|
|
|
|
|
* @param roleId 角色id
|
|
|
|
|
* @return 处理结果
|
|
|
|
|
*/
|
|
|
|
@ -117,16 +133,16 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@GetMapping(value="/query")
|
|
|
|
|
@ApiOperation(value="查询角色",notes="组合查询角色,外带分页功能")
|
|
|
|
|
@GetMapping(value = "/query")
|
|
|
|
|
@ApiOperation(value = "查询角色", notes = "组合查询角色,外带分页功能")
|
|
|
|
|
public ResultBean queryPager(SysRole bean, Pager pager) {
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
ListPager result = null;
|
|
|
|
|
if(AuthUtil.getUserType().equals(CommonEnumUtil.USER_TYPE.ADMIN)){
|
|
|
|
|
result = sysRoleService.findPager(bean,pager);
|
|
|
|
|
}else {
|
|
|
|
|
if (AuthUtil.getUserType().equals(CommonEnumUtil.USER_TYPE.ADMIN)) {
|
|
|
|
|
result = sysRoleService.findPager(bean, pager);
|
|
|
|
|
} else {
|
|
|
|
|
List<SysRefUserRole> refList = personnelService.findSysRefUserRole(getSessionUser().getUser().getId());
|
|
|
|
|
if(refList != null && refList.size() > 0){
|
|
|
|
|
if (refList != null && refList.size() > 0) {
|
|
|
|
|
List<Long> idList = new ArrayList<>(refList.size());
|
|
|
|
|
refList.forEach(ref -> idList.add(ref.getRoleId()));
|
|
|
|
|
|
|
|
|
@ -134,15 +150,16 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ResultBean.success("操作成功").setListPager(result).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改角色状态
|
|
|
|
|
*
|
|
|
|
|
* @param id 角色id
|
|
|
|
|
* @param status 状态
|
|
|
|
|
* @return 处理结果
|
|
|
|
@ -156,9 +173,9 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
ValidatorBean.checkNotZero(status, "角色状态不能为空");
|
|
|
|
|
|
|
|
|
|
SysRole role = sysRoleService.get(id);
|
|
|
|
|
ValidatorBean.checkNotNull(role,"不存在的角色信息");
|
|
|
|
|
ValidatorBean.checkNotNull(role, "不存在的角色信息");
|
|
|
|
|
role.setRoleStatus(status);
|
|
|
|
|
ConvertBean.modelUpdate(role,getSessionUser());
|
|
|
|
|
ConvertBean.modelUpdate(role, getSessionUser());
|
|
|
|
|
sysRoleService.update(role);
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
@ -171,74 +188,77 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量修改系统角色状态
|
|
|
|
|
*
|
|
|
|
|
* @param ids 系统角色ids数组
|
|
|
|
|
* @param status 状态
|
|
|
|
|
* @return 处理结果
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping(value = "/batch-status")
|
|
|
|
|
@ApiOperation(value = "批量修改系统角色状态", notes = "根据ID修改系统角色状态")
|
|
|
|
|
public ResultBean updateBatchStatus(Long[] ids,int status) {
|
|
|
|
|
public ResultBean updateBatchStatus(Long[] ids, int status) {
|
|
|
|
|
try {
|
|
|
|
|
// 数据校验
|
|
|
|
|
ValidatorBean.checkNotNull(ids, "角色id 不能为空");
|
|
|
|
|
ValidatorBean.checkNotZero(status, "角色状态不能为空");
|
|
|
|
|
|
|
|
|
|
sysRoleService.updateSysRoleStatusByIds(ids,status,AuthUtil.getSessionUser());
|
|
|
|
|
sysRoleService.updateSysRoleStatusByIds(ids, status, AuthUtil.getSessionUser());
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
} catch(ImppBusiException busExcep){
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增角色权限关系
|
|
|
|
|
*
|
|
|
|
|
* @param roleId 角色id
|
|
|
|
|
* @param refIds 关系di
|
|
|
|
|
* @return 处理结果
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping(value = "/ref-menu/insert")
|
|
|
|
|
@ApiOperation(value = "新增角色权限关系", notes = "新增角色权限关系")
|
|
|
|
|
public ResultBean insertRefMenu(Long roleId,String[] refIds) {
|
|
|
|
|
public ResultBean insertRefMenu(Long roleId, String[] refIds) {
|
|
|
|
|
try {
|
|
|
|
|
startMultiService();
|
|
|
|
|
|
|
|
|
|
// 数据校验
|
|
|
|
|
ValidatorBean.checkNotNull(roleId, "角色roleId 不能为空");
|
|
|
|
|
|
|
|
|
|
ConvertBean.modelSafeArrayNumber(refIds,true);
|
|
|
|
|
ConvertBean.modelSafeArrayNumber(refIds, true);
|
|
|
|
|
|
|
|
|
|
sysRoleService.refreshSysRoleRef(roleId,StringTool.getArrayLong(refIds),AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
sysRoleService.refreshSysRoleRef(roleId, StringTool.getArrayLong(refIds), AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
} catch(ImppBusiException busExcep){
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量新增角色权限关系
|
|
|
|
|
*
|
|
|
|
|
* @param roleIds 角色id 集合
|
|
|
|
|
* @param menuIds 功能id
|
|
|
|
|
* @return 处理结果
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping(value = "/ref-menu/batch-insert")
|
|
|
|
|
@ApiOperation(value = "批量新增角色权限关系", notes = "批量新增角色权限关系")
|
|
|
|
|
public ResultBean insertBatchRefMenu(String[] roleIds,String[] menuIds) {
|
|
|
|
|
public ResultBean insertBatchRefMenu(String[] roleIds, String[] menuIds) {
|
|
|
|
|
try {
|
|
|
|
|
startMultiService();
|
|
|
|
|
|
|
|
|
|
roleIds = ConvertBean.modelSafeArrayNumber(roleIds,true);
|
|
|
|
|
menuIds = ConvertBean.modelSafeArrayNumber(menuIds,true);
|
|
|
|
|
roleIds = ConvertBean.modelSafeArrayNumber(roleIds, true);
|
|
|
|
|
menuIds = ConvertBean.modelSafeArrayNumber(menuIds, true);
|
|
|
|
|
|
|
|
|
|
// 数据校验
|
|
|
|
|
ValidatorBean.checkNotNull(roleIds, "角色roleIds 不能为空");
|
|
|
|
|
|
|
|
|
|
if(roleIds.length == 0){
|
|
|
|
|
if (roleIds.length == 0) {
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
@ -247,21 +267,21 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
}
|
|
|
|
|
List<SysRole> roleList = sysRoleService.findSysRoleByInIdAndStatus(StringTool.getArrayLong(roleIds), CommonEnumUtil.DATA_STATUS.DISABLE.getValue());
|
|
|
|
|
|
|
|
|
|
if(roleList != null && roleList.size() > 0){
|
|
|
|
|
if (roleList != null && roleList.size() > 0) {
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION_DATA_NOT_EXIT.getCode())
|
|
|
|
|
.setErrorDetail("["+roleList.get(0).getName()+"]角色已禁用,不允许操作")
|
|
|
|
|
.setErrorDetail("[" + roleList.get(0).getName() + "]角色已禁用,不允许操作")
|
|
|
|
|
.setErrorSolution("请重新操作")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
sysRoleService.refreshBatchSysRoleRef(StringTool.getArrayLong(roleIds),StringTool.getArrayLong(menuIds),
|
|
|
|
|
sysRoleService.refreshBatchSysRoleRef(StringTool.getArrayLong(roleIds), StringTool.getArrayLong(menuIds),
|
|
|
|
|
AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
} catch(ImppBusiException busExcep){
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|