Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
liberhe committed Nov 10, 2023
2 parents 873bc39 + 9c8fce9 commit 35b281c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 31 deletions.
68 changes: 47 additions & 21 deletions src/main/java/com/dl/officialsite/team/TeamService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.transaction.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
Expand All @@ -32,6 +33,7 @@
* @Date 2023/10/21 17:23
* @Description TODO
**/
@Slf4j
@Service
public class TeamService {

Expand Down Expand Up @@ -89,6 +91,7 @@ public javax.persistence.criteria.Predicate toPredicate(
return teamsMembersVos;
}

@Transactional(rollbackOn = Exception.class)
public void join(TeamMemberJoinVO teamMember) {
Member member = memberRepository.findById(teamMember.getMemberId()).get();
/* if (ObjectUtils.isEmpty(member.getTelegramId()) || ObjectUtils.isEmpty(
Expand All @@ -104,11 +107,55 @@ 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);
log.info("发送邮件给管理员:{},接收地址{}", email, mailAddress);
emailService.memberJoinTeam(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);
teamMember1.setStatus(Constants.REQUEST_TEAM);
teamMemberRepository.save(teamMember1);
//发送邮件
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);
log.info("发送邮件给管理员:{},接收地址{}", email, mailAddress);
emailService.memberJoinTeam(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 All @@ -127,27 +174,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
2 changes: 0 additions & 2 deletions src/main/resources/application-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ spring:
auth: true
ssl:
enable: true
starttls:
enable: true
session:
store-type: jdbc
jdbc:
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ spring:
auth: true
ssl:
enable: true
starttls:
enable: true
session:
store-type: jdbc
jdbc:
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 35b281c

Please sign in to comment.