|
@@ -25,6 +25,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
@@ -70,8 +71,20 @@ public class AssetService {
|
|
|
private UserBalanceService userBalanceService;
|
|
private UserBalanceService userBalanceService;
|
|
|
|
|
|
|
|
public Page<Asset> all(PageQuery pageQuery) {
|
|
public Page<Asset> all(PageQuery pageQuery) {
|
|
|
- Page<Asset> all = assetRepo
|
|
|
|
|
- .findAll(JpaUtils.toSpecification(pageQuery, Asset.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> query = pageQuery.getQuery();
|
|
|
|
|
+ Specification<Asset> specification = JpaUtils.toSpecification(pageQuery, Asset.class);
|
|
|
|
|
+ PageRequest pageRequest = JpaUtils.toPageRequest(pageQuery);
|
|
|
|
|
+ if (query.containsKey("lock")) {
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ query.remove("lock");
|
|
|
|
|
+ specification = specification.and((Specification<Asset>) (root, criteriaQuery, criteriaBuilder) -> {
|
|
|
|
|
+ List<Predicate> and = new ArrayList<>();
|
|
|
|
|
+ and.add(criteriaBuilder.greaterThan(root.get("lockTo"), now));
|
|
|
|
|
+ return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ Page<Asset> all = assetRepo.findAll(specification, pageRequest);
|
|
|
// Map<String, Object> query = pageQuery.getQuery();
|
|
// Map<String, Object> query = pageQuery.getQuery();
|
|
|
// if (query.containsKey("userId")) {
|
|
// if (query.containsKey("userId")) {
|
|
|
// List<Long> orderId = orderRepo
|
|
// List<Long> orderId = orderRepo
|
|
@@ -83,7 +96,8 @@ public class AssetService {
|
|
|
// return asset;
|
|
// return asset;
|
|
|
// });
|
|
// });
|
|
|
// }
|
|
// }
|
|
|
- return all;
|
|
|
|
|
|
|
+ return new PageWrapper<>(all.getContent(), all.getPageable().getPageNumber(),
|
|
|
|
|
+ all.getPageable().getPageSize(), all.getTotalElements()).toPage();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<AssetDTO> userSummary(PageQuery pageQuery) {
|
|
public List<AssetDTO> userSummary(PageQuery pageQuery) {
|