Merge branch 'master' into docker_package
This commit is contained in:
commit
e42d997ce3
|
@ -8,8 +8,10 @@ import io.renren.common.validator.group.AddGroup;
|
|||
import io.renren.common.validator.group.DefaultGroup;
|
||||
import io.renren.common.validator.group.UpdateGroup;
|
||||
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.SysUserDTO;
|
||||
import io.renren.modules.sys.enums.SuperAdminEnum;
|
||||
import io.renren.modules.sys.service.SysDeptService;
|
||||
import io.renren.modules.sys.service.SysUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
@ -66,11 +68,23 @@ public class SysDeptController {
|
|||
@LogOperation("查询所有部门列表")
|
||||
// @RequiresPermissions("sys:dept:list")
|
||||
public Result<List<Map<String, Object>>> all(String name) {
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
if (StringUtils.isNotEmpty(name)) {
|
||||
list = jdbcTemplate.queryForList(String.format("SELECT id,`name` FROM sys_dept WHERE `name` LIKE '%s';", "%" + name + "%"));
|
||||
} else {
|
||||
list = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept;");
|
||||
if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) { // 超级管理员
|
||||
if (StringUtils.isNotEmpty(name)) {
|
||||
list = jdbcTemplate.queryForList(String.format("SELECT id,`name` FROM sys_dept WHERE `name` LIKE '%s';", "%" + name + "%"));
|
||||
} 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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue