|
|
|
@ -75,7 +75,7 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
@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);
|
|
|
|
@ -85,14 +85,13 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
.setResultList(sysRoleService.findAll());
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询所有角色
|
|
|
|
|
*
|
|
|
|
|
* @param ids 角色id数组
|
|
|
|
|
* @return 处理结果
|
|
|
|
|
*/
|
|
|
|
@ -104,14 +103,13 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(list);
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询角色的所有角色权限关系
|
|
|
|
|
*
|
|
|
|
|
* @param roleId 角色id
|
|
|
|
|
* @return 处理结果
|
|
|
|
|
*/
|
|
|
|
@ -133,16 +131,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()));
|
|
|
|
|
|
|
|
|
@ -150,17 +148,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 id 角色id
|
|
|
|
|
* @param status 状态
|
|
|
|
|
* @return 处理结果
|
|
|
|
|
*/
|
|
|
|
@ -173,9 +170,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());
|
|
|
|
@ -188,25 +185,24 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量修改系统角色状态
|
|
|
|
|
*
|
|
|
|
|
* @param ids 系统角色ids数组
|
|
|
|
|
* @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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -220,45 +216,89 @@ public class SysRoleController extends CrudBaseController<SysRole> {
|
|
|
|
|
*/
|
|
|
|
|
@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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = "/ref-menu/save")
|
|
|
|
|
@ApiOperation(value = "保存角色权限关系", notes = "? 权限列表没有数据时清理角色的产品")
|
|
|
|
|
public ResultBean saveRefMenuBySoftType(@RequestBody SysRefRoleMenu refRoleMenu) {
|
|
|
|
|
try {
|
|
|
|
|
// 数据校验
|
|
|
|
|
ValidatorBean.beginValid(refRoleMenu)
|
|
|
|
|
.notNull("roleId",refRoleMenu.getRoleId())
|
|
|
|
|
.notNull("softType",refRoleMenu.getSoftType());
|
|
|
|
|
|
|
|
|
|
sysRoleService.refreshSysRoleRef(refRoleMenu.getRoleId(),refRoleMenu.getSoftType(),refRoleMenu.getMenuIdList()
|
|
|
|
|
,AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
} catch(ImppBusiException busExcep){
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增角色权限关系
|
|
|
|
|
* @param roleId 角色id
|
|
|
|
|
* @param softType 产品类型ID
|
|
|
|
|
* @return 处理结果
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(value = "/ref-menu/{roleId}/{softType}/list")
|
|
|
|
|
@ApiOperation(value = "查询角色权限关系", notes = "根据软件类型查询角色权限关系")
|
|
|
|
|
public ResultBean findRefMenuBySoftType(@PathVariable("roleId") Long roleId, @PathVariable("softType") Integer softType) {
|
|
|
|
|
try {
|
|
|
|
|
// 数据校验
|
|
|
|
|
ValidatorBean.checkNotNull(roleId, "角色roleId 不能为空");
|
|
|
|
|
ValidatorBean.checkNotNull(softType, "产品类型 不能为空");
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
|
|
|
|
|
.setResultList(sysRoleService.findSysRefRoleMenuByRoleId(roleId,softType));
|
|
|
|
|
} catch(ImppBusiException busExcep){
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
}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())
|
|
|
|
@ -267,21 +307,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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|