Skip to content

Commit

Permalink
Merge pull request #57 from cheng521521/main
Browse files Browse the repository at this point in the history
fix: member join feature
  • Loading branch information
yanyanho authored Nov 9, 2023
2 parents b040768 + 72b83d0 commit beca9ee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
42 changes: 21 additions & 21 deletions src/main/java/com/dl/officialsite/team/TeamService.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,27 @@ public void join(TeamMemberJoinVO teamMember) {
TeamMember teamMember2 = optional.get();
teamMember2.setStatus(Constants.REQUEST_TEAM);
teamMemberRepository.save(teamMember2);
//发送邮件
Team team = teamRepository.findById(teamMember.getTeamId()).get();
String administratorAddress = team.getAdministrator();
if (!ObjectUtils.isEmpty(administratorAddress) || !"".equals(administratorAddress)) {
Optional<Member> admin = memberRepository.findByAddress(administratorAddress);
if (admin.isPresent()) {
Member member1 = admin.get();
String email = member1.getEmail();
String subject = team.getTeamName() + "团队新成员加入申请";
List<String> mailAddress = new ArrayList<>();
mailAddress.add(email);
emailService.memberExitTeam(mailAddress, subject, subject);
} else {
throw new BizException(CodeEnums.TEAM_ADMIN_NOT_EXIST.getCode(),
CodeEnums.TEAM_ADMIN_NOT_EXIST.getMsg());
}

} else {
throw new BizException(CodeEnums.TEAM_ADMIN_NOT_EXIST.getCode(),
CodeEnums.TEAM_ADMIN_NOT_EXIST.getMsg());
}
} else {
TeamMember teamMember1 = new TeamMember();
BeanUtils.copyProperties(teamMember, teamMember1);
Expand All @@ -127,27 +148,6 @@ public void approve(TeamMemberApproveVO teamMemberApproveVO) {
}
});
teamMemberRepository.saveAll(teamMembers);
//发送邮件
Team team = teamRepository.findById(teamMemberApproveVO.getTeamId()).get();
String administratorAddress = team.getAdministrator();
if (!ObjectUtils.isEmpty(administratorAddress) || !"".equals(administratorAddress)) {
Optional<Member> admin = memberRepository.findByAddress(administratorAddress);
if (admin.isPresent()) {
Member member = admin.get();
String email = member.getEmail();
String subject = team.getTeamName() + "团队新成员加入申请";
List<String> mailAddress = new ArrayList<>();
mailAddress.add(email);
emailService.memberExitTeam(mailAddress, subject, subject);
} else {
throw new BizException(CodeEnums.TEAM_ADMIN_NOT_EXIST.getCode(),
CodeEnums.TEAM_ADMIN_NOT_EXIST.getMsg());
}

} else {
throw new BizException(CodeEnums.TEAM_ADMIN_NOT_EXIST.getCode(),
CodeEnums.TEAM_ADMIN_NOT_EXIST.getMsg());
}
}


Expand Down
11 changes: 5 additions & 6 deletions src/test/java/com/dl/officialsite/UtilTests.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
package com.dl.officialsite;

import static org.web3j.crypto.Sign.getEthereumMessageHash;
import static org.web3j.utils.Numeric.hexStringToByteArray;

import com.dl.officialsite.common.base.BaseResponse;
import com.dl.officialsite.member.MemberController;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.math.BigInteger;
import java.security.SignatureException;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.web3j.crypto.Keys;
import org.web3j.crypto.Sign;

import java.math.BigInteger;
import java.security.SignatureException;

import static org.web3j.crypto.Sign.getEthereumMessageHash;
import static org.web3j.utils.Numeric.hexStringToByteArray;


class UtilTests {
public static final Logger logger = LoggerFactory.getLogger(MemberController.class);
Expand Down

0 comments on commit beca9ee

Please sign in to comment.