xiongzhu 4 years ago
parent
commit
a73d5ccfdf

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

@@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.jpa.repository.Query;
 
 
 import javax.transaction.Transactional;
 import javax.transaction.Transactional;
+import java.time.LocalDateTime;
 import java.util.List;
 import java.util.List;
 
 
 public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationExecutor<Asset> {
 public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationExecutor<Asset> {
@@ -21,4 +22,6 @@ public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationE
     List<Asset> findByCollectionId(Long collectionId);
     List<Asset> findByCollectionId(Long collectionId);
 
 
     List<Asset> findByCollectionIdAndStatusIn(Long collectionId, Iterable<AssetStatus> statuses);
     List<Asset> findByCollectionIdAndStatusIn(Long collectionId, Iterable<AssetStatus> statuses);
+
+    List<Asset> findByCreatedAtBefore(LocalDateTime localDateTime);
 }
 }

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

@@ -287,4 +287,28 @@ public class AssetService {
         Thread.sleep(1000);
         Thread.sleep(1000);
         log.info("" + i);
         log.info("" + i);
     }
     }
+
+    public void setHistory() {
+        List<Asset> assets = assetRepo.findByCreatedAtBefore(LocalDateTime.of(2021, 11, 22, 23, 59, 59));
+        assets.parallelStream().forEach(asset -> {
+            try {
+                User owner = userRepo.findById(asset.getUserId()).orElseThrow(new BusinessException(""));
+                Order order = orderRepo.findById(asset.getOrderId()).orElseThrow(new BusinessException(""));
+                TokenHistory t = TokenHistory.builder()
+                        .tokenId(asset.getTokenId())
+                        .fromUser(asset.getMinter())
+                        .fromUserId(asset.getMinterId())
+                        .fromAvatar(asset.getMinterAvatar())
+                        .toUser(owner.getNickname())
+                        .toUserId(owner.getId())
+                        .toAvatar(owner.getAvatar())
+                        .operation("出售")
+                        .price(order.getPrice())
+                        .build();
+                t.setCreatedAt(asset.getCreatedAt());
+                tokenHistoryRepo.save(t);
+            } catch (Exception e) {
+            }
+        });
+    }
 }
 }

+ 2 - 2
src/main/nine-space/src/components/product/HashCode.vue

@@ -8,7 +8,7 @@
                 <span class="text1">Hash地址:</span>
                 <span class="text1">Hash地址:</span>
                 <span class="flex1"></span>
                 <span class="flex1"></span>
                 <img @click="copy(info.txHash)" src="../../assets/svgs/copy_icon.svg" alt="" />
                 <img @click="copy(info.txHash)" src="../../assets/svgs/copy_icon.svg" alt="" />
-                <span class="van-ellipsis">{{ info.txHash }}</span>
+                <span class="van-ellipsis" style="direction: rtl; text-align: left">{{ info.txHash }}</span>
             </div>
             </div>
             <div class="text-info">
             <div class="text-info">
                 <span class="text1">区块高度: </span>
                 <span class="text1">区块高度: </span>
@@ -19,7 +19,7 @@
                 <span class="text1">令牌ID: </span>
                 <span class="text1">令牌ID: </span>
                 <span class="flex1"></span>
                 <span class="flex1"></span>
                 <img @click="copy(info.tokenId)" src="../../assets/svgs/copy_icon.svg" alt="" />
                 <img @click="copy(info.tokenId)" src="../../assets/svgs/copy_icon.svg" alt="" />
-                <span class="van-ellipsis">{{ info.tokenId }}</span>
+                <span class="van-ellipsis" style="direction: rtl; text-align: left">{{ info.tokenId }}</span>
             </div>
             </div>
         </div>
         </div>
         <div v-else class="textName">铸造者未设置</div>
         <div v-else class="textName">铸造者未设置</div>

+ 1 - 1
src/main/resources/application.yaml

@@ -12,7 +12,7 @@ spring:
   profiles:
   profiles:
     active: dev
     active: dev
   datasource:
   datasource:
-    url: jdbc:mysql://rm-wz9y2p75f51a2o19kbo.mysql.rds.aliyuncs.com:53306/9th_test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
+    url: jdbc:mysql://rm-wz9y2p75f51a2o19kbo.mysql.rds.aliyuncs.com:53306/9th?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
     username: develop
     username: develop
     password: glV1BJCzcNB9ughR
     password: glV1BJCzcNB9ughR
     hikari:
     hikari:

+ 5 - 0
src/test/java/com/izouma/nineth/service/AssetServiceTest.java

@@ -60,4 +60,9 @@ class AssetServiceTest extends ApplicationTests {
         Asset asset = assetRepo.findById(4622L).get();
         Asset asset = assetRepo.findById(4622L).get();
         assetMintService.mint(asset, 1L);
         assetMintService.mint(asset, 1L);
     }
     }
+
+    @Test
+    public void setHistory() {
+        assetService.setHistory();
+    }
 }
 }