From c374562f65b828b9b880fb2d11a551550e3e8e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A1=E1=86=AB=E1=84=82=E1=85=A1=E1=84=8B?= =?UTF-8?q?=E1=85=A7=E1=86=BC?= Date: Sat, 6 Jul 2024 15:41:34 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EC=8B=A4=EB=AA=85=20->=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84=20=EB=B3=80=EA=B2=BD=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hana/hanalink/team/dto/response/DetailTeamRes.java | 4 +++- .../com/hana/hanalink/team/service/TeamService.java | 2 +- .../hana/hanalink/teammember/domain/TeamMember.java | 2 +- .../hana/hanalink/teammember/dto/TeamMemberRes.java | 2 +- .../hanalink/teammember/service/TeamMemberService.java | 2 +- .../transaction/controller/TransactionController.java | 4 ++-- .../hana/hanalink/transaction/domain/Transaction.java | 1 + .../transaction/dto/request/TransactionReq.java | 2 +- .../transaction/dto/response/TransactionRes.java | 2 ++ .../transaction/service/TransactionService.java | 10 ++++++---- 10 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/hana/hanalink/team/dto/response/DetailTeamRes.java b/src/main/java/com/hana/hanalink/team/dto/response/DetailTeamRes.java index 538434f..3616885 100644 --- a/src/main/java/com/hana/hanalink/team/dto/response/DetailTeamRes.java +++ b/src/main/java/com/hana/hanalink/team/dto/response/DetailTeamRes.java @@ -12,9 +12,10 @@ public record DetailTeamRes( Float score, String thumbNail, String banner, + String nickName, TeamMemberRole role ) { - public DetailTeamRes(Team team, TeamMemberRole role) { + public DetailTeamRes(Team team, TeamMemberRole role,String nickName) { this( team.getTeamId(), team.getSiGunGu().getSiGunGu(), @@ -24,6 +25,7 @@ public DetailTeamRes(Team team, TeamMemberRole role) { team.getScore(), team.getThumbNail(), team.getBanner(), + nickName, role ); } diff --git a/src/main/java/com/hana/hanalink/team/service/TeamService.java b/src/main/java/com/hana/hanalink/team/service/TeamService.java index 57b7ca7..4044841 100644 --- a/src/main/java/com/hana/hanalink/team/service/TeamService.java +++ b/src/main/java/com/hana/hanalink/team/service/TeamService.java @@ -145,7 +145,7 @@ public DetailTeamRes getDetailTeam(String phone, Long teamId) { Optional teamMemberOptional = teamMemberRepository.findByMemberAndTeam(member, team); TeamMemberRole role = teamMemberOptional.map(TeamMember::getRole).orElse(null); - return new DetailTeamRes(team, role); + return new DetailTeamRes(team, role, teamMemberOptional.get().getNickname()); } diff --git a/src/main/java/com/hana/hanalink/teammember/domain/TeamMember.java b/src/main/java/com/hana/hanalink/teammember/domain/TeamMember.java index 47a13ed..526dea7 100644 --- a/src/main/java/com/hana/hanalink/teammember/domain/TeamMember.java +++ b/src/main/java/com/hana/hanalink/teammember/domain/TeamMember.java @@ -39,7 +39,7 @@ public class TeamMember extends BaseEntity { public TeamMemberRes toDto(String gender,String profile,String name){ return TeamMemberRes.builder() .teamMemberId(teamMemberId) - .name(name) + .nickName(name) .gender(gender) .profile(profile) .role(role) diff --git a/src/main/java/com/hana/hanalink/teammember/dto/TeamMemberRes.java b/src/main/java/com/hana/hanalink/teammember/dto/TeamMemberRes.java index 9ae6d7f..80b96f7 100644 --- a/src/main/java/com/hana/hanalink/teammember/dto/TeamMemberRes.java +++ b/src/main/java/com/hana/hanalink/teammember/dto/TeamMemberRes.java @@ -4,5 +4,5 @@ import lombok.Builder; @Builder -public record TeamMemberRes(Long teamMemberId,String profile, String name, String gender, TeamMemberRole role) { +public record TeamMemberRes(Long teamMemberId,String profile, String nickName, String gender, TeamMemberRole role) { } diff --git a/src/main/java/com/hana/hanalink/teammember/service/TeamMemberService.java b/src/main/java/com/hana/hanalink/teammember/service/TeamMemberService.java index 91e0da7..5e8627e 100644 --- a/src/main/java/com/hana/hanalink/teammember/service/TeamMemberService.java +++ b/src/main/java/com/hana/hanalink/teammember/service/TeamMemberService.java @@ -27,7 +27,7 @@ public class TeamMemberService { @Transactional(readOnly = true) public List getTeamMembers(Long teamId) { - return teamMemberRepository.findTeamMemberByTeam_TeamId(teamId).stream().map(teamMember -> teamMember.toDto(teamMember.getMember().getGender(),teamMember.getMember().getProfile(),teamMember.getMember().getName()) + return teamMemberRepository.findTeamMemberByTeam_TeamId(teamId).stream().map(teamMember -> teamMember.toDto(teamMember.getMember().getGender(),teamMember.getMember().getProfile(),teamMember.getNickname()) ).toList(); } diff --git a/src/main/java/com/hana/hanalink/transaction/controller/TransactionController.java b/src/main/java/com/hana/hanalink/transaction/controller/TransactionController.java index a9f25f9..917de19 100644 --- a/src/main/java/com/hana/hanalink/transaction/controller/TransactionController.java +++ b/src/main/java/com/hana/hanalink/transaction/controller/TransactionController.java @@ -28,8 +28,8 @@ public SuccessResponse getTransactionHistory(@PathVariable /*회비 납부하기*/ @PostMapping("/transaction/{teamId}") - public SuccessResponse createTransaction(@PathVariable("teamId") Long teamId, @RequestBody TransactionReq transactionReq,@AuthenticationPrincipal MemberDetails member){ - return SuccessResponse.success(transactionService.paymentDues(teamId,transactionReq,member)); + public SuccessResponse createTransaction(@PathVariable("teamId") Long teamId, @RequestBody TransactionReq transactionReq){ + return SuccessResponse.success(transactionService.paymentDues(teamId,transactionReq)); } diff --git a/src/main/java/com/hana/hanalink/transaction/domain/Transaction.java b/src/main/java/com/hana/hanalink/transaction/domain/Transaction.java index 12318e4..f4007bd 100644 --- a/src/main/java/com/hana/hanalink/transaction/domain/Transaction.java +++ b/src/main/java/com/hana/hanalink/transaction/domain/Transaction.java @@ -48,6 +48,7 @@ public TransactionRes toTransMember(Member member) { return TransactionRes.builder() .memberGender(member.getGender()) .memberName(member.getName()) + .memberNickname(transFrom) .memberGender(member.getGender()) .amount(amount) .memberProfile(member.getProfile()) diff --git a/src/main/java/com/hana/hanalink/transaction/dto/request/TransactionReq.java b/src/main/java/com/hana/hanalink/transaction/dto/request/TransactionReq.java index c1589bb..45b93d1 100644 --- a/src/main/java/com/hana/hanalink/transaction/dto/request/TransactionReq.java +++ b/src/main/java/com/hana/hanalink/transaction/dto/request/TransactionReq.java @@ -1,4 +1,4 @@ package com.hana.hanalink.transaction.dto.request; -public record TransactionReq(Long amount, Long accountId) { +public record TransactionReq(Long amount, Long accountId, String nickName) { } diff --git a/src/main/java/com/hana/hanalink/transaction/dto/response/TransactionRes.java b/src/main/java/com/hana/hanalink/transaction/dto/response/TransactionRes.java index 364c1af..a8056eb 100644 --- a/src/main/java/com/hana/hanalink/transaction/dto/response/TransactionRes.java +++ b/src/main/java/com/hana/hanalink/transaction/dto/response/TransactionRes.java @@ -9,6 +9,8 @@ public record TransactionRes( String memberProfile, String memberName, + + String memberNickname, String memberGender, Long amount, TransactionType type, diff --git a/src/main/java/com/hana/hanalink/transaction/service/TransactionService.java b/src/main/java/com/hana/hanalink/transaction/service/TransactionService.java index 379d619..9aa4f02 100644 --- a/src/main/java/com/hana/hanalink/transaction/service/TransactionService.java +++ b/src/main/java/com/hana/hanalink/transaction/service/TransactionService.java @@ -4,15 +4,16 @@ import com.hana.hanalink.account.repository.AccountRepository; import com.hana.hanalink.accountto.domain.AccountTo; import com.hana.hanalink.accountto.repository.AccountToRepository; -import com.hana.hanalink.common.service.PaymentTestData; import com.hana.hanalink.common.exception.EntityNotFoundException; import com.hana.hanalink.common.firebase.FirebaseFcmService; +import com.hana.hanalink.common.service.PaymentTestData; import com.hana.hanalink.meetingacount.domain.MeetingAccount; import com.hana.hanalink.meetingacount.repository.MeetingAccountRepository; import com.hana.hanalink.member.domain.MemberDetails; import com.hana.hanalink.team.domain.Team; import com.hana.hanalink.team.exception.TeamNotFoundException; import com.hana.hanalink.team.repository.TeamRepository; +import com.hana.hanalink.teammember.repository.TeamMemberRepository; import com.hana.hanalink.transaction.domain.Transaction; import com.hana.hanalink.transaction.domain.TransactionType; import com.hana.hanalink.transaction.dto.request.TransactionReq; @@ -36,6 +37,7 @@ public class TransactionService { private final TransactionRepository transactionRepository; private final MeetingAccountRepository meetingAccountRepository; + private final TeamMemberRepository teamMemberRepository; private final TeamRepository teamRepository; private final AccountRepository accountRepository; private final AccountToRepository accountToRepository; @@ -54,7 +56,7 @@ public TransactionDetailRes getTransHistory(Long teamId, YearMonth date){ List transactions = transactionRepository.findByAccountTo_AccountIdAndYearMonth(accountTo.getAccountToId(),date.getYear(),date.getMonthValue()); List transactionResList = transactions.stream().map(trans -> ( - trans.toTransMember(trans.getAccountTo().getAccount().getMember()))).toList(); + trans.toTransMember(trans.getAccountFrom().getMember()))).toList(); return TransactionDetailRes.builder() .balance(account.getBalance()) //잔액 @@ -93,7 +95,7 @@ public PaymentCardResponse paymentCard(MemberDetails member,Long teamId) { return new PaymentCardResponse(paidStore, paidAmount, LocalDateTime.now()); } - public Long paymentDues(Long teamId, TransactionReq transactionReq, MemberDetails member) { + public Long paymentDues(Long teamId, TransactionReq transactionReq) { Long meetingAccountId = teamRepository.findById(teamId).orElseThrow(EntityNotFoundException::new).getMeetingAccount().getMeetingAccountId(); MeetingAccount meetingAccount = meetingAccountRepository.findById(meetingAccountId).orElseThrow(EntityNotFoundException::new); @@ -109,7 +111,7 @@ public Long paymentDues(Long teamId, TransactionReq transactionReq, MemberDetail Transaction transaction = Transaction.builder() .amount(transactionReq.amount()) - .transFrom(member.getMemberName()) + .transFrom(transactionReq.nickName()) .transTo(team.getTeamName()) .accountFrom(myAccount) .accountTo(chairAccount)