Skip to content

Commit

Permalink
Merge pull request #79 from Hanaro-trip-together-bank/feature/team
Browse files Browse the repository at this point in the history
fix: 내 모임 조회에 team_member_idx추가
  • Loading branch information
mummhy0811 authored May 31, 2024
2 parents 6298eb3 + c0008de commit c91a367
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public class TeamServiceListResDto {
private BigDecimal accBalance;
private String teamName;
private Long teamIdx;
private Long teamMemberIdx;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.hanaro.triptogether.member.domain.MemberRepository;
import com.hanaro.triptogether.team.domain.Team;
import com.hanaro.triptogether.team.domain.TeamRepository;
import com.hanaro.triptogether.teamMember.domain.TeamMemberRepository;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -26,6 +27,7 @@ public class AccountServiceImpl implements AccountService {
private final AccountRepository accountRepository;
private final MemberRepository memberRepository;
private final TeamRepository teamRepository;
private final TeamMemberRepository teamMemberRepository;

// 모임서비스 전체 조회
@Transactional
Expand All @@ -36,12 +38,14 @@ public List<TeamServiceListResDto> teamServiceList(Long memberIdx) {
List<Team> teams = teamRepository.findTeamsByMemberIdx(memberIdx);

for(int i = 0; i < teams.size(); i++) {
Long teamMemberIdx = teamMemberRepository.findTeamMemberByMember_MemberIdxAndTeam_TeamIdx(memberIdx, teams.get(i).getTeamIdx()).get().getTeamMemberIdx();
TeamServiceListResDto teamServiceListResDto = TeamServiceListResDto.builder()
.accIdx(teams.get(i).getAccount().getAccIdx())
.accNumber(teams.get(i).getAccount().getAccNumber())
.accBalance(teams.get(i).getAccount().getAccBalance())
.teamName(teams.get(i).getTeamName())
.teamIdx(teams.get(i).getTeamIdx())
.teamMemberIdx(teamMemberIdx)
.build();

teamServiceListResDtos.add(teamServiceListResDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Optional;

public interface TeamMemberRepository extends JpaRepository<TeamMember,Long> {

Expand All @@ -15,4 +16,6 @@ public interface TeamMemberRepository extends JpaRepository<TeamMember,Long> {
List<TeamMember> findTeamMembersByTeam(Team team);

List<TeamMember> findTeamMemberByMember_MemberIdx(Long memberIdx);

Optional<TeamMember> findTeamMemberByMember_MemberIdxAndTeam_TeamIdx(Long memberIdx, Long teamIdx);
}

0 comments on commit c91a367

Please sign in to comment.