|
@@ -1,7 +1,5 @@
|
|
|
package cn.com.qmth.examcloud.service.core.service;
|
|
|
|
|
|
-import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
|
|
|
-
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashSet;
|
|
@@ -27,7 +25,6 @@ import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
|
|
|
import cn.com.qmth.examcloud.service.core.dto.UserInfo;
|
|
|
import cn.com.qmth.examcloud.service.core.entity.Org;
|
|
|
-import cn.com.qmth.examcloud.service.core.entity.Specialty;
|
|
|
import cn.com.qmth.examcloud.service.core.entity.Student;
|
|
|
import cn.com.qmth.examcloud.service.core.entity.User;
|
|
|
import cn.com.qmth.examcloud.service.core.entity.UserLogin;
|
|
@@ -107,7 +104,7 @@ public class UserService {
|
|
|
int pageNumber = pageable.getPageNumber();
|
|
|
int pageSize = pageable.getPageSize();
|
|
|
users = users.stream()
|
|
|
- .filter(user -> filterUser(user))
|
|
|
+ .filter(user -> filterNonMarkerUser(user))
|
|
|
.collect(Collectors.toList());
|
|
|
long total = users.size();
|
|
|
users = users.stream()
|
|
@@ -119,11 +116,11 @@ public class UserService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 过滤评卷员
|
|
|
+ * 过滤非评卷员
|
|
|
* @param user
|
|
|
* @return
|
|
|
*/
|
|
|
- private boolean filterUser(User user){
|
|
|
+ private boolean filterNonMarkerUser(User user){
|
|
|
List<UserRole> userRoles = user.getUserRoles();
|
|
|
if(userRoles != null){
|
|
|
if(userRoles.size() == 1 && userRoles.get(0).getRoleCode().equals(RoleMeta.MARKER.name())){
|
|
@@ -135,6 +132,27 @@ public class UserService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 过滤管理角色
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean filterAdminUser(User user){
|
|
|
+ List<UserRole> userRoles = user.getUserRoles();
|
|
|
+ if(userRoles != null){
|
|
|
+ for(UserRole userRole:userRoles){
|
|
|
+ if(userRole.getRoleCode().equals(RoleMeta.MARKER.name())
|
|
|
+ || userRole.getRoleCode().equals(RoleMeta.STUDENT.name())
|
|
|
+ || userRole.getRoleCode().equals(RoleMeta.LC_USER.name())){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询所有机构用户
|
|
|
* @param userCriteria
|
|
@@ -160,8 +178,19 @@ public class UserService {
|
|
|
}
|
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
};
|
|
|
- Page<User> users = userRepo.findAll(userSpecification, pageable);
|
|
|
- return users;
|
|
|
+ List<User> users = userRepo.findAll(userSpecification);
|
|
|
+ int pageNumber = pageable.getPageNumber();
|
|
|
+ int pageSize = pageable.getPageSize();
|
|
|
+ users = users.stream()
|
|
|
+ .filter(user -> filterAdminUser(user))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ long total = users.size();
|
|
|
+ users = users.stream()
|
|
|
+ .skip(pageNumber * pageSize)
|
|
|
+ .limit(pageSize)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Page<User> userPage = new PageImpl<User>(users,pageable,total);
|
|
|
+ return userPage;
|
|
|
}
|
|
|
|
|
|
/**
|