Browse Source

评卷员查询修改

weiwenhai 7 years ago
parent
commit
fbed7b7763

+ 2 - 1
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserApi.java

@@ -274,7 +274,8 @@ public class UserApi {
     								 HttpServletRequest request){
     	AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
     	if(accessUser != null){
-    		return new ResponseEntity(userService.getALLMaker(accessUser.getRootOrgId(),new PageRequest(curPage-1, pageSize)),HttpStatus.OK);
+    		user.setRootOrgId(accessUser.getRootOrgId());
+    		return new ResponseEntity(userService.getAllMaker(user,new PageRequest(curPage-1, pageSize)),HttpStatus.OK);
     	}
         return new ResponseEntity(HttpStatus.NOT_FOUND);
     }

+ 9 - 8
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserService.java

@@ -95,8 +95,10 @@ public class UserService {
 //            Predicate predicate = cb.notEqual(subRootEntity.get("roleCode"), RoleMeta.MARKER.name());
 //            subquery.select(subRootEntity).where(predicate);
 //            predicates.add(cb.exists(subquery));
-            predicates.add(cb.equal(root.get("type"),userCriteria.getType()));
+            predicates.add(cb.equal(root.get("type"),UserType.NOT_STUDENT));
             predicates.add(cb.equal(root.get("rootOrgId"),userCriteria.getRootOrgId()));
+            Join join = root.join("userRoles");
+            predicates.add(cb.notEqual(join.get("roleCode"), "MARKER"));
             if(StringUtils.isNotEmpty(userCriteria.getLoginName())){
                 predicates.add(cb.like(root.get("loginName"),"%"+userCriteria.getLoginName()+"%"));
             }
@@ -343,25 +345,24 @@ public class UserService {
 	 * @param pageable
 	 * @return
 	 */
-	public Page<User> getALLMaker(Long rootOrgId,Pageable pageable){
-		//Specification<User> specification = getSpecification(user);
-		return userRepo.findMarkerByRootOrgId(rootOrgId,pageable);
+	public Page<User> getAllMaker(User user,Pageable pageable){
+		Specification<User> specification = getSpecification(user);
+		return userRepo.findAll(specification,pageable);
 	}
 
 	public Specification<User> getSpecification(User user){
 		Specification<User> specification = (root, query, cb) -> {
 			List<Predicate> predicates = new ArrayList<>();
-			predicates.add(cb.equal(root.get("type"),user.getType()));
+			predicates.add(cb.equal(root.get("type"),UserType.NOT_STUDENT));
             predicates.add(cb.equal(root.get("rootOrgId"),user.getRootOrgId()));
+            Join join = root.join("userRoles");
+            predicates.add(cb.equal(join.get("roleCode"), "MARKER"));
             if(StringUtils.isNotEmpty(user.getLoginName())){
                 predicates.add(cb.like(root.get("loginName"),"%"+user.getLoginName()+"%"));
             }
             if(StringUtils.isNotEmpty(user.getName())){
                 predicates.add(cb.like(root.get("name"),"%"+user.getName()+"%"));
             }
-            if(user.getOrgId() != null){
-                predicates.add(cb.equal(root.get("orgId"),user.getOrgId()));
-            }
             if(user.getEnable() != null){
                 predicates.add(cb.equal(root.get("enable"),user.getEnable()));
             }