Ver código fonte

Merge branch 'dev' of http://git.izouma.com/xiongzhu/9th into dev

panhui 4 anos atrás
pai
commit
407904df50

+ 4 - 1
src/main/java/com/izouma/nineth/repo/AssetRepo.java

@@ -44,7 +44,10 @@ public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationE
 
     Asset findFirstByTokenIdAndCreatedAtAfterOrderByCreatedAt(String tokenId, LocalDateTime time);
 
-    List<Asset> findByTxHashIsNullAndTokenIdNotNullAndCreatedAtBeforeOrderByCreatedAtDesc(LocalDateTime time);
+    @Query("select a from Asset a where a.txHash is null and a.tokenId is not null " +
+            "and a.status = com.izouma.nineth.enums.AssetStatus.NORMAL and a.createdAt < ?1 " +
+            "order by a.createdAt desc")
+    List<Asset> toMint(LocalDateTime time);
 
     @Query("select id from Asset where status = ?1")
     List<Long> findAllByStatus(AssetStatus status);

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

@@ -139,8 +139,11 @@ public class AssetController extends BaseController {
     }
 
     @GetMapping("/mint")
-    public String mint() {
-        for (Asset asset : assetRepo.findByTxHashIsNullAndTokenIdNotNullAndCreatedAtBeforeOrderByCreatedAtDesc(LocalDateTime.now())) {
+    public String mint(@RequestParam(required = false) LocalDateTime time) {
+        if (time == null) {
+            time = LocalDateTime.now();
+        }
+        for (Asset asset : assetRepo.toMint(time)) {
             rocketMQTemplate.syncSend(generalProperties.getMintTopic(), asset.getId());
         }
         return "ok";