|
|
@ -67,12 +67,22 @@ public class UserDao extends BaseDao<MyInfo> { |
|
|
|
Criteria criteria = new Criteria(); |
|
|
|
Criteria criteria = new Criteria(); |
|
|
|
if (!StringUtils.isEmpty(queryUserForm.getUsername())) { |
|
|
|
if (!StringUtils.isEmpty(queryUserForm.getUsername())) { |
|
|
|
if (queryUserForm.isLike()) { |
|
|
|
if (queryUserForm.isLike()) { |
|
|
|
criteria = criteria.and("username").regex(Pattern.compile(".*" + queryUserForm.getUsername() + ".*")); |
|
|
|
criteria = Criteria.where("username").regex(Pattern.compile(".*" + queryUserForm.getUsername() + ".*")); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
criteria = criteria.and("username").is(queryUserForm.getUsername()); |
|
|
|
criteria = Criteria.where("username").is(queryUserForm.getUsername()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Query query = new Query(criteria); |
|
|
|
Query query = new Query(criteria); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (queryUserForm.isOrderScore()) { |
|
|
|
|
|
|
|
Sort sort = Sort.by("creditScore"); |
|
|
|
|
|
|
|
if (queryUserForm.isDesc()) { |
|
|
|
|
|
|
|
query = query.with(sort.descending()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
query = query.with(sort.ascending()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
long count = mongoTemplate.count(query, entityClass()); |
|
|
|
long count = mongoTemplate.count(query, entityClass()); |
|
|
|
Page<MyInfo> page = new Page<>(count, queryUserForm.getCurrentPage(), pageSize); |
|
|
|
Page<MyInfo> page = new Page<>(count, queryUserForm.getCurrentPage(), pageSize); |
|
|
|
List<MyInfo> myInfos = mongoTemplate.find(query.with(PageRequest.of(queryUserForm.getCurrentPage().intValue() - 1, pageSize)), entityClass()); |
|
|
|
List<MyInfo> myInfos = mongoTemplate.find(query.with(PageRequest.of(queryUserForm.getCurrentPage().intValue() - 1, pageSize)), entityClass()); |
|
|
|