Skip to content

Commit

Permalink
Merge pull request #267 from Dapp-Learning-DAO/dev
Browse files Browse the repository at this point in the history
Add feature adn fix bug
  • Loading branch information
cheng521521 authored Jul 20, 2024
2 parents c42e239 + 06b2f44 commit 913bb60
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 59 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies{
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-validation
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.16.0'
implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16'


implementation 'mysql:mysql-connector-java:8.0.28'
Expand Down
19 changes: 15 additions & 4 deletions src/main/java/com/dl/officialsite/bounty/BountyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.dl.officialsite.common.constants.Constants.BOUNTY_MEMBER_MAP_STATUS_FINISH;
import static com.dl.officialsite.common.enums.CodeEnums.NOT_FOUND_BOUNTY;
import static com.dl.officialsite.common.enums.CodeEnums.NOT_FOUND_MEMBER;

import com.dl.officialsite.bot.constant.BotEnum;
import com.dl.officialsite.bot.constant.ChannelEnum;
Expand All @@ -14,16 +15,14 @@
import com.dl.officialsite.bounty.vo.MyBountySearchVo;
import com.dl.officialsite.common.constants.Constants;
import com.dl.officialsite.common.exception.BizException;
import com.dl.officialsite.hiring.application.Application;
import com.dl.officialsite.mail.EmailService;
import com.dl.officialsite.member.Member;
import com.dl.officialsite.member.MemberRepository;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.criteria.Predicate;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand Down Expand Up @@ -54,13 +53,16 @@ public class BountyService {

private final ApplicationContext applicationContext;

private final EmailService emailService;

public BountyService(BountyRepository bountyRepository,
BountyMemberMapRepository bountyMemberMapRepository, MemberRepository memberRepository,
ApplicationContext applicationContext) {
ApplicationContext applicationContext, EmailService emailService) {
this.bountyRepository = bountyRepository;
this.bountyMemberMapRepository = bountyMemberMapRepository;
this.memberRepository = memberRepository;
this.applicationContext = applicationContext;
this.emailService = emailService;
}


Expand Down Expand Up @@ -195,6 +197,15 @@ public void apply(Long bountyId, String address) {
bountyMemberMap.setMemberAddress(address);
bountyMemberMap.setStatus(Constants.BOUNTY_MEMBER_MAP_STATUS_APPLY);
bountyMemberMapRepository.save(bountyMemberMap);
String creatorAddress = bounty.getCreator();
Member createBountyMember = memberRepository.findByAddress(creatorAddress)
.orElseThrow(() -> new BizException(NOT_FOUND_MEMBER.getCode(), NOT_FOUND_MEMBER.getMsg()));

try {
emailService.sendMail(createBountyMember.getEmail(), "有新人申请bounty", "赶紧去看看吧 https://dapplearning.org/bounty");
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public List<BountyMemberMap> findBountyMemberMapByBountyId(Long bounty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ public static BaseResponse success(){
public static <T> BaseResponse failWithReason(String code, String msg){
return new BaseResponse(code, msg, null);
}

public static <T> BaseResponse failWithReason(CodeEnums codeEnums){
return new BaseResponse(codeEnums.getCode(), codeEnums.getMsg(), null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,27 +232,27 @@ 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/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/Bfrtk6bLRZoULLzAZ99hZ1Ae8kvFxsUWa4e97XzWJYhG");
break;
case Constants.CHAIN_ID_SEPOLIA: // sepolia
request = new HttpPost(
"https://gateway-arbitrum.network.thegraph.com/api/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/9p6zFejTBC2bLLJRCdrk1A2PXfZkriRMacM5wiCAyh5Z");
break;
case Constants.CHAIN_ID_SCROLL: // scroll
request = new HttpPost("https://gateway-arbitrum.network.thegraph.com/api/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/8HhHjdsXrZ1cjq5qNpksoWfAm1NTDDFhH2Yb8ZkBixjo");
request = new HttpPost("https://subgraph.satsuma-prod.com/3213d35a17f1/zhes-team--158805/dloptimismdistribute/api");
break;
// case Constants.CHAIN_ID_SEPOLIA: // sepolia
// request = new HttpPost(
// "https://gateway-arbitrum.network.thegraph.com/api/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/9p6zFejTBC2bLLJRCdrk1A2PXfZkriRMacM5wiCAyh5Z");
// break;
// case Constants.CHAIN_ID_SCROLL: // scroll
// request = new HttpPost("https://gateway-arbitrum.network.thegraph.com/api/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/8HhHjdsXrZ1cjq5qNpksoWfAm1NTDDFhH2Yb8ZkBixjo");
// break;
case Constants.CHAIN_ID_ARBITRUM: // arbitrum
request = new HttpPost("https://gateway-arbitrum.network.thegraph.com/api/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/BbFUyrr7KeB9VjxrSqWFDWAcsyDsGdbinrteLrPK5MVb");
break;
case Constants.CHAIN_ID_ZKSYNC: // zksync
request = new HttpPost("https://gateway-arbitrum.network.thegraph.com/api/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/DzTmBT2V5kFQL6LpjC3iubYkusfj4HLVScCrAcT2DKGK");
break;
case Constants.CHAIN_ID_POLYGON_ZKEVM: // polygon zkevm
request = new HttpPost("https://gateway-arbitrum.network.thegraph.com/api/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/A46TwCAxDy4upqLuS7bgXd14yLQdTjfS4AVPMNwWkZSR");
break;
case Constants.CHAIN_ID_LINEA: //linea
request = new HttpPost("https://gateway-arbitrum.network.thegraph.com/api/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/DatcM6CoN5u79XPx1wYFFnWXpHYcfDodkbycx2vSp25C");
request = new HttpPost("https://subgraph.satsuma-prod.com/3213d35a17f1/zhes-team--158805/dlarbitrumdistribute/api");
break;
// case Constants.CHAIN_ID_ZKSYNC: // zksync
// request = new HttpPost("https://gateway-arbitrum.network.thegraph.com/api/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/DzTmBT2V5kFQL6LpjC3iubYkusfj4HLVScCrAcT2DKGK");
// break;
// case Constants.CHAIN_ID_POLYGON_ZKEVM: // polygon zkevm
// request = new HttpPost("https://gateway-arbitrum.network.thegraph.com/api/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/A46TwCAxDy4upqLuS7bgXd14yLQdTjfS4AVPMNwWkZSR");
// break;
// case Constants.CHAIN_ID_LINEA: //linea
// request = new HttpPost("https://gateway-arbitrum.network.thegraph.com/api/" + merkleDistributorConfig.getGraphConfig().getKey() +"/subgraphs/id/DatcM6CoN5u79XPx1wYFFnWXpHYcfDodkbycx2vSp25C");
// break;
}

if (request == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void apply(ApplyVo applyVo, String address) {
throw new BizException(APPLY_REPEAT.getCode(), APPLY_REPEAT.getMsg());
});
try {
emailService.sendMail(member.getEmail(), "有新人投递简历", "有新人投递简历:\n简历地址:\n "
emailService.sendMail(createJDMember.getEmail(), "有新人投递简历", "有新人投递简历:\n简历地址:\n "
+ "https://dlh-1257682033.cos.ap-hongkong.myqcloud.com/" + applyVo.getFile());
//添加应聘记录
Application application = new Application();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/dl/officialsite/mail/EmailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void sendMail(String to, String subject, String text) {
message.setTo(to);
message.setSubject(subject);
message.setText(text);
message.setCc("[email protected]");
emailSender.send(message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif
@Query(value = "update member set github_id=NULL, github_status=0, discord_id=NULL, telegram_user_id=NULL where address = :address",
nativeQuery = true)
void removeGitHubTgAndDiscordId(@Param("address") String address);


@Query(value = "select * from member where address in :addressList", nativeQuery = true)
List<Member> findByAddressList(@Param("addressList") List<String> addressList);
}
19 changes: 19 additions & 0 deletions src/main/java/com/dl/officialsite/member/MemberService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dl.officialsite.member;

import cn.hutool.core.collection.CollUtil;
import com.dl.officialsite.common.enums.CodeEnums;
import com.dl.officialsite.common.exception.BizException;
import com.dl.officialsite.common.utils.UserSecurityUtils;
Expand Down Expand Up @@ -124,4 +125,22 @@ public void nickNameExists(String nickName){
throw new RuntimeException("Nickname already exists, please change another one.") ;
}
}

public List<Member> queryMemberInfoByAddress(List<String> addressList){
if(CollUtil.isEmpty(addressList)){
return new ArrayList<>();
}
List<Member> memberList = memberRepository.findByAddressList(addressList);
//只保留id、address、nickName字段
List<Member> result = new ArrayList<>();
for (Member member : memberList) {
Member filteredMember = new Member();
filteredMember.setId(member.getId());
filteredMember.setAddress(member.getAddress());
filteredMember.setNickName(member.getNickName());
result.add(filteredMember);
}
return result;
}

}
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
package com.dl.officialsite.redpacket;

import com.dl.officialsite.common.base.BaseResponse;
import com.dl.officialsite.login.Auth;
import com.dl.officialsite.member.Member;
import com.dl.officialsite.member.MemberController;
import com.dl.officialsite.member.MemberRepository;
import com.dl.officialsite.member.MemberService;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
Expand All @@ -24,11 +17,9 @@
import javax.persistence.criteria.Root;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import static com.dl.officialsite.common.converter.StringListConverter.SPLIT_CHAR;
import static org.hibernate.criterion.Restrictions.in;

@RestController
Expand Down Expand Up @@ -68,13 +59,12 @@ BaseResponse getRedPacketAll(@RequestParam String address,

@RequestMapping(value = "/query/user", method = RequestMethod.GET)
BaseResponse getRedPacketByAddress(@RequestParam String address, @RequestParam(required = false) Integer status,
@RequestParam String chainId) {
@RequestParam(required = false) String chainId) {
List<RedPacket> result;
if (status == 0) {
result = redPacketRepository.findByUnclaimedPacket("%" + address + "%", 0, chainId);
result = redPacketRepository.findByUnclaimedPacketWithoutChainId("%" + address + "%", 0, chainId);
} else {
result = redPacketRepository.findByClaimedPacket("%" + address + "%", chainId);

result = redPacketRepository.findByClaimedPacketWithoutChainId("%" + address + "%", chainId);
}
return BaseResponse.successWithData(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public interface RedPacketRepository extends JpaRepository<RedPacket, String>,
@Query(value = "select * from red_packet where claimed_address like ?1 and chain_id = ?2 order by create_time desc", nativeQuery = true)
List<RedPacket> findByClaimedPacket(@Param("address") String address, @Param("chainId") String chainId);

@Query(value = "select * from red_packet where claimed_address like ?1 and if(isnull(?2), 1=1, chain_id = ?2) order by create_time desc", nativeQuery = true)
List<RedPacket> findByClaimedPacketWithoutChainId(@Param("address") String address, @Param("chainId") String chainId);


@Query(value = "select * from red_packet where address_list like ?1 and claimed_address not like ?1 and status = 2 and chain_id = ?2 order by create_time desc", nativeQuery = true)
List<RedPacket> findByUnclaimedTimeOutPacket(@Param("address") String address, @Param("chainId") String chainId );
Expand All @@ -28,6 +31,9 @@ public interface RedPacketRepository extends JpaRepository<RedPacket, String>,
@Query(value = "select * from red_packet where address_list like ?1 and claimed_address not like ?1 and status = ?2 and chain_id = ?3 order by create_time desc", nativeQuery = true)
List<RedPacket> findByUnclaimedPacket(@Param("address") String address, @Param("status") Integer status, @Param("chainId") String chainId);

@Query(value = "select * from red_packet where address_list like ?1 and claimed_address not like ?1 and status = ?2 and if(isnull(?3), 1=1, chain_id = ?3) order by create_time desc", nativeQuery = true)
List<RedPacket> findByUnclaimedPacketWithoutChainId(@Param("address") String address, @Param("status") Integer status, @Param("chainId") String chainId);


RedPacket findByIdAndStatus(@Param("id") String id, @Param("status") Integer status);

Expand Down
45 changes: 22 additions & 23 deletions src/main/java/com/dl/officialsite/redpacket/RedPacketService.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,33 +149,32 @@ private HttpEntity getHttpEntityFromChain(String chainId) throws IOException {
switch (chainId) {
case Constants.CHAIN_ID_OP: // op
request = new HttpPost(
"https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +
"/subgraphs/id/G7LuMuUuWUW8UknEx8x2aVSeFtqpNMEKHvka2aKiDzRm");
break;
case Constants.CHAIN_ID_SEPOLIA: //sepolia
request = new HttpPost(
"https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +"/subgraphs/id/84hUXdB1qCmn8Du8bDmpLxxFSHjsgFCUKcrbtM4j5tp6");
break;
case Constants.CHAIN_ID_SCROLL: //scrool
request = new HttpPost(
"https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +"/subgraphs/id/6Ln5DVxZuYiY4VZzDQ2hzweBMRBpwW1SKRjeUy2YouRC");
"https://subgraph.satsuma-prod.com/f440a1fb5a7f/caodalong--672935/dloptimismredpacket/api");
break;
// case Constants.CHAIN_ID_SEPOLIA: //sepolia
// request = new HttpPost(
// "https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +"/subgraphs/id/84hUXdB1qCmn8Du8bDmpLxxFSHjsgFCUKcrbtM4j5tp6");
// break;
// case Constants.CHAIN_ID_SCROLL: //scrool
// request = new HttpPost(
// "https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +"/subgraphs/id/6Ln5DVxZuYiY4VZzDQ2hzweBMRBpwW1SKRjeUy2YouRC");
// break;
case Constants.CHAIN_ID_ARBITRUM: //arbitrum
request = new HttpPost(
"https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +"/subgraphs/id/9S1hiM5vzZ3m7o9SBpywHHcC8VZBSRUZTv3R8Npt56gS");
break;
case Constants.CHAIN_ID_ZKSYNC: //zksync
request = new HttpPost(
"https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +"/subgraphs/id/ERTqnTVeQKH8CVYwfGnqqZjtNDzgdnJRYQCgD4TY1gUX");
break;
case Constants.CHAIN_ID_POLYGON_ZKEVM: //polygon zkevm
request = new HttpPost(
"https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +"/subgraphs/id/5DsufFHE6P7tK7QT1mGCPrQEKURD2E1SSHAyCSzf5CAg");
break;
case Constants.CHAIN_ID_LINEA: //linea
request = new HttpPost(
"https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +"/subgraphs/id/958YHrTJturbhR6uwRyPu1wmBNiXivNkLMPY7tUiL4wD");
"https://subgraph.satsuma-prod.com/f440a1fb5a7f/caodalong--672935/dlarbitrumredpacket/api");
break;
// case Constants.CHAIN_ID_ZKSYNC: //zksync
// request = new HttpPost(
// "https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +"/subgraphs/id/ERTqnTVeQKH8CVYwfGnqqZjtNDzgdnJRYQCgD4TY1gUX");
// break;
// case Constants.CHAIN_ID_POLYGON_ZKEVM: //polygon zkevm
// request = new HttpPost(
// "https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +"/subgraphs/id/5DsufFHE6P7tK7QT1mGCPrQEKURD2E1SSHAyCSzf5CAg");
// break;
// case Constants.CHAIN_ID_LINEA: //linea
// request = new HttpPost(
// "https://gateway-arbitrum.network.thegraph.com/api/" + redPacketConfig.getGraphConfig().getKey() +"/subgraphs/id/958YHrTJturbhR6uwRyPu1wmBNiXivNkLMPY7tUiL4wD");
// break;

}
request.setHeader("Content-Type", "application/json");
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/dl/officialsite/team/TeamController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.dl.officialsite.login.Auth;
import com.dl.officialsite.member.Member;
import com.dl.officialsite.member.MemberService;
import com.dl.officialsite.team.vo.TeamMemberAddQueryVO;
import com.dl.officialsite.team.vo.TeamMemberApproveVO;
import com.dl.officialsite.team.vo.TeamMemberBatchJoinVO;
import com.dl.officialsite.team.vo.TeamMemberJoinVO;
Expand Down Expand Up @@ -55,6 +56,17 @@ BaseResponse update(@RequestBody Team team, @RequestParam String address) {
return BaseResponse.successWithData(null);
}

/**
* 通过地址信息查询member信息
* @param teamMemberAddQueryVO
* @return
*/
@PostMapping("queryMemberInfoByAddress")
BaseResponse<List<Member>> queryMemberInfoByAddress(@RequestBody TeamMemberAddQueryVO teamMemberAddQueryVO) {
List<Member> members = memberService.queryMemberInfoByAddress(teamMemberAddQueryVO.getAddressList());
return BaseResponse.successWithData(members);
}

/**
* 加入团队
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.dl.officialsite.team.vo;

import lombok.Data;

import java.util.List;

/**
* @Description
* @Author xiaoming
* @Date 2024/7/6 8:59 PM
**/
@Data
public class TeamMemberAddQueryVO {

/**
* 地址列表
*/
private List<String> addressList;
}

0 comments on commit 913bb60

Please sign in to comment.