Explorar el Código

域名测试永

wangqifan hace 3 años
padre
commit
d06491cc80

+ 2 - 0
src/main/java/com/izouma/nineth/repo/CollectionRepo.java

@@ -205,4 +205,6 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
 
     @Query("select min(price) from Collection where source = 'TRANSFER' and salable = true and onShelf = true and del = false and prefixName like ?1 and name like ?2 and name not like ?3")
     BigDecimal findMinPriceByNameAndPrefixName(String prefixName, String nameLike, String nameNotLike);
+
+    List<Collection> findAllByNameLikeAndSalableAndOnShelf(String name, boolean salable, boolean onshelf);
 }

+ 12 - 5
src/main/java/com/izouma/nineth/service/DomainOrderService.java

@@ -54,14 +54,19 @@ public class DomainOrderService {
     public Map<String, Object> check(String domain) {
         Map<String, Object> result = new HashMap<>();
         Integer count = domainOrderRepo.countAllByDomainNameEqualsAndStatus(domain, CollectionStatus.SUCCESS);
+        if (domain.length() < 5 || domain.length() > 20) {
+            result.put("result", false);
+            result.put("reason", "域名长度不合规");
+            return result;
+        }
         if (count > 0) {
             result.put("result", false);
             result.put("reason", "该域名已被注册");
             return result;
         }
-        if (contentAuditService.auditText(domain)) {
+        if (!contentAuditService.auditText(domain)) {
             result.put("result", false);
-            result.put("reason", "该域名已被注册");
+            result.put("reason", "该域名内容不合规");
             return result;
         }
         result.put("result", true);
@@ -74,11 +79,13 @@ public class DomainOrderService {
 
         String n = domain.substring(domain.length() - 1);
         List<Map<String, Object>> recommend = new ArrayList<>();
-        for (int i = 0; i < 6; i++) {
+
+        for (int i = 0; i < 100; i++) {
             domain = domain + n;
-            if ((Boolean) check(domain).get("result")) {
+            Map<String, Object> checkResult = check(domain);
+            if ((Boolean) checkResult.get("result")) {
                 Map<String, Object> sold = new HashMap<>();
-                sold.put("domain", domain);
+                sold.put("domain", domain + ".uni");
                 sold.put("sold", false);
                 recommend.add(sold);
             }

+ 48 - 28
src/test/java/com/izouma/nineth/service/CollectionServiceTest.java

@@ -24,6 +24,7 @@ import org.bytedeco.javacv.Frame;
 import org.bytedeco.javacv.Java2DFrameConverter;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
 
 import javax.imageio.ImageIO;
 import java.awt.image.BufferedImage;
@@ -38,6 +39,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 class CollectionServiceTest extends ApplicationTests {
 
     @Autowired
@@ -52,6 +54,8 @@ class CollectionServiceTest extends ApplicationTests {
     private PrivilegeOptionRepo privilegeOptionRepo;
     @Autowired
     private SysConfigService    sysConfigService;
+    @Autowired
+    private DomainOrderService  domainOrderService;
 
     @Test
     void toDTO() {
@@ -67,41 +71,41 @@ class CollectionServiceTest extends ApplicationTests {
         Arrays.stream(new File("/Users/qiufangchao/Desktop/mugen_mu").listFiles())
                 .filter(f -> !f.getName().contains(".DS_Store"))
                 .parallel().forEach(file -> {
-                    try {
+            try {
 //                        String name = file.getName();
 //                        Pattern p = Pattern.compile("(\\d+)");
 //                        Matcher matcher = p.matcher(name);
 //                        matcher.find();
 //                        String findname = matcher.group();
 
-                        Collection collection = JSON.parseObject(jsonStr, Collection.class);
-                        collection.setId(null);
-                        collection.setName("MUGEN无限:未央宗#" + num.getAndIncrement());
-                        collection.setStock(1);
-                        collection.setTotal(1);
-                        collection.setSale(0);
-                        collection.setMinterId(5868950L);
-                        collection.setOnShelf(false);
-                        collection.setSalable(false);
+                Collection collection = JSON.parseObject(jsonStr, Collection.class);
+                collection.setId(null);
+                collection.setName("MUGEN无限:未央宗#" + num.getAndIncrement());
+                collection.setStock(1);
+                collection.setTotal(1);
+                collection.setSale(0);
+                collection.setMinterId(5868950L);
+                collection.setOnShelf(false);
+                collection.setSalable(false);
 //                        String thumbPath = "https://cdn.raex.vip/thumb_image/mahjongman/" + file.getName()
 //                                .substring(0, file.getName().lastIndexOf(".")) + ".jpg";
-                        collection.setPic(Collections
-                                .singletonList(new FileObject("", "https://cdn.raex.vip/nft/mugen_mu/" + file
-                                        .getName(), null, "image/png")));
+                collection.setPic(Collections
+                        .singletonList(new FileObject("", "https://cdn.raex.vip/nft/mugen_mu/" + file
+                                .getName(), null, "image/png")));
 
-                        collectionRepo.save(collection);
-                        System.out.println("保存成功" + collection.getId());
+                collectionRepo.save(collection);
+                System.out.println("保存成功" + collection.getId());
 
-                        items.add(BlindBoxItem
-                                .builder()
-                                .collectionId(collection.getId())
-                                .total(1)
-                                .stock(1)
-                                .rare(false)
-                                .build());
-                    } catch (Exception e) {
-                    }
-                });
+                items.add(BlindBoxItem
+                        .builder()
+                        .collectionId(collection.getId())
+                        .total(1)
+                        .stock(1)
+                        .rare(false)
+                        .build());
+            } catch (Exception e) {
+            }
+        });
 
 
     }
@@ -112,7 +116,7 @@ class CollectionServiceTest extends ApplicationTests {
 //                6863188L, 6863438L, 6863449L, 6863588L, 6863608L, 6863671L, 6863745L, 6863760L, 6863938L, 6863954L, 6864008L, 6864081L);
         List<Collection> items = collectionRepo.findByNameLike("MUGEN无限:未央宗#%")
                 .stream()
-                .filter(collection -> collection.getCreatedAt().isAfter(LocalDateTime.of(2022,6,28,0,0)))
+                .filter(collection -> collection.getCreatedAt().isAfter(LocalDateTime.of(2022, 6, 28, 0, 0)))
                 .limit(450L)
                 .collect(Collectors.toList());
 
@@ -126,7 +130,8 @@ class CollectionServiceTest extends ApplicationTests {
         blindBox.setNoSoldOut(true);
         blindBox.setMaxCount(1);
         blindBox.setName("MUGEN无限未央宗数字艺术品盲盒");
-        blindBox.setPic(Arrays.asList(new FileObject(null, "https://cdn.raex.vip/nft/2022-04-16-19-24-54WTJLmsmR.jpg", null, "image/jpeg")));
+        blindBox.setPic(Arrays
+                .asList(new FileObject(null, "https://cdn.raex.vip/nft/2022-04-16-19-24-54WTJLmsmR.jpg", null, "image/jpeg")));
         collectionService.createBlindBox(new CreateBlindBox(blindBox, items.stream().map(i -> {
             BlindBoxItem item = new BlindBoxItem();
             item.setCollectionId(i.getId());
@@ -249,7 +254,8 @@ class CollectionServiceTest extends ApplicationTests {
         blindBox.setNoSoldOut(true);
         blindBox.setMaxCount(1);
         blindBox.setName("520盲盒");
-        blindBox.setPic(Arrays.asList(new FileObject(null, "https://cdn.raex.vip/nft/2022-04-16-19-24-54WTJLmsmR.jpg", null, "image/jpeg")));
+        blindBox.setPic(Arrays
+                .asList(new FileObject(null, "https://cdn.raex.vip/nft/2022-04-16-19-24-54WTJLmsmR.jpg", null, "image/jpeg")));
         collectionService.createBlindBox(new CreateBlindBox(blindBox, items.stream().map(i -> {
             BlindBoxItem item = new BlindBoxItem();
             item.setCollectionId(i.getId());
@@ -258,4 +264,18 @@ class CollectionServiceTest extends ApplicationTests {
         }).collect(Collectors.toList()), 1L));
 
     }
+
+    @Test
+    public void searchRTesty() {
+        List<Map<String, Object>> madin = domainOrderService.search("1");
+        System.out.print(madin);
+    }
+//    @Test
+//    public void clearOldCollection() {
+//        List<String> bannedAssets = Arrays.asList(sysConfigService.getString("older_collections").split(",").clone());
+//        bannedAssets.forEach(name -> {
+//            List<Collection> collections = collectionRepo.findAllByNameLikeAndSalableAndOnShelf();
+//        });
+//
+//    }
 }