|
|
@@ -87,8 +87,8 @@ public class CollectionService {
|
|
|
@Cacheable(value = "collectionList", key = "#pageQuery.hashCode()")
|
|
|
public PageWrapper<Collection> all(PageQuery pageQuery) {
|
|
|
pageQuery.getQuery().put("del", false);
|
|
|
- String type = MapUtils.getString(pageQuery.getQuery(), "type", "DEFAULT");
|
|
|
- pageQuery.getQuery().remove("type");
|
|
|
+// String type = MapUtils.getString(pageQuery.getQuery(), "type", "DEFAULT");
|
|
|
+// pageQuery.getQuery().remove("type");
|
|
|
|
|
|
Specification<Collection> specification = JpaUtils.toSpecification(pageQuery, Collection.class);
|
|
|
PageRequest pageRequest = JpaUtils.toPageRequest(pageQuery);
|
|
|
@@ -97,24 +97,24 @@ public class CollectionService {
|
|
|
// pageRequest.getSort().and(Sort.by("createdAt").descending()));
|
|
|
// }
|
|
|
|
|
|
- specification = specification.and((Specification<Collection>) (root, criteriaQuery, criteriaBuilder) -> {
|
|
|
- List<Predicate> and = new ArrayList<>();
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(type) && !"all".equalsIgnoreCase(type)) {
|
|
|
- try {
|
|
|
- if (type.contains(",")) {
|
|
|
- and.add(root.get("type")
|
|
|
- .in(Arrays.stream(type.split(",")).map(s -> Enum.valueOf(CollectionType.class, s))
|
|
|
- .collect(Collectors.toList())));
|
|
|
- } else {
|
|
|
- and.add(criteriaBuilder.equal(root.get("type"), Enum.valueOf(CollectionType.class, type)));
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
|
- });
|
|
|
+// specification = specification.and((Specification<Collection>) (root, criteriaQuery, criteriaBuilder) -> {
|
|
|
+// List<Predicate> and = new ArrayList<>();
|
|
|
+//
|
|
|
+// if (StringUtils.isNotEmpty(type) && !"all".equalsIgnoreCase(type)) {
|
|
|
+// try {
|
|
|
+// if (type.contains(",")) {
|
|
|
+// and.add(root.get("type")
|
|
|
+// .in(Arrays.stream(type.split(",")).map(s -> Enum.valueOf(CollectionType.class, s))
|
|
|
+// .collect(Collectors.toList())));
|
|
|
+// } else {
|
|
|
+// and.add(criteriaBuilder.equal(root.get("type"), Enum.valueOf(CollectionType.class, type)));
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
|
+// });
|
|
|
Page<Collection> page = collectionRepo.findAll(specification, pageRequest);
|
|
|
return new PageWrapper<>(page.getContent(), page.getPageable().getPageNumber(),
|
|
|
page.getPageable().getPageSize(), page.getTotalElements());
|