|
@@ -4,6 +4,7 @@ package com.gis.web.controller;
|
|
import com.gis.common.util.Result;
|
|
import com.gis.common.util.Result;
|
|
import com.gis.domain.po.SysRoleEntity;
|
|
import com.gis.domain.po.SysRoleEntity;
|
|
import com.gis.domain.dto.RoleDto;
|
|
import com.gis.domain.dto.RoleDto;
|
|
|
|
+import com.gis.domain.po.SysUserEntity;
|
|
import com.gis.domain.vo.UserVo;
|
|
import com.gis.domain.vo.UserVo;
|
|
import com.gis.service.SysResourceService;
|
|
import com.gis.service.SysResourceService;
|
|
import com.gis.service.SysRoleService;
|
|
import com.gis.service.SysRoleService;
|
|
@@ -17,6 +18,7 @@ import lombok.extern.log4j.Log4j2;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
+import tk.mybatis.mapper.entity.Condition;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -71,6 +73,11 @@ public class SysRoleController extends BaseController {
|
|
return Result.failure("对象id不存在");
|
|
return Result.failure("对象id不存在");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ("sys_admin".equals(entity.getRoleKey())) {
|
|
|
|
+ log.error("超级管理员角色不能修改: {}");
|
|
|
|
+ return Result.failure("超级管理员角色不能修改");
|
|
|
|
+ }
|
|
|
|
+
|
|
BeanUtils.copyProperties(param, entity);
|
|
BeanUtils.copyProperties(param, entity);
|
|
entity.setUpdateTime(new Date());
|
|
entity.setUpdateTime(new Date());
|
|
sysRoleService.update(entity);
|
|
sysRoleService.update(entity);
|
|
@@ -124,11 +131,52 @@ public class SysRoleController extends BaseController {
|
|
return Result.success(resultMap);
|
|
return Result.success(resultMap);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 思考:
|
|
|
|
+ * 1. 定义一个超级管理员角色,而且这个角色是不可以删除、修改的
|
|
|
|
+ * 2. 前端判断这个roleKey,如果是,就不做任何判断
|
|
|
|
+ * 3. 删除角色后,用户的权限怎么去定义
|
|
|
|
+ */
|
|
|
|
+// @ApiOperation("删除角色")
|
|
|
|
+// @GetMapping("removes/{ids}")
|
|
|
|
+// public Result removes(@PathVariable String ids) {
|
|
|
|
+// sysRoleService.deleteByIds(ids);
|
|
|
|
+// return Result.success();
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("启用、停用、注销角色")
|
|
|
|
+ @GetMapping("setStatus/{id}/{status}")
|
|
|
|
+ public Result setStatus(@PathVariable Long id, @PathVariable Integer status) {
|
|
|
|
+
|
|
|
|
+ SysRoleEntity entity = sysRoleService.findById(id);
|
|
|
|
+ if (entity == null) {
|
|
|
|
+ log.error("对象不存在: {}", id);
|
|
|
|
+ return Result.failure("对象不存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 管理员账号不能停用
|
|
|
|
+ if ("sys_admin".equals(entity.getRoleKey())) {
|
|
|
|
+ log.error("超级管理员角色不能停用/注销: {}", id);
|
|
|
|
+ return Result.failure("超级管理员角色不能停用/注销");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (status != 1){
|
|
|
|
+ Condition condition = new Condition(SysUserEntity.class);
|
|
|
|
+ condition.and().andEqualTo("recStatus", "A");
|
|
|
|
+ condition.and().andEqualTo("roleId", id);
|
|
|
|
+ List<SysUserEntity> roles = sysUserService.findAll(condition);
|
|
|
|
+
|
|
|
|
+ if (roles.size() > 0) {
|
|
|
|
+ log.error("该角色已跟用户绑定,不能停用/注销: {}", id);
|
|
|
|
+ return Result.failure("该角色已跟用户绑定,不能停用/注销");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
- @ApiOperation("删除角色")
|
|
|
|
- @GetMapping("removes/{ids}")
|
|
|
|
- public Result removes(@PathVariable String ids) {
|
|
|
|
- sysRoleService.deleteByIds(ids);
|
|
|
|
|
|
+ entity.setStatus(status);
|
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
|
+ sysRoleService.update(entity);
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
|
|
|