Browse Source

Merge branch 'dev-meta-user' of xiongzhu/raex_back into master

sunkean 3 years ago
parent
commit
6d6901eba6

+ 17 - 3
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -25,6 +25,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.scheduling.annotation.Async;
@@ -70,8 +71,20 @@ public class AssetService {
     private UserBalanceService      userBalanceService;
 
     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();
 //        if (query.containsKey("userId")) {
 //            List<Long> orderId = orderRepo
@@ -83,7 +96,8 @@ public class AssetService {
 //                return asset;
 //            });
 //        }
-        return all;
+        return new PageWrapper<>(all.getContent(), all.getPageable().getPageNumber(),
+                all.getPageable().getPageSize(), all.getTotalElements()).toPage();
     }
 
     public List<AssetDTO> userSummary(PageQuery pageQuery) {

+ 7 - 0
src/main/java/com/izouma/nineth/web/MetaPlayerInfoController.java

@@ -3,6 +3,7 @@ package com.izouma.nineth.web;
 import cn.hutool.core.collection.CollectionUtil;
 import com.izouma.nineth.domain.*;
 import com.izouma.nineth.dto.MetaRestResult;
+import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.*;
 import com.izouma.nineth.service.MetaPlayerInfoService;
 import lombok.AllArgsConstructor;
@@ -95,4 +96,10 @@ public class MetaPlayerInfoController {
         }
         return MetaRestResult.returnSuccess(metaUser.isAllowLogin());
     }
+
+    @GetMapping("/{userId}/useCollectionPic")
+    public MetaRestResult<Boolean> useCollectionPic(@PathVariable Long userId) {
+        User user = userRepo.findById(userId).orElseThrow(new BusinessException(String.format("根据userId: [%S]查询不到玩家信息", userId)));
+        return MetaRestResult.returnSuccess(user.isUseCollectionPic());
+    }
 }

+ 0 - 2
src/main/java/com/izouma/nineth/web/UserController.java

@@ -24,9 +24,7 @@ import lombok.AllArgsConstructor;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
-import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.data.domain.Page;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.security.access.prepost.PreAuthorize;