Skip to content

Commit

Permalink
feat:
Browse files Browse the repository at this point in the history
add team ,exit team send message to tel
new bounty send message to tel
new share send message to tel
  • Loading branch information
cheng521521 committed Mar 3, 2024
1 parent 2e962cc commit ffaaac7
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/dl/officialsite/aave/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @ClassName Compent
* @Author jackchen
* @Date 2023/11/5 14:30
* @Description TODO
* @Description Constant
**/
@Component
public class Constant {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
@Slf4j
public class BountyController {

//todo 是否可以批量新增bounty
//todo 是否可以批量申请bounty,一个人最多申请几个?
private final BountyService bountyService;

public BountyController(BountyService bountyService) {
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/com/dl/officialsite/bounty/BountyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
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 com.dl.officialsite.bot.constant.BotEnum;
import com.dl.officialsite.bot.constant.ChannelEnum;
import com.dl.officialsite.bot.event.EventNotify;
import com.dl.officialsite.bounty.vo.ApplyBountyVo;
import com.dl.officialsite.bounty.vo.BountyMemberVo;
import com.dl.officialsite.bounty.vo.BountySearchVo;
Expand All @@ -17,6 +20,7 @@
import java.util.List;
import javax.persistence.criteria.Predicate;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
Expand All @@ -37,11 +41,15 @@ public class BountyService {

private final MemberRepository memberRepository;

private final ApplicationContext applicationContext;

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

public BountyVo add(BountyVo bountyVo, String address) {
Expand All @@ -52,6 +60,9 @@ public BountyVo add(BountyVo bountyVo, String address) {
bountyVo.setId(bounty.getId());
Member creatorInfo = memberRepository.findByAddress(bounty.getCreator()).orElse(null);
bountyVo.setCreator(creatorInfo);
applicationContext.publishEvent(new EventNotify(Member.class, BotEnum.TELEGRAM,
ChannelEnum.GENERAL, "➖➖➖➖➖➖➖➖➖➖➖\n" +
"👏Create New Bounty👏\nCreator: " + creatorInfo.getNickName() + "\n" + "Bounty Name: " + bounty.getTitle() + "\n" + "➖➖➖➖➖➖➖➖➖➖➖"));
return bountyVo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public BaseResponse createMember(@Valid @RequestBody Member member, @RequestPara
}
MemberVo _member = memberService.save(member);

//todo 看这里
applicationContext.publishEvent(new EventNotify(Member.class, BotEnum.TELEGRAM, ChannelEnum.GENERAL,
"Welcome " + member.getNickName() + " join " + "Dapp-Learning, introduce yourself briefly.\n"));
return BaseResponse.successWithData(_member);
Expand Down
29 changes: 27 additions & 2 deletions src/main/java/com/dl/officialsite/sharing/SharingService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.dl.officialsite.sharing;

import cn.hutool.core.lang.Assert;
import com.dl.officialsite.bot.constant.BotEnum;
import com.dl.officialsite.bot.constant.ChannelEnum;
import com.dl.officialsite.bot.event.EventNotify;
import com.dl.officialsite.common.base.PagedList;
import com.dl.officialsite.common.base.Pagination;
import com.dl.officialsite.common.enums.CodeEnums;
Expand All @@ -13,6 +17,7 @@
import com.dl.officialsite.sharing.model.req.UpdateSharingReq;
import com.dl.officialsite.team.TeamService;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -22,6 +27,7 @@
import javax.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
Expand All @@ -48,11 +54,15 @@ public class SharingService {

private final EmailService emailService;

public SharingService(EmailService emailService) {
private final ApplicationContext applicationContext;

public SharingService(EmailService emailService, ApplicationContext applicationContext) {
this.emailService = emailService;
this.applicationContext = applicationContext;
}


@Transactional(rollbackFor = Exception.class)
public Share createSharing(Share share, String address) {
/**
* 登陆用户转member
Expand All @@ -62,7 +72,15 @@ public Share createSharing(Share share, String address) {
// Optional<Member> memberOpt = this.memberRepository.findByAddress(userInfo.getAddress());
// Member member = memberOpt.get();
// if(member.getId() != req.)
return this.sharingRepository.save(share);
share = sharingRepository.save(share);
Member creatorInfo = memberRepository.findByAddress(address).orElse(null);
Assert.isNull(creatorInfo, "not found member by address");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String formatDate = format.format(share.getDate());
applicationContext.publishEvent(new EventNotify(Member.class, BotEnum.TELEGRAM,
ChannelEnum.SHARING, "➖➖➖➖➖➖➖➖➖➖➖\n" +
"👏Create New Share👏\nCreator: " + creatorInfo.getNickName() + "\n" + "Share Name: " + share.getTheme() + "\n" + "Share Date: " + formatDate +"\n➖➖➖➖➖➖➖➖➖➖➖"));
return share;
}


Expand Down Expand Up @@ -93,6 +111,13 @@ public void updateSharing(UpdateSharingReq req, String address) {
sharing.setLabel(req.getLabel());

this.sharingRepository.save(sharing);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String formatDate = format.format(req.getDate());
applicationContext.publishEvent(new EventNotify(Member.class, BotEnum.TELEGRAM,
ChannelEnum.SHARING, "➖➖➖➖➖➖➖➖➖➖➖\n" +
"‼️‼️Edit Share Info‼️‼️\nCreator: " + member.getNickName() + "\n" + "Share "
+ "Name: " + req.getTheme() + "\n" + "Share Date: " + formatDate +"\n"
+ "➖➖➖➖➖➖➖➖➖➖➖"));
} else {
throw new BizException(CodeEnums.SHARING_NOT_OWNER_OR_ADMIN);
}
Expand Down
Loading

0 comments on commit ffaaac7

Please sign in to comment.