Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller에서 Swagger 코드 분리 #74

Merged
merged 14 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.RequiredArgsConstructor;
import mouda.backend.common.RestResponse;
import mouda.backend.moim.domain.Moim;
Expand All @@ -24,52 +21,37 @@
@RestController
@RequestMapping("/v1/moim")
@RequiredArgsConstructor
public class MoimController {
public class MoimController implements MoimSwagger {

private final MoimService moimService;

@Operation(summary = "모임 생성", description = "모임을 생성한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 생성 성공!"),
})
@Override
@PostMapping
public ResponseEntity<RestResponse<Long>> createMoim(@RequestBody MoimCreateRequest moimCreateRequest) {
Moim moim = moimService.createMoim(moimCreateRequest);
return ResponseEntity.ok().body(new RestResponse<>(moim.getId()));
}

@Operation(summary = "모임 전체 조회", description = "모든 모임을 조회한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 조회 성공!"),
})
@Override
@GetMapping
public ResponseEntity<RestResponse<MoimFindAllResponses>> findAllMoim() {
return ResponseEntity.ok().body(new RestResponse<>(moimService.findAllMoim()));
}

@Operation(summary = "모임 상세 조회", description = "모임 상세 조회한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 상세 조회 성공!"),
})
@Override
@GetMapping("/{moimId}")
public ResponseEntity<RestResponse<MoimDetailsFindResponse>> findMoimDetails(@PathVariable long moimId) {
return ResponseEntity.ok().body(new RestResponse<>(moimService.findMoimDetails(moimId)));
}

@Operation(summary = "모임 참여", description = "모임에 참여한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 참여 성공!")
})
@Override
@PostMapping("/join")
public ResponseEntity<RestResponse<Void>> joinMoim(@RequestBody MoimJoinRequest moimJoinRequest) {
moimService.joinMoim(moimJoinRequest);
return ResponseEntity.ok().build();
}

@Operation(summary = "모임 삭제", description = "해당하는 id의 모임을 삭제한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 삭제 성공!"),
})
@Override
@DeleteMapping("/{moimId}")
public void deleteMoim(@PathVariable long moimId) {
moimService.deleteMoim(moimId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package mouda.backend.moim.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import mouda.backend.common.RestResponse;
import mouda.backend.moim.dto.request.MoimCreateRequest;
import mouda.backend.moim.dto.request.MoimJoinRequest;
import mouda.backend.moim.dto.response.MoimDetailsFindResponse;
import mouda.backend.moim.dto.response.MoimFindAllResponses;

public interface MoimSwagger {

@Operation(summary = "모임 생성", description = "모임을 생성한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 생성 성공!"),
})
ResponseEntity<RestResponse<Long>> createMoim(@RequestBody MoimCreateRequest moimCreateRequest);

@Operation(summary = "모임 전체 조회", description = "모든 모임을 조회한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 조회 성공!"),
})
ResponseEntity<RestResponse<MoimFindAllResponses>> findAllMoim();

@Operation(summary = "모임 상세 조회", description = "모임 상세 조회한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 상세 조회 성공!"),
})
ResponseEntity<RestResponse<MoimDetailsFindResponse>> findMoimDetails(@PathVariable long moimId);

@Operation(summary = "모임 참여", description = "모임에 참여한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 참여 성공!")
})
ResponseEntity<RestResponse<Void>> joinMoim(@RequestBody MoimJoinRequest moimJoinRequest);

@Operation(summary = "모임 삭제", description = "해당하는 id의 모임을 삭제한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 삭제 성공!"),
})
void deleteMoim(@PathVariable long moimId);
}
Loading
Loading