diff --git a/src/main/java/com/dl/officialsite/hiring/Hiring.java b/src/main/java/com/dl/officialsite/hiring/Hiring.java index ecca3bdb..d429496e 100644 --- a/src/main/java/com/dl/officialsite/hiring/Hiring.java +++ b/src/main/java/com/dl/officialsite/hiring/Hiring.java @@ -3,7 +3,6 @@ public class Hiring { - private String headline; private String employer; private String jd; diff --git a/src/main/java/com/dl/officialsite/redpacket/RedPacketRepository.java b/src/main/java/com/dl/officialsite/redpacket/RedPacketRepository.java index e2d0608f..e4a7a28d 100644 --- a/src/main/java/com/dl/officialsite/redpacket/RedPacketRepository.java +++ b/src/main/java/com/dl/officialsite/redpacket/RedPacketRepository.java @@ -25,5 +25,7 @@ public interface RedPacketRepository extends JpaRepository, RedPacket findByIdAndStatus(@Param("id") String id, @Param("status") Integer status); + List findByStatus(@Param("status") Integer status); + } diff --git a/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java b/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java index 59986138..425181ff 100644 --- a/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java +++ b/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java @@ -57,7 +57,7 @@ public class RedPacketService { @Scheduled(cron = "0 0/3 * * * ? ") public void updateRedpacketStatus() throws IOException { - log.info("schedule task begin --------------------- " ); + log.info("schedule task begin --------------------- "); HttpPost request = new HttpPost("https://api.studio.thegraph.com/proxy/55957/dapp-learning-redpacket/version/latest"); request.setHeader("Content-Type", "application/json"); // Define your GraphQL query @@ -87,50 +87,58 @@ public void updateRedpacketStatus() throws IOException { JsonObject data = jsonObject.getAsJsonObject("data"); JsonArray redpacketsArray = data.getAsJsonArray("redpackets"); - //log.info("redpacket array : " + redpacketsArray); + log.info("redpacket array : " + redpacketsArray); + List redPacketList = redPacketRepository.findByStatus(0); + for (int i = 0; i < redpacketsArray.size(); i++) { // Access each element in the array JsonObject redpacketObject = redpacketsArray.get(i).getAsJsonObject(); - // log.info("redpackt object : " + redpacketObject); + // log.info("redpackt object : " + redpacketObject); String id = redpacketObject.get("id").getAsString(); - // log.info("id: " + id); - RedPacket redPacket = redPacketRepository.findByIdAndStatus(id,0); - log.info("redPacket: " + redPacket); - if(redPacket == null ) - continue; - String hasRefundedOrAllClaimed = redpacketObject.get("hasRefundedOrAllClaimed").getAsString(); - Boolean claimed = redpacketObject.get("hasRefundedOrAllClaimed").getAsBoolean(); - - if (claimed) { - log.info( "redpacket id: "+id + "claimed: " ); - redPacket.setStatus(1); - redPacketRepository.save(redPacket); - continue; - } - JsonArray claimers = redpacketObject.getAsJsonArray("claimers"); - - // redPacket.getAddressList() is the total claimer. - if(claimers.size() == redPacket.getAddressList().size()) { - log.info( "redpacket id: "+id + " aLL claimed " ); - redPacket.setStatus(1); - redPacketRepository.save(redPacket); - continue; - } + // log.info("id: " + id); + for (int j = 0; j < redPacketList.size(); j++) { + + RedPacket redPacket = redPacketList.get(j); + log.info("redPacket: " + redPacket); + if (!redPacketList.get(j).getId().equals(id)) + continue; + +// Boolean claimed = redpacketObject.get("hasRefundedOrAllClaimed").getAsBoolean(); +// +// if (claimed) { +// log.info("redpacket id: " + id + "claimed: "); +// redPacket.setStatus(1); +// redPacketRepository.save(redPacket); +// continue; +// } + + + JsonArray claimers = redpacketObject.getAsJsonArray("claimers"); + + // redPacket.getAddressList() is the total claimer. + if (claimers.size() == redPacket.getAddressList().size()) { + log.info("redpacket id: " + id + " aLL claimed "); + redPacket.setStatus(1); + redPacketRepository.save(redPacket); + continue; + } - if (claimers.size() > redPacket.getClaimedAddress().size()) { - ArrayList claimersList = new ArrayList<>(); + if (claimers.size() > redPacket.getClaimedAddress().size()) { + ArrayList claimersList = new ArrayList<>(); - for (int j = 0; j < claimers.size(); j++) { - String s = claimers.get(j).getAsJsonObject().get("claimer").getAsString(); - //log.info("claimer address: " + s); - claimersList.add(s); - } - redPacket.setClaimedAddress(claimersList); - log.info( "update claimed address : " + id ); - redPacketRepository.save(redPacket); - } + //todo + for (int k = 0; k < claimers.size(); k++) { + String s = claimers.get(k).getAsJsonObject().get("claimer").getAsString(); + //log.info("claimer address: " + s); + claimersList.add(s); + } + redPacket.setClaimedAddress(claimersList); + log.info("update claimed address : " + id); + redPacketRepository.save(redPacket); + } + } } } } diff --git a/src/main/resources/DB/data-mysql.SQL b/src/main/resources/DB/data-mysql.SQL index 595a5703..7d6cf09c 100644 --- a/src/main/resources/DB/data-mysql.SQL +++ b/src/main/resources/DB/data-mysql.SQL @@ -1,7 +1,7 @@ INSERT INTO team ( team_name, team_profile, administrator, authority) VALUES ("Dapp-Learning DAO co-founders", "Initial founding members and those who contributed significantly, Taking charge of community vault.", "0x1F7b953113f4dFcBF56a1688529CC812865840e1", 10), -("Dapp-Learning DAO builders", "Those who are willing to participate in the community and make outstanding contributions to community building", "", 9), -("Dapp-Learning DAO PR reviewers", "Responsible for review PR of our repository", "", 8), -("Dapp-Learning DAO sharing group", "sharing in Dapp-Learning and earn reward", "", 7), -("Dapp-Learning DAO translation group", "Translate blockchain-related documents ", "", 6); +("Dapp-Learning DAO builders", "Those who are willing to participate in the community and make outstanding contributions to community building", "0x1F7b953113f4dFcBF56a1688529CC812865840e1", 9), +("Dapp-Learning DAO PR reviewers", "Responsible for review PR of our repository", "0x1F7b953113f4dFcBF56a1688529CC812865840e1", 8), +("Dapp-Learning DAO sharing group", "sharing in Dapp-Learning and earn reward", "0x1F7b953113f4dFcBF56a1688529CC812865840e1", 7), +("Dapp-Learning DAO translation group", "Translate blockchain-related documents ", "0x1F7b953113f4dFcBF56a1688529CC812865840e1", 6); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 27b36891..ac1d7c4a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -12,6 +12,8 @@ spring: username: root #password: 12345678 password: {{SPRING_DATASOURCE_PASSWORD}} + maximum-pool-size: 20 + jpa: hibernate: ddl-auto: update