Skip to content

Commit

Permalink
Merge pull request #264 from facming/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
yanyanho authored Jul 10, 2024
2 parents e7b7cef + 5459f72 commit 90b6089
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 13 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
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 @@ -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
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 90b6089

Please sign in to comment.