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; } // 모임서비스 상세