From ca1ccd16ea229fd5f77ba76d05dad1fc50351150 Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Wed, 1 Nov 2023 19:27:59 +0800 Subject: [PATCH 1/4] fix:add function get team detail --- .../dl/officialsite/team/TeamController.java | 4 ++-- .../com/dl/officialsite/team/TeamService.java | 18 ++++++++++++++---- .../com/dl/officialsite/team/vo/TeamVO.java | 2 ++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/dl/officialsite/team/TeamController.java b/src/main/java/com/dl/officialsite/team/TeamController.java index e0b0b374..4d22a9b1 100644 --- a/src/main/java/com/dl/officialsite/team/TeamController.java +++ b/src/main/java/com/dl/officialsite/team/TeamController.java @@ -79,8 +79,8 @@ BaseResponse getTeams(@RequestBody TeamQueryVo teamQueryVo, @RequestParam String @GetMapping("/id") BaseResponse getTeamById(@RequestParam Long teamId, @RequestParam String address) { - Team team = teamService.getTeamById(teamId); - return BaseResponse.successWithData(team); + TeamsMembersVo teamAndMembers = teamService.getTeamById(teamId); + return BaseResponse.successWithData(teamAndMembers); } /** diff --git a/src/main/java/com/dl/officialsite/team/TeamService.java b/src/main/java/com/dl/officialsite/team/TeamService.java index fea74fc8..60289fa4 100644 --- a/src/main/java/com/dl/officialsite/team/TeamService.java +++ b/src/main/java/com/dl/officialsite/team/TeamService.java @@ -90,11 +90,11 @@ public javax.persistence.criteria.Predicate toPredicate( public void join(TeamMemberJoinVO teamMember) { Member member = memberRepository.findById(teamMember.getMemberId()).get(); - if (ObjectUtils.isEmpty(member.getTelegramId()) || ObjectUtils.isEmpty( +/* if (ObjectUtils.isEmpty(member.getTelegramId()) || ObjectUtils.isEmpty( member.getWechatId())) { throw new BizException(CodeEnums.TELEGRAM_WECHAT_NOT_BIND.getCode(), CodeEnums.TELEGRAM_WECHAT_NOT_BIND.getMsg()); - } + }*/ //判断是否已经退出过团队 Optional optional = teamMemberRepository.findByTeamAndMember( teamMember.getTeamId() @@ -180,10 +180,20 @@ public List getMemberRole(Long memberId) { } } - public Team getTeamById(Long teamId) { + public TeamsMembersVo getTeamById(Long teamId) { Optional optional = teamRepository.findById(teamId); if (optional.isPresent()) { - return optional.get(); + TeamsMembersVo teamsMembersVo = new TeamsMembersVo(); + Team team = optional.get(); + List members = new ArrayList<>(); + List memberIds = teamMemberRepository.findByTeamId(team.getId()); + memberIds.stream().forEach(memberId -> { + Member member = memberRepository.findById(memberId).get(); + members.add(member); + }); + teamsMembersVo.setMembers(members); + BeanUtils.copyProperties(team, teamsMembersVo); + return teamsMembersVo; } else { throw new BizException(CodeEnums.TEAM_NOT_EXIST.getCode(), CodeEnums.TEAM_NOT_EXIST.getMsg()); diff --git a/src/main/java/com/dl/officialsite/team/vo/TeamVO.java b/src/main/java/com/dl/officialsite/team/vo/TeamVO.java index 99ef74ad..11dff687 100644 --- a/src/main/java/com/dl/officialsite/team/vo/TeamVO.java +++ b/src/main/java/com/dl/officialsite/team/vo/TeamVO.java @@ -12,6 +12,8 @@ @Data public class TeamVO { + private Long id; + private String teamName; private String teamProfile; From 263ff5677408b948e7b0ce06a209a5b92510fdae Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Wed, 1 Nov 2023 19:57:46 +0800 Subject: [PATCH 2/4] fix:add function get memeber progress --- src/main/java/com/dl/officialsite/team/TeamService.java | 1 + src/main/java/com/dl/officialsite/team/vo/TeamVO.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/main/java/com/dl/officialsite/team/TeamService.java b/src/main/java/com/dl/officialsite/team/TeamService.java index 60289fa4..05c28e7e 100644 --- a/src/main/java/com/dl/officialsite/team/TeamService.java +++ b/src/main/java/com/dl/officialsite/team/TeamService.java @@ -174,6 +174,7 @@ public List getMemberRole(Long memberId) { Team team = teamRepository.findById(teamMember.getTeamId()).get(); TeamVO teamVO = new TeamVO(); BeanUtils.copyProperties(team, teamVO); + teamVO.setStatus(teamMember.getStatus()); teamVOS.add(teamVO); }); return teamVOS; diff --git a/src/main/java/com/dl/officialsite/team/vo/TeamVO.java b/src/main/java/com/dl/officialsite/team/vo/TeamVO.java index 11dff687..96bf851a 100644 --- a/src/main/java/com/dl/officialsite/team/vo/TeamVO.java +++ b/src/main/java/com/dl/officialsite/team/vo/TeamVO.java @@ -24,5 +24,7 @@ public class TeamVO { // dao admin , core contributor, builder private String authority; + private int status; + private List members; } From 0352aa18e21c215f3d0da95d6fde211031109419 Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Wed, 1 Nov 2023 20:38:54 +0800 Subject: [PATCH 3/4] fix:add function get all team status --- .../java/com/dl/officialsite/team/TeamMemberRepository.java | 5 +++++ src/main/java/com/dl/officialsite/team/TeamService.java | 2 +- src/main/java/com/dl/officialsite/team/vo/TeamQueryVo.java | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/dl/officialsite/team/TeamMemberRepository.java b/src/main/java/com/dl/officialsite/team/TeamMemberRepository.java index 3fa2db6e..09c8f851 100644 --- a/src/main/java/com/dl/officialsite/team/TeamMemberRepository.java +++ b/src/main/java/com/dl/officialsite/team/TeamMemberRepository.java @@ -17,6 +17,11 @@ public interface TeamMemberRepository extends JpaRepository { @Query(value = "select member_id from team_member where team_id = :team_id", nativeQuery = true) List findByTeamId(@Param("team_id")Long teamId); + @Query(value = "select member_id from team_member where team_id = :team_id and status = :status", + nativeQuery = + true) + List findByTeamIdStatus(@Param("team_id")Long teamId, @Param("status")int status); + @Query(value = "select * from team_member where team_id = :team_id and member_id = :member_id", nativeQuery = true) Optional findByTeamAndMember(@Param("team_id")Long teamId, @Param("member_id")Long memberId); diff --git a/src/main/java/com/dl/officialsite/team/TeamService.java b/src/main/java/com/dl/officialsite/team/TeamService.java index 05c28e7e..3f18a75d 100644 --- a/src/main/java/com/dl/officialsite/team/TeamService.java +++ b/src/main/java/com/dl/officialsite/team/TeamService.java @@ -77,7 +77,7 @@ public javax.persistence.criteria.Predicate toPredicate( TeamsMembersVo teamsMembersVo = new TeamsMembersVo(); BeanUtils.copyProperties(team, teamsMembersVo); List members = new ArrayList<>(); - List memberIds = teamMemberRepository.findByTeamId(team.getId()); + List memberIds = teamMemberRepository.findByTeamIdStatus(team.getId(), teamQueryVo.getStatus()); memberIds.stream().forEach(memberId -> { Member member = memberRepository.findById(memberId).get(); members.add(member); diff --git a/src/main/java/com/dl/officialsite/team/vo/TeamQueryVo.java b/src/main/java/com/dl/officialsite/team/vo/TeamQueryVo.java index dd65d025..52d86065 100644 --- a/src/main/java/com/dl/officialsite/team/vo/TeamQueryVo.java +++ b/src/main/java/com/dl/officialsite/team/vo/TeamQueryVo.java @@ -12,4 +12,6 @@ public class TeamQueryVo { private String teamName; + + private int status; } From 37a7185e7dd040fa37b316dc0708ba95ef42c801 Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Thu, 2 Nov 2023 19:01:21 +0800 Subject: [PATCH 4/4] fix: approve bug --- .../officialsite/common/enums/CodeEnums.java | 3 ++- .../com/dl/officialsite/team/TeamService.java | 26 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java b/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java index 03f93be2..3910325d 100644 --- a/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java +++ b/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java @@ -17,7 +17,8 @@ public enum CodeEnums { MEMBER_NOT_IN_TEAM("1004", "member not in team"), TEAM_NOT_EXIST("1005", "team not exist"), - LOGIN_IN("2001", "please login"); + LOGIN_IN("2001", "please login"), + TEAM_ADMIN_NOT_EXIST("1006", "team admin not exist"); private String code; diff --git a/src/main/java/com/dl/officialsite/team/TeamService.java b/src/main/java/com/dl/officialsite/team/TeamService.java index 3f18a75d..0df9452d 100644 --- a/src/main/java/com/dl/officialsite/team/TeamService.java +++ b/src/main/java/com/dl/officialsite/team/TeamService.java @@ -1,5 +1,7 @@ package com.dl.officialsite.team; +import static org.bouncycastle.asn1.x500.style.RFC4519Style.member; + import com.dl.officialsite.common.constants.Constants; import com.dl.officialsite.common.enums.CodeEnums; import com.dl.officialsite.common.exception.BizException; @@ -112,6 +114,7 @@ public void join(TeamMemberJoinVO teamMember) { } + @Transactional(rollbackOn = Exception.class) public void approve(TeamMemberApproveVO teamMemberApproveVO) { List memberIds = teamMemberApproveVO.getMemberIds(); List teamMembers = new ArrayList<>(); @@ -127,11 +130,24 @@ public void approve(TeamMemberApproveVO teamMemberApproveVO) { teamMemberRepository.saveAll(teamMembers); //发送邮件 Team team = teamRepository.findById(teamMemberApproveVO.getTeamId()).get(); - String subject = team.getTeamName() + "团队新成员加入申请"; - List mailAddress = new ArrayList<>(); - //todo 这里需要确认有那些管理员 - if (mailAddress.size() != 0) { - emailService.memberExitTeam(mailAddress, subject, subject); + String administratorAddress = team.getAdministrator(); + if (!ObjectUtils.isEmpty(administratorAddress) || !"".equals(administratorAddress)) { + Optional admin = memberRepository.findByAddress(administratorAddress); + if (admin.isPresent()) { + Member member = admin.get(); + String email = member.getEmail(); + String subject = team.getTeamName() + "团队新成员加入申请"; + List 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()); } }