|
@@ -2,11 +2,13 @@ package com.fdage.controller;
|
|
|
|
|
|
import com.fdage.aop.WebControllerLog;
|
|
import com.fdage.aop.WebControllerLog;
|
|
import com.fdage.pojo.TbRole;
|
|
import com.fdage.pojo.TbRole;
|
|
|
|
+import com.fdage.pojo.TbUser;
|
|
import com.fdage.request.RequestBase;
|
|
import com.fdage.request.RequestBase;
|
|
import com.fdage.request.RequestRole;
|
|
import com.fdage.request.RequestRole;
|
|
import com.fdage.respon.ResponRole;
|
|
import com.fdage.respon.ResponRole;
|
|
import com.fdage.service.IResourceService;
|
|
import com.fdage.service.IResourceService;
|
|
import com.fdage.service.IRoleService;
|
|
import com.fdage.service.IRoleService;
|
|
|
|
+import com.fdage.service.IUserService;
|
|
import com.fdage.util.AjaxJson;
|
|
import com.fdage.util.AjaxJson;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@@ -40,6 +42,11 @@ public class RoleController {
|
|
@Autowired
|
|
@Autowired
|
|
private IResourceService resourceService;
|
|
private IResourceService resourceService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IUserService userService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
@PostMapping("save")
|
|
@PostMapping("save")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@WebControllerLog(description = "角色管理-新增/修改角色")
|
|
@WebControllerLog(description = "角色管理-新增/修改角色")
|
|
@@ -78,6 +85,15 @@ public class RoleController {
|
|
|
|
|
|
}
|
|
}
|
|
BeanUtils.copyProperties(param, roleEntity);
|
|
BeanUtils.copyProperties(param, roleEntity);
|
|
|
|
+
|
|
|
|
+ // 2021-8-16 检查该角色是否被用户使用
|
|
|
|
+ if (roleEntity.getState() == 1){
|
|
|
|
+ if (checkUseRole(roleEntity.getId())) {
|
|
|
|
+ return AjaxJson.failure("当前角色还有关联用户,请先处理用户角色");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
n = roleService.update(roleEntity);
|
|
n = roleService.update(roleEntity);
|
|
|
|
|
|
// 每次修改,删除角色资源表信息,重新添加
|
|
// 每次修改,删除角色资源表信息,重新添加
|
|
@@ -97,6 +113,16 @@ public class RoleController {
|
|
return AjaxJson.failure("新增角色失败");
|
|
return AjaxJson.failure("新增角色失败");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private Boolean checkUseRole(Long id){
|
|
|
|
+ List<String> list = roleService.findUserNameByRoleId(id);
|
|
|
|
+ if(list != null && list.size() > 0){
|
|
|
|
+ return true;
|
|
|
|
+// return AjaxJson.failure("当前角色还有关联用户,请先处理用户角色");
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
@PostMapping("list")
|
|
@PostMapping("list")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@WebControllerLog(description = "角色管理-获取角色列表")
|
|
@WebControllerLog(description = "角色管理-获取角色列表")
|