Browse Source

Merge branch 'dev-whetherMetaCanUse' of xiongzhu/raex_back into master

sunkean 3 years ago
parent
commit
cfdc385afc

+ 20 - 0
src/main/java/com/izouma/nineth/dto/WhetherMetaCanUse.java

@@ -0,0 +1,20 @@
+package com.izouma.nineth.dto;
+
+import com.izouma.nineth.enums.UserHoldTypeEnum;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class WhetherMetaCanUse {
+
+    private Long id;
+
+    private boolean hold;
+
+    private String address;
+
+    private UserHoldTypeEnum type;
+}

+ 6 - 0
src/main/java/com/izouma/nineth/enums/UserHoldTypeEnum.java

@@ -0,0 +1,6 @@
+package com.izouma.nineth.enums;
+
+public enum UserHoldTypeEnum {
+
+    ASSET;
+}

+ 3 - 0
src/main/java/com/izouma/nineth/repo/AssetRepo.java

@@ -111,4 +111,7 @@ public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationE
     int totalElements();
 
     List<Asset> findAllByUserIdAndStatusIn(Long userId, List<AssetStatus> status);
+
+    @Query("select a from Asset a where a.status in (com.izouma.nineth.enums.AssetStatus.NORMAL,com.izouma.nineth.enums.AssetStatus.TRADING,com.izouma.nineth.enums.AssetStatus.GIFTING,com.izouma.nineth.enums.AssetStatus.MINTING,com.izouma.nineth.enums.AssetStatus.AUCTIONING) and a.userId = ?1 and a.name like ?2")
+    List<Asset> findAllByUserIdAndNameLike(Long userId, String name);
 }

+ 19 - 0
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -963,4 +963,23 @@ public class AssetService {
             }
         });
     }
+
+    public List<WhetherMetaCanUse> whetherMetaCanUse(Long userId) {
+        List<WhetherMetaCanUse> whetherMetaCanUses = new ArrayList<>();
+        whetherMetaCanUses.add(build(userId, "艾弗森", 1L));
+        whetherMetaCanUses.add(build(userId, "开拓猿", 2L));
+        whetherMetaCanUses.add(build(userId, "朋克", 3L));
+        whetherMetaCanUses.add(build(userId, "MUGEN", 4L));
+        return whetherMetaCanUses;
+    }
+
+    private WhetherMetaCanUse build (Long userId, String name, Long id) {
+        WhetherMetaCanUse whetherMetaCanUse = new WhetherMetaCanUse();
+        whetherMetaCanUse.setId(id);
+        whetherMetaCanUse.setType(UserHoldTypeEnum.ASSET);
+        whetherMetaCanUse.setAddress("https://www.raex.vip/9th/productSearch?search=" + name + "&source=TRANSFER");
+        List<Asset> assets = assetRepo.findAllByUserIdAndNameLike(userId, "%" + name + "%");
+        whetherMetaCanUse.setHold(CollectionUtils.isNotEmpty(assets));
+        return whetherMetaCanUse;
+    }
 }

+ 13 - 6
src/main/java/com/izouma/nineth/web/AssetController.java

@@ -7,6 +7,7 @@ import com.izouma.nineth.domain.GiftOrder;
 import com.izouma.nineth.dto.AssetDTO;
 import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.dto.UserHistory;
+import com.izouma.nineth.dto.WhetherMetaCanUse;
 import com.izouma.nineth.enums.CollectionType;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.AssetRepo;
@@ -37,11 +38,11 @@ import java.util.concurrent.ExecutionException;
 @RequestMapping("/asset")
 @AllArgsConstructor
 public class AssetController extends BaseController {
-    private AssetService     assetService;
-    private AssetRepo        assetRepo;
+    private AssetService assetService;
+    private AssetRepo assetRepo;
     private GiftOrderService giftOrderService;
-    private OrderRepo        orderRepo;
-    private CacheService     cacheService;
+    private OrderRepo orderRepo;
+    private CacheService cacheService;
 
     //@PreAuthorize("hasRole('ADMIN')")
 //    @PostMapping("/save")
@@ -193,9 +194,10 @@ public class AssetController extends BaseController {
 
     @ApiOperation("销毁")
     @PostMapping("/destroy")
-    public void destroy(@RequestParam Long id ,@RequestParam String tradeCode) {
-        assetService.destroy(id, SecurityUtils.getAuthenticatedUser().getId(),tradeCode);
+    public void destroy(@RequestParam Long id, @RequestParam String tradeCode) {
+        assetService.destroy(id, SecurityUtils.getAuthenticatedUser().getId(), tradeCode);
     }
+
     @ApiOperation("开盲盒")
     @PostMapping("/open")
     public void open(@RequestParam Long id) {
@@ -234,6 +236,11 @@ public class AssetController extends BaseController {
     public void giveBonus() {
         assetService.giveBonus();
     }
+
+    @GetMapping("/whetherMetaCanUse/{userId}")
+    public List<WhetherMetaCanUse> whetherMetaCanUse(@PathVariable Long userId) {
+        return assetService.whetherMetaCanUse(userId);
+    }
 }