|
@@ -11,7 +11,6 @@ import java.util.stream.Stream;
|
|
import javax.persistence.criteria.Predicate;
|
|
import javax.persistence.criteria.Predicate;
|
|
import javax.persistence.criteria.Root;
|
|
import javax.persistence.criteria.Root;
|
|
import javax.persistence.criteria.Subquery;
|
|
import javax.persistence.criteria.Subquery;
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.lang.StringEscapeUtils;
|
|
import org.apache.commons.lang.StringEscapeUtils;
|
|
@@ -85,7 +84,7 @@ public class UserController extends ControllerSupport {
|
|
UserRoleRelationRepo userRoleRelationRepo;
|
|
UserRoleRelationRepo userRoleRelationRepo;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 重新定义
|
|
|
|
|
|
+ * 方法注释
|
|
*
|
|
*
|
|
* @author WANGWEI
|
|
* @author WANGWEI
|
|
* @param curPage
|
|
* @param curPage
|
|
@@ -95,12 +94,12 @@ public class UserController extends ControllerSupport {
|
|
* @param name
|
|
* @param name
|
|
* @param enable
|
|
* @param enable
|
|
* @param roleId
|
|
* @param roleId
|
|
- * @param type
|
|
|
|
|
|
+ * @param roleCode
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "查询所有用户", notes = "")
|
|
@ApiOperation(value = "查询所有用户", notes = "")
|
|
@GetMapping("/all/{curPage}/{pageSize}")
|
|
@GetMapping("/all/{curPage}/{pageSize}")
|
|
- public PageInfo<UserDomain> getAllUser(@PathVariable Integer curPage,
|
|
|
|
|
|
+ public PageInfo<UserDomain> getUserPage(@PathVariable Integer curPage,
|
|
@PathVariable Integer pageSize, @RequestParam Long rootOrgId,
|
|
@PathVariable Integer pageSize, @RequestParam Long rootOrgId,
|
|
@RequestParam String loginName, @RequestParam String name,
|
|
@RequestParam String loginName, @RequestParam String name,
|
|
@RequestParam(required = false) Boolean enable,
|
|
@RequestParam(required = false) Boolean enable,
|
|
@@ -126,7 +125,11 @@ public class UserController extends ControllerSupport {
|
|
throw new StatusException("B-150002", "角色不存在");
|
|
throw new StatusException("B-150002", "角色不存在");
|
|
}
|
|
}
|
|
} else if (StringUtils.isNotBlank(roleCode)) {
|
|
} else if (StringUtils.isNotBlank(roleCode)) {
|
|
- RoleEntity roleEntity = roleRepo.findByCode(roleCode.trim());
|
|
|
|
|
|
+ RoleEntity roleEntity = roleRepo.findByCodeAndRootOrgIdIsNull(roleCode.trim());
|
|
|
|
+ if (null == roleEntity) {
|
|
|
|
+ roleEntity = roleRepo.findByCodeAndRootOrgId(roleCode.trim(),
|
|
|
|
+ accessUser.getRootOrgId());
|
|
|
|
+ }
|
|
if (null == roleEntity) {
|
|
if (null == roleEntity) {
|
|
throw new StatusException("B-150002", "角色不存在");
|
|
throw new StatusException("B-150002", "角色不存在");
|
|
}
|
|
}
|
|
@@ -190,7 +193,7 @@ public class UserController extends ControllerSupport {
|
|
List<Long> roleIdList = Lists.newArrayList();
|
|
List<Long> roleIdList = Lists.newArrayList();
|
|
List<String> roleCodeList = Lists.newArrayList();
|
|
List<String> roleCodeList = Lists.newArrayList();
|
|
for (UserRoleRelationEntity cur : relationList) {
|
|
for (UserRoleRelationEntity cur : relationList) {
|
|
- RoleEntity curRoleEntity = roleRepo.findByCode(cur.getRoleCode());
|
|
|
|
|
|
+ RoleEntity curRoleEntity = roleRepo.findOne(cur.getRoleId());
|
|
if (null == curRoleEntity) {
|
|
if (null == curRoleEntity) {
|
|
throw new StatusException("B-150002", "角色错误");
|
|
throw new StatusException("B-150002", "角色错误");
|
|
}
|
|
}
|
|
@@ -343,7 +346,7 @@ public class UserController extends ControllerSupport {
|
|
throw new StatusException("B-150007", "不允许新增或修改超级管理员");
|
|
throw new StatusException("B-150007", "不允许新增或修改超级管理员");
|
|
}
|
|
}
|
|
UserRoleRelationEntity relation = new UserRoleRelationEntity(saved.getId(),
|
|
UserRoleRelationEntity relation = new UserRoleRelationEntity(saved.getId(),
|
|
- curRoleEntity.getId(), curRoleEntity.getCode());
|
|
|
|
|
|
+ curRoleEntity.getId());
|
|
userRoles.add(relation);
|
|
userRoles.add(relation);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -368,8 +371,9 @@ public class UserController extends ControllerSupport {
|
|
List<UserRoleRelationEntity> relationList = userRoleRelationRepo.findAllByUserId(userId);
|
|
List<UserRoleRelationEntity> relationList = userRoleRelationRepo.findAllByUserId(userId);
|
|
if (CollectionUtils.isNotEmpty(relationList)) {
|
|
if (CollectionUtils.isNotEmpty(relationList)) {
|
|
for (UserRoleRelationEntity cur : relationList) {
|
|
for (UserRoleRelationEntity cur : relationList) {
|
|
- String roleCode = cur.getRoleCode();
|
|
|
|
- if (roleCode.equals(RoleMeta.SUPER_ADMIN.name())) {
|
|
|
|
|
|
+ Long roleId = cur.getRoleId();
|
|
|
|
+ RoleEntity roleEntity = roleRepo.findOne(roleId);
|
|
|
|
+ if (roleEntity.getCode().equals(RoleMeta.SUPER_ADMIN.name())) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -508,37 +512,4 @@ public class UserController extends ControllerSupport {
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 方法注释
|
|
|
|
- *
|
|
|
|
- * @author WANGWEI
|
|
|
|
- * @param request
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @ApiOperation(value = "查询所有评卷员(不分页)", notes = "查询")
|
|
|
|
- @GetMapping("/getMarkerListNoPageable")
|
|
|
|
- public List<UserEntity> getMarkerListNoPageable(HttpServletRequest request) {
|
|
|
|
-
|
|
|
|
- RoleEntity role = roleRepo.findByCode(RoleMeta.MARKER.name());
|
|
|
|
-
|
|
|
|
- Specification<UserEntity> specification = (root, query, cb) -> {
|
|
|
|
- List<Predicate> predicates = new ArrayList<>();
|
|
|
|
- predicates.add(cb.equal(root.get("rootOrgId"), getRootOrgId()));
|
|
|
|
-
|
|
|
|
- Subquery<UserRoleRelationEntity> subquery = query
|
|
|
|
- .subquery(UserRoleRelationEntity.class);
|
|
|
|
- Root<UserRoleRelationEntity> subRoot = subquery.from(UserRoleRelationEntity.class);
|
|
|
|
- subquery.select(subRoot.get("userId"));
|
|
|
|
- Predicate p1 = cb.equal(subRoot.get("roleId"), role.getId());
|
|
|
|
- Predicate p2 = cb.equal(subRoot.get("userId"), root.get("id"));
|
|
|
|
- subquery.where(cb.and(p1, p2));
|
|
|
|
- predicates.add(cb.exists(subquery));
|
|
|
|
-
|
|
|
|
- return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- List<UserEntity> userList = userRepo.findAll(specification);
|
|
|
|
- return userList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|