|
|
@@ -18,10 +18,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import javax.persistence.criteria.*;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.util.*;
|
|
|
|
|
|
@@ -340,4 +342,27 @@ public class UserspaceServiceImpl implements UserspaceService {
|
|
|
|
|
|
syncUserSpaceInfo(space.toView(), "更换管理员");
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<Userspace> findByKeyword(final String keyword, int pageNumber, int pageSize) {
|
|
|
+ Pageable pageable = PageInfo.pageRequest(pageNumber, pageSize);
|
|
|
+ Page<Userspace> page = userspaceDao.findAll(new Specification<Userspace>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<Userspace> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
+ List<Predicate> keyPredicates = new ArrayList<>();
|
|
|
+ // 模糊查询企业名称,营业执照号,注册地址,管理员姓名
|
|
|
+ keyPredicates.add(cb.like(cb.upper(root.get("spaceName").as(String.class)), "%" + keyword.toUpperCase() + "%"));
|
|
|
+ keyPredicates.add(cb.like(cb.upper(root.get("businessCode").as(String.class)), "%" + keyword.toUpperCase() + "%"));
|
|
|
+ keyPredicates.add(cb.like(cb.upper(root.get("regAddress").as(String.class)), "%" + keyword.toUpperCase() + "%"));
|
|
|
+ keyPredicates.add(cb.like(cb.upper(root.join("admin", JoinType.INNER).get("vipName").as(String.class)), "%" + keyword.toUpperCase() + "%"));
|
|
|
+
|
|
|
+ Predicate[] predicates = new Predicate[keyPredicates.size()];
|
|
|
+ query.where(cb.or(keyPredicates.toArray(predicates)));
|
|
|
+ query.orderBy(cb.desc(root.get("registerDate").as(Integer.class)));
|
|
|
+
|
|
|
+ return query.getRestriction();
|
|
|
+ }
|
|
|
+ }, pageable);
|
|
|
+ return new PageInfo<Userspace>(page.getContent(), pageable, page.getTotalElements());
|
|
|
+ }
|
|
|
}
|