Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ny2060 committed Jun 11, 2024
2 parents 7ba781b + 8ad2c01 commit a2c8c26
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
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;
import com.hanaro.triptogether.team.service.TeamService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequiredArgsConstructor
public class TeamController {
private final TeamService teamService;

// 모임서비스 가입
@PostMapping("/account/add")
public void addTeam(@RequestBody AddTeamReqDto addTeamReqDto) {
teamService.addTeam(addTeamReqDto);
public AddTeamResDto addTeam(@RequestBody AddTeamReqDto addTeamReqDto) {
return teamService.addTeam(addTeamReqDto);
}

// 모임서비스 상세
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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));

Expand All @@ -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;
}

// 모임서비스 상세
Expand Down

0 comments on commit a2c8c26

Please sign in to comment.