Преглед изворни кода

元宇宙角色接口调整

sunkean пре 3 година
родитељ
комит
6053a665e2

+ 7 - 0
src/main/java/com/izouma/nineth/dto/MetaPlayerRole.java

@@ -12,9 +12,16 @@ public class MetaPlayerRole {
 
 
     private Long id;
     private Long id;
 
 
+    private String name;
+
     private boolean hold;
     private boolean hold;
 
 
     private String address;
     private String address;
 
 
     private UserHoldTypeEnum type;
     private UserHoldTypeEnum type;
+
+    public MetaPlayerRole(Long id, String name) {
+        this.id = id;
+        this.name = name;
+    }
 }
 }

+ 18 - 0
src/main/java/com/izouma/nineth/dto/MetaPlayerRoleClassify.java

@@ -0,0 +1,18 @@
+package com.izouma.nineth.dto;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class MetaPlayerRoleClassify {
+
+    private String classify;
+
+    private List<MetaPlayerRole> metaPlayerRoleList;
+}

+ 1 - 1
src/main/java/com/izouma/nineth/security/WebSecurityConfig.java

@@ -140,7 +140,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/user/synchronizationData").permitAll()
                 .antMatchers("/user/synchronizationData").permitAll()
                 .antMatchers("/rarityLabel/label/*").permitAll()
                 .antMatchers("/rarityLabel/label/*").permitAll()
                 .antMatchers("/collection/count/*").permitAll()
                 .antMatchers("/collection/count/*").permitAll()
-                .antMatchers("/asset/whetherMetaCanUse/*").permitAll()
+                .antMatchers("/asset/*/metaPlayerRole").permitAll()
                 .antMatchers("/metaPlayerInfo/**").permitAll()
                 .antMatchers("/metaPlayerInfo/**").permitAll()
                 .antMatchers("/metaSpatialInfo/**").permitAll()
                 .antMatchers("/metaSpatialInfo/**").permitAll()
                 .antMatchers("/onOff/**").permitAll()
                 .antMatchers("/onOff/**").permitAll()

+ 36 - 16
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -41,7 +41,6 @@ import java.util.*;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ForkJoinPool;
 import java.util.concurrent.ForkJoinPool;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 @Service
 @Service
@@ -952,22 +951,43 @@ public class AssetService {
                 .build());
                 .build());
     }
     }
 
 
-    public List<MetaPlayerRole> metaPlayerRole(Long userId) {
-        List<MetaPlayerRole> metaPlayerRoles = new ArrayList<>();
-        metaPlayerRoles.add(build(userId, "艾弗森", 1L));
-        metaPlayerRoles.add(build(userId, "开拓猿", 2L));
-        metaPlayerRoles.add(build(userId, "朋克", 3L));
-        metaPlayerRoles.add(build(userId, "MUGEN", 4L));
-        return metaPlayerRoles;
+    public List<MetaPlayerRoleClassify> metaPlayerRole(Long userId) {
+        List<MetaPlayerRoleClassify> metaPlayerRoleClassifies = new ArrayList<>();
+        metaPlayerRoleClassifies.add(buildMetaPlayerRoleClassify(userId, "艾弗森", 1L));
+        metaPlayerRoleClassifies.add(buildMetaPlayerRoleClassify(userId, "开拓猿", 2L));
+        metaPlayerRoleClassifies.add(buildMetaPlayerRoleClassify(userId, "朋克", 3L));
+        metaPlayerRoleClassifies.add(buildMetaPlayerRoleClassify(userId, "MUGEN", 4L));
+        return metaPlayerRoleClassifies;
+
+    }
+
+    private MetaPlayerRoleClassify buildMetaPlayerRoleClassify(Long userId, String name, Long id) {
+        MetaPlayerRoleClassify metaPlayerRoleClassify = new MetaPlayerRoleClassify();
+        metaPlayerRoleClassify.setClassify(name);
+        List<MetaPlayerRole> metaPlayerRoleList;
+        if("MUGEN".equals(name)) {
+            metaPlayerRoleList = Arrays.asList(new MetaPlayerRole(id, "无限集团"),
+                    new MetaPlayerRole(id + 1, "苍茫雷道"),
+                    new MetaPlayerRole(id + 2, "炼炉天族"),
+                    new MetaPlayerRole(id + 3, "未央宗"),
+                    new MetaPlayerRole(id + 4, "八级门"),
+                    new MetaPlayerRole(id + 5, "人族"),
+                    new MetaPlayerRole(id + 6, "凤鸣寺"),
+                    new MetaPlayerRole(id + 7, "九州岛"));
+        } else {
+            metaPlayerRoleList = Collections.singletonList(new MetaPlayerRole(id, name));
+        }
+        metaPlayerRoleClassify.setMetaPlayerRoleList(build(userId, metaPlayerRoleList));
+        return metaPlayerRoleClassify;
     }
     }
 
 
-    private MetaPlayerRole build (Long userId, String name, Long id) {
-        MetaPlayerRole metaPlayerRole = new MetaPlayerRole();
-        metaPlayerRole.setId(id);
-        metaPlayerRole.setType(UserHoldTypeEnum.ASSET);
-        metaPlayerRole.setAddress("https://www.raex.vip/9th/productSearch?search=" + name + "&source=TRANSFER");
-        List<Asset> assets = assetRepo.findAllByUserIdAndNameLike(userId, "%" + name + "%");
-        metaPlayerRole.setHold(CollectionUtils.isNotEmpty(assets));
-        return metaPlayerRole;
+    private List<MetaPlayerRole> build (Long userId, List<MetaPlayerRole> metaPlayerRoleList) {
+        metaPlayerRoleList.forEach(metaPlayerRole -> {
+            metaPlayerRole.setType(UserHoldTypeEnum.ASSET);
+            metaPlayerRole.setAddress("https://www.raex.vip/9th/productSearch?search=" + metaPlayerRole.getName() + "&source=TRANSFER");
+            List<Asset> assets = assetRepo.findAllByUserIdAndNameLike(userId, "%" + metaPlayerRole.getName() + "%");
+            metaPlayerRole.setHold(CollectionUtils.isNotEmpty(assets));
+        });
+        return metaPlayerRoleList;
     }
     }
 }
 }

+ 2 - 5
src/main/java/com/izouma/nineth/web/AssetController.java

@@ -4,10 +4,7 @@ import com.fasterxml.jackson.annotation.JsonView;
 import com.izouma.nineth.TokenHistory;
 import com.izouma.nineth.TokenHistory;
 import com.izouma.nineth.domain.Asset;
 import com.izouma.nineth.domain.Asset;
 import com.izouma.nineth.domain.GiftOrder;
 import com.izouma.nineth.domain.GiftOrder;
-import com.izouma.nineth.dto.AssetDTO;
-import com.izouma.nineth.dto.MetaPlayerRole;
-import com.izouma.nineth.dto.PageQuery;
-import com.izouma.nineth.dto.UserHistory;
+import com.izouma.nineth.dto.*;
 import com.izouma.nineth.enums.CollectionType;
 import com.izouma.nineth.enums.CollectionType;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.AssetRepo;
 import com.izouma.nineth.repo.AssetRepo;
@@ -232,7 +229,7 @@ public class AssetController extends BaseController {
     }
     }
 
 
     @GetMapping("/{userId}/metaPlayerRole")
     @GetMapping("/{userId}/metaPlayerRole")
-    public List<MetaPlayerRole> MetaPlayerRoles(@PathVariable Long userId) {
+    public List<MetaPlayerRoleClassify> MetaPlayerRoles(@PathVariable Long userId) {
         return assetService.metaPlayerRole(userId);
         return assetService.metaPlayerRole(userId);
     }
     }
 }
 }