|
|
@@ -1,5 +1,6 @@
|
|
|
package com.izouma.nineth.service;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import com.izouma.nineth.TokenHistory;
|
|
|
import com.izouma.nineth.annotations.Debounce;
|
|
|
import com.izouma.nineth.config.GeneralProperties;
|
|
|
@@ -82,12 +83,27 @@ public class CollectionService {
|
|
|
|
|
|
@Cacheable(value = "collectionList", key = "#pageQuery.hashCode()")
|
|
|
public PageWrapper<Collection> all(PageQuery pageQuery) {
|
|
|
- pageQuery.getQuery().put("del", false);
|
|
|
+ Map<String, Object> query = pageQuery.getQuery();
|
|
|
+
|
|
|
+ query.put("del", false);
|
|
|
// 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);
|
|
|
+
|
|
|
+ //筛选最低价格
|
|
|
+ if (query.containsKey("minPrice")) {
|
|
|
+ BigDecimal minPrice = Convert.toBigDecimal(query.get("minPrice"));
|
|
|
+ query.remove("minPrice");
|
|
|
+ if (minPrice.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ specification = specification.and((Specification<Collection>) (root, criteriaQuery, criteriaBuilder) -> {
|
|
|
+ List<Predicate> and = new ArrayList<>();
|
|
|
+ and.add(criteriaBuilder.greaterThanOrEqualTo(root.get("price"), minPrice));
|
|
|
+ return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
// if (pageRequest.getSort().stream().noneMatch(order -> order.getProperty().equals("createdAt"))) {
|
|
|
// pageRequest = PageRequest.of(pageRequest.getPageNumber(), pageQuery.getSize(),
|
|
|
// pageRequest.getSort().and(Sort.by("createdAt").descending()));
|