From 19c00173068908520da90791209112aeb03c8a2d Mon Sep 17 00:00:00 2001 From: yubin-im Date: Tue, 11 Jun 2024 16:18:33 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=AA=A8=EC=9E=84=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EA=B0=80=EC=9E=85=20=ED=9B=84=20=EB=B0=94=EB=A1=9C?= =?UTF-8?q?=20=EC=B4=88=EB=8C=80=EB=A7=81=ED=81=AC=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../triptogether/team/controller/TeamController.java | 7 +++---- .../triptogether/team/dto/response/AddTeamResDto.java | 10 ++++++++++ .../hanaro/triptogether/team/service/TeamService.java | 3 ++- .../team/service/impl/TeamServiceImpl.java | 11 +++++++++-- 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/hanaro/triptogether/team/dto/response/AddTeamResDto.java diff --git a/src/main/java/com/hanaro/triptogether/team/controller/TeamController.java b/src/main/java/com/hanaro/triptogether/team/controller/TeamController.java index d73599a..9e4785f 100644 --- a/src/main/java/com/hanaro/triptogether/team/controller/TeamController.java +++ b/src/main/java/com/hanaro/triptogether/team/controller/TeamController.java @@ -1,6 +1,7 @@ package com.hanaro.triptogether.team.controller; import com.hanaro.triptogether.team.dto.request.*; +import com.hanaro.triptogether.team.dto.response.AddTeamResDto; import com.hanaro.triptogether.team.dto.response.DetailTeamResDto; import com.hanaro.triptogether.team.dto.response.InviteTeamResDto; import com.hanaro.triptogether.team.dto.response.ManageTeamResDto; @@ -8,8 +9,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; -import java.util.Map; - @RestController @RequiredArgsConstructor public class TeamController { @@ -17,8 +16,8 @@ public class TeamController { // 모임서비스 가입 @PostMapping("/account/add") - public void addTeam(@RequestBody AddTeamReqDto addTeamReqDto) { - teamService.addTeam(addTeamReqDto); + public AddTeamResDto addTeam(@RequestBody AddTeamReqDto addTeamReqDto) { + return teamService.addTeam(addTeamReqDto); } // 모임서비스 상세 diff --git a/src/main/java/com/hanaro/triptogether/team/dto/response/AddTeamResDto.java b/src/main/java/com/hanaro/triptogether/team/dto/response/AddTeamResDto.java new file mode 100644 index 0000000..11de05d --- /dev/null +++ b/src/main/java/com/hanaro/triptogether/team/dto/response/AddTeamResDto.java @@ -0,0 +1,10 @@ +package com.hanaro.triptogether.team.dto.response; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class AddTeamResDto { + private Long teamIdx; +} diff --git a/src/main/java/com/hanaro/triptogether/team/service/TeamService.java b/src/main/java/com/hanaro/triptogether/team/service/TeamService.java index 4fb4a6f..0152749 100644 --- a/src/main/java/com/hanaro/triptogether/team/service/TeamService.java +++ b/src/main/java/com/hanaro/triptogether/team/service/TeamService.java @@ -2,13 +2,14 @@ import com.hanaro.triptogether.team.domain.Team; import com.hanaro.triptogether.team.dto.request.*; +import com.hanaro.triptogether.team.dto.response.AddTeamResDto; import com.hanaro.triptogether.team.dto.response.DetailTeamResDto; import com.hanaro.triptogether.team.dto.response.InviteTeamResDto; import com.hanaro.triptogether.team.dto.response.ManageTeamResDto; public interface TeamService { // 모임서비스 가입 - void addTeam(AddTeamReqDto addTeamReqDto); + AddTeamResDto addTeam(AddTeamReqDto addTeamReqDto); // 모임서비스 상세 DetailTeamResDto detailTeam(DetailTeamReqDto detailTeamReqDto); diff --git a/src/main/java/com/hanaro/triptogether/team/service/impl/TeamServiceImpl.java b/src/main/java/com/hanaro/triptogether/team/service/impl/TeamServiceImpl.java index 15505ff..151f1c3 100644 --- a/src/main/java/com/hanaro/triptogether/team/service/impl/TeamServiceImpl.java +++ b/src/main/java/com/hanaro/triptogether/team/service/impl/TeamServiceImpl.java @@ -10,6 +10,7 @@ import com.hanaro.triptogether.team.domain.Team; import com.hanaro.triptogether.team.domain.TeamRepository; import com.hanaro.triptogether.team.dto.request.*; +import com.hanaro.triptogether.team.dto.response.AddTeamResDto; import com.hanaro.triptogether.team.dto.response.DetailTeamResDto; import com.hanaro.triptogether.team.dto.response.InviteTeamResDto; import com.hanaro.triptogether.team.dto.response.ManageTeamResDto; @@ -18,7 +19,6 @@ import com.hanaro.triptogether.teamMember.domain.TeamMemberRepository; import com.hanaro.triptogether.trip.domain.Trip; import com.hanaro.triptogether.trip.domain.TripRepository; -import com.hanaro.triptogether.trip.service.TripService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -38,7 +38,7 @@ public class TeamServiceImpl implements TeamService { // 모임서비스 가입 @Transactional @Override - public void addTeam(AddTeamReqDto addTeamReqDto) { + public AddTeamResDto addTeam(AddTeamReqDto addTeamReqDto) { Account account = accountRepository.findById(addTeamReqDto.getAccIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.ACCOUNT_NOT_FOUND)); Member member = memberRepository.findById(addTeamReqDto.getMemberIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.MEMBER_NOT_FOUND)); @@ -60,6 +60,13 @@ public void addTeam(AddTeamReqDto addTeamReqDto) { teamRepository.save(team); teamMemberRepository.save(teamMember); + + Long teamIdx = team.getTeamIdx(); + AddTeamResDto addTeamResDto = AddTeamResDto.builder() + .teamIdx(teamIdx) + .build(); + + return addTeamResDto; } // 모임서비스 상세