|
@@ -2,11 +2,7 @@ package cn.com.qmth.examcloud.service.core.service;
|
|
|
|
|
|
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
|
|
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.HashSet;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.uac.AccessUserOps;
|
|
import cn.com.qmth.examcloud.common.uac.AccessUserOps;
|
|
@@ -19,6 +15,7 @@ import org.springframework.data.domain.Example;
|
|
import org.springframework.data.domain.ExampleMatcher;
|
|
import org.springframework.data.domain.ExampleMatcher;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -30,6 +27,8 @@ import cn.com.qmth.examcloud.service.core.enums.UserScope;
|
|
import cn.com.qmth.examcloud.service.core.enums.UserType;
|
|
import cn.com.qmth.examcloud.service.core.enums.UserType;
|
|
import cn.com.qmth.examcloud.service.core.params.UserParam;
|
|
import cn.com.qmth.examcloud.service.core.params.UserParam;
|
|
|
|
|
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 用户服务类
|
|
* 用户服务类
|
|
* Created by songyue on 17/1/13.
|
|
* Created by songyue on 17/1/13.
|
|
@@ -65,6 +64,12 @@ public class UserService {
|
|
this.accessUserOps = new AccessUserOpsForRedis(redisTemplate);
|
|
this.accessUserOps = new AccessUserOpsForRedis(redisTemplate);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询所有用户
|
|
|
|
+ * @param userCriteria
|
|
|
|
+ * @param pageable
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
public Page<User> findAll(User userCriteria, Pageable pageable){
|
|
public Page<User> findAll(User userCriteria, Pageable pageable){
|
|
ExampleMatcher exampleMatcher = ExampleMatcher.matching()
|
|
ExampleMatcher exampleMatcher = ExampleMatcher.matching()
|
|
.withMatcher("name", contains())
|
|
.withMatcher("name", contains())
|
|
@@ -74,6 +79,29 @@ public class UserService {
|
|
return users;
|
|
return users;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询所有机构用户
|
|
|
|
+ * @param userCriteria
|
|
|
|
+ * @param pageable
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Page<User> findOrgUser(User userCriteria,Pageable pageable){
|
|
|
|
+ Specification<User> userSpecification = (root, query, cb) -> {
|
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
|
+ predicates.add(cb.equal(root.get("rootOrgId"),root.get("orgId")));
|
|
|
|
+ predicates.add(cb.equal(root.get("type"),userCriteria.getType()));
|
|
|
|
+ if(StringUtils.isNotEmpty(userCriteria.getLoginName())){
|
|
|
|
+ predicates.add(cb.like(root.get("loginName"),"%"+userCriteria.getLoginName()+"%"));
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotEmpty(userCriteria.getName())){
|
|
|
|
+ predicates.add(cb.like(root.get("name"),"%"+userCriteria.getName()+"%"));
|
|
|
|
+ }
|
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
|
+ };
|
|
|
|
+ Page<User> users = userRepo.findAll(userSpecification, pageable);
|
|
|
|
+ return users;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 初始化密码
|
|
* 初始化密码
|
|
* @param userId
|
|
* @param userId
|