区域部门管理员只出本区域部门信息

This commit is contained in:
wangliwen 2022-10-31 13:49:45 +08:00
parent 2af6dfc830
commit fd7b66bba9
1 changed files with 18 additions and 4 deletions

View File

@ -8,8 +8,10 @@ import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.DefaultGroup;
import io.renren.common.validator.group.UpdateGroup; import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.security.user.UserDetail;
import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysUserDTO; import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.enums.SuperAdminEnum;
import io.renren.modules.sys.service.SysDeptService; import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysUserService; import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -66,11 +68,23 @@ public class SysDeptController {
@LogOperation("查询所有部门列表") @LogOperation("查询所有部门列表")
// @RequiresPermissions("sys:dept:list") // @RequiresPermissions("sys:dept:list")
public Result<List<Map<String, Object>>> all(String name) { public Result<List<Map<String, Object>>> all(String name) {
UserDetail user = SecurityUser.getUser();
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
if (StringUtils.isNotEmpty(name)) { if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) { // 超级管理员
list = jdbcTemplate.queryForList(String.format("SELECT id,`name` FROM sys_dept WHERE `name` LIKE '%s';", "%" + name + "%")); if (StringUtils.isNotEmpty(name)) {
} else { list = jdbcTemplate.queryForList(String.format("SELECT id,`name` FROM sys_dept WHERE `name` LIKE '%s';", "%" + name + "%"));
list = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept;"); } else {
list = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept;");
}
} else { // 区域管理员
SysDeptDTO sysDeptDTO = sysDeptService.get(user.getDeptId());
if (sysDeptDTO.getDistrict() != null) {
if (StringUtils.isNotEmpty(name)) {
list = jdbcTemplate.queryForList(String.format("SELECT id,`name` FROM sys_dept WHERE `name` LIKE '%s' AND WHERE district = %d;", "%" + name + "%", sysDeptDTO.getDistrict()));
} else {
list = jdbcTemplate.queryForList(String.format("SELECT id,`name` FROM sys_dept WHERE district = %d;", sysDeptDTO.getDistrict()));
}
}
} }
return new Result<List<Map<String, Object>>>().ok(list); return new Result<List<Map<String, Object>>>().ok(list);
} }