Skip to content

Commit

Permalink
feat:1. add send mail for apply bounty
Browse files Browse the repository at this point in the history
     2. cc mail to dapp official mail
     3. fix hiring bug when send mail
  • Loading branch information
cheng521521 committed Jul 20, 2024
1 parent 9a3ce7d commit bfd7942
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
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 @@ -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

0 comments on commit bfd7942

Please sign in to comment.