|
@@ -221,31 +221,36 @@ public class UserController extends ControllerSupport {
|
|
|
@ApiOperation(value = "模糊查询用户", notes = "")
|
|
|
@GetMapping("query")
|
|
|
public List<UserDomain> query(@RequestParam(required = false) Long rootOrgId,
|
|
|
- @RequestParam(required = false) Boolean rootOrgIdNull,
|
|
|
+ @RequestParam(required = false) String rootOrgCode,
|
|
|
@RequestParam(required = false) String loginName,
|
|
|
@RequestParam(required = false) String name,
|
|
|
@RequestParam(required = false) Boolean enable,
|
|
|
@RequestParam(required = false) Long roleId, @RequestParam(required = false) Long orgId,
|
|
|
@RequestParam(required = false) String roleCode) {
|
|
|
|
|
|
- User accessUser = getAccessUser();
|
|
|
+ OrgEntity rootOrg = null;
|
|
|
|
|
|
if (null == rootOrgId) {
|
|
|
- rootOrgId = accessUser.getRootOrgId();
|
|
|
- } else {
|
|
|
- validateRootOrgIsolation(rootOrgId);
|
|
|
+ rootOrg = orgRepo.findOne(rootOrgId);
|
|
|
+ if (null == rootOrg) {
|
|
|
+ throw new StatusException("B-150003", "机构不存在");
|
|
|
+ }
|
|
|
+ } else if (StringUtils.isNotBlank(rootOrgCode)) {
|
|
|
+ rootOrg = orgRepo.findByParentIdIsNullAndCode(rootOrgCode);
|
|
|
+ if (null == rootOrg) {
|
|
|
+ throw new StatusException("B-150003", "机构不存在");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- final Long finalRootOrgId = rootOrgId;
|
|
|
-
|
|
|
- OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
|
|
|
- if (null == rootOrg) {
|
|
|
- throw new StatusException("B-150003", "机构不存在");
|
|
|
- }
|
|
|
- if (null != rootOrg.getParentId()) {
|
|
|
- throw new StatusException("B-150004", "机构错误");
|
|
|
+ if (null != rootOrg) {
|
|
|
+ if (null != rootOrg.getParentId()) {
|
|
|
+ throw new StatusException("B-150004", "机构错误");
|
|
|
+ }
|
|
|
+ rootOrgId = rootOrg.getId();
|
|
|
}
|
|
|
|
|
|
+ final Long finalRootOrgId = rootOrgId;
|
|
|
+
|
|
|
if (null != roleId) {
|
|
|
RoleEntity roleEntity = roleRepo.findOne(roleId);
|
|
|
if (null == roleEntity) {
|
|
@@ -254,8 +259,7 @@ public class UserController extends ControllerSupport {
|
|
|
} else if (StringUtils.isNotBlank(roleCode)) {
|
|
|
RoleEntity roleEntity = roleRepo.findByCodeAndRootOrgIdIsNull(roleCode.trim());
|
|
|
if (null == roleEntity) {
|
|
|
- roleEntity = roleRepo.findByCodeAndRootOrgId(roleCode.trim(),
|
|
|
- accessUser.getRootOrgId());
|
|
|
+ roleEntity = roleRepo.findByCodeAndRootOrgId(roleCode.trim(), rootOrgId);
|
|
|
}
|
|
|
if (null == roleEntity) {
|
|
|
throw new StatusException("B-150002", "角色不存在");
|
|
@@ -267,7 +271,8 @@ public class UserController extends ControllerSupport {
|
|
|
|
|
|
Specification<UserEntity> specification = (root, query, cb) -> {
|
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
- if (null == rootOrgIdNull || !rootOrgIdNull) {
|
|
|
+
|
|
|
+ if (null != finalRootOrgId) {
|
|
|
predicates.add(cb.equal(root.get("rootOrgId"), finalRootOrgId));
|
|
|
}
|
|
|
|