From d84fae64e09646caad0659fcdcc0022bb8a75f76 Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Sun, 18 Aug 2024 19:05:56 +0800 Subject: [PATCH 1/4] feat: redPacket the graph To envio --- .../redpacket/RedPacketController.java | 9 +++++ .../redpacket/RedPacketService.java | 34 +++++-------------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java b/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java index f839121..23e0d72 100644 --- a/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java +++ b/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java @@ -18,6 +18,7 @@ import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.util.ObjectUtils; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -31,6 +32,9 @@ public class RedPacketController { @Autowired private RedPacketRepository redPacketRepository; + + @Autowired + private RedPacketService redPacketService; public static final Logger logger = LoggerFactory.getLogger(MemberController.class); @PostMapping("/create") @@ -123,4 +127,9 @@ public Predicate toPredicate(Root root, CriteriaQuery criteriaQuer return BaseResponse.successWithData(redPacketRepository.findAll(queryParam, pageable)); } + @GetMapping("/test") + public void test() { + redPacketService.updateRedpacketStatus(); + } + } diff --git a/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java b/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java index bbf664d..667c995 100644 --- a/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java +++ b/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java @@ -68,8 +68,8 @@ private void updateRedpacketStatusByChainId(String chainId) throws IOException { } JsonObject jsonObject = JsonParser.parseString(jsonResponse).getAsJsonObject(); JsonObject data = jsonObject.getAsJsonObject("data"); - JsonArray redpacketsArray = data.getAsJsonArray("redpackets"); - JsonArray lastupdatesArray = data.getAsJsonArray("lastupdates"); + JsonArray redpacketsArray = data.getAsJsonArray("Redpacket"); + JsonArray lastupdatesArray = data.getAsJsonArray("Lastupdate"); log.debug("lastupdatesArray" + lastupdatesArray.toString()); List redPacketList = redPacketRepository.findUnfinishedRedpacketByChainId(chainId); @@ -131,8 +131,7 @@ private HttpEntity getHttpEntityFromChain(String chainId) throws IOException { HttpPost request = null; switch (chainId) { case Constants.CHAIN_ID_OP: // op - request = new HttpPost( - "https://gateway-arbitrum.network.thegraph.com/api/4146067af3cd632fedc37eef1783bdb2/subgraphs/id/G7LuMuUuWUW8UknEx8x2aVSeFtqpNMEKHvka2aKiDzRm"); + request = new HttpPost("https://indexer.bigdevenergy.link/f9489a8/v1/graphql"); break; // case Constants.CHAIN_ID_SEPOLIA: //sepolia // request = new HttpPost( @@ -144,7 +143,7 @@ private HttpEntity getHttpEntityFromChain(String chainId) throws IOException { // break; case Constants.CHAIN_ID_ARBITRUM: //arbitrum request = new HttpPost( - "http://103.99.179.200:8400/subgraphs/name/redpacket_arbitrum"); + "https://indexer.bigdevenergy.link/40a09e1/v1/graphql\n"); break; // case Constants.CHAIN_ID_ZKSYNC: //zksync // request = new HttpPost( @@ -168,29 +167,12 @@ private HttpEntity getHttpEntityFromChain(String chainId) throws IOException { String creationTimeGtValue = String.valueOf(time); - String graphQL = "\" {" + - " redpackets (where: { creationTime_gt: " + creationTimeGtValue + " }) {" + - " id " + - " refunded " + - " lock " + - " name " + - " creationTime " + - " allClaimed " + - " claimers {" + - " claimer" + - " claimedValue " + - " }" + - " }" + - " lastupdates (orderBy : lastupdateTimestamp , orderDirection: desc) { lastupdateTimestamp } " + - - "}\""; - + String graphQL = "{\n" + + " \"query\": \"{\\n Redpacket(\\n where: {creationTime: {_gt: \\\"" + creationTimeGtValue + "\\\"}}\\n order_by: {creationTime: desc}\\n ) {\\n id\\n refunded\\n lock\\n name\\n creationTime\\n allClaimed\\n claimers {\\n claimer\\n claimedValue\\n }\\n }\\n Lastupdate(order_by: {lastupdateTimestamp: asc}) {\\n lastupdateTimestamp\\n }\\n}\"\n" + + "}"; - String query = "{ \"query\": " + - graphQL + - " }"; - request.setEntity(new StringEntity(query)); + request.setEntity(new StringEntity(graphQL)); HttpResponse response = httpClient.execute(request); // System.out.println("response" + response); HttpEntity entity = response.getEntity(); From 2aec9341f59c98f259c42dd043899373702a475e Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Sun, 18 Aug 2024 19:07:01 +0800 Subject: [PATCH 2/4] fix: redPacket delete test controller --- .../com/dl/officialsite/redpacket/RedPacketController.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java b/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java index 23e0d72..5015978 100644 --- a/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java +++ b/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java @@ -18,7 +18,6 @@ import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -127,9 +126,4 @@ public Predicate toPredicate(Root root, CriteriaQuery criteriaQuer return BaseResponse.successWithData(redPacketRepository.findAll(queryParam, pageable)); } - @GetMapping("/test") - public void test() { - redPacketService.updateRedpacketStatus(); - } - } From 1aa6695dec2bf2de8695337fc64d99efc9ca6473 Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Sun, 18 Aug 2024 19:22:41 +0800 Subject: [PATCH 3/4] fix: redPacket fix arb graph Url --- .../com/dl/officialsite/redpacket/RedPacketController.java | 6 ++++++ .../com/dl/officialsite/redpacket/RedPacketService.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java b/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java index 5015978..23e0d72 100644 --- a/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java +++ b/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java @@ -18,6 +18,7 @@ import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.util.ObjectUtils; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -126,4 +127,9 @@ public Predicate toPredicate(Root root, CriteriaQuery criteriaQuer return BaseResponse.successWithData(redPacketRepository.findAll(queryParam, pageable)); } + @GetMapping("/test") + public void test() { + redPacketService.updateRedpacketStatus(); + } + } diff --git a/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java b/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java index 667c995..9219727 100644 --- a/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java +++ b/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java @@ -143,7 +143,7 @@ private HttpEntity getHttpEntityFromChain(String chainId) throws IOException { // break; case Constants.CHAIN_ID_ARBITRUM: //arbitrum request = new HttpPost( - "https://indexer.bigdevenergy.link/40a09e1/v1/graphql\n"); + "https://indexer.bigdevenergy.link/40a09e1/v1/graphql"); break; // case Constants.CHAIN_ID_ZKSYNC: //zksync // request = new HttpPost( From 4c71f61b42de6e0b2cf9901136499eaa5321e626 Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Sun, 18 Aug 2024 19:23:20 +0800 Subject: [PATCH 4/4] fix: redPacket delete test url --- .../com/dl/officialsite/redpacket/RedPacketController.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java b/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java index 23e0d72..5015978 100644 --- a/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java +++ b/src/main/java/com/dl/officialsite/redpacket/RedPacketController.java @@ -18,7 +18,6 @@ import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -127,9 +126,4 @@ public Predicate toPredicate(Root root, CriteriaQuery criteriaQuer return BaseResponse.successWithData(redPacketRepository.findAll(queryParam, pageable)); } - @GetMapping("/test") - public void test() { - redPacketService.updateRedpacketStatus(); - } - }