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

[STYLE] MemberApiController에 swagger 관련 ApiReponse 추가 #63

Merged
merged 2 commits into from
Aug 19, 2024
Merged
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
40 changes: 40 additions & 0 deletions src/main/java/umc/haruchi/web/controller/MemberApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Email;
Expand All @@ -29,6 +32,11 @@ public class MemberApiController {

@PostMapping("/signup")
@Operation(summary = "회원가입 API", description = "이메일 인증으로 회원가입을 진행하는 API (액세스 토큰 필요 없음)")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4005", description = "존재하지 않는 회원입니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MONTHBUDGET4001", description = "한 달 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
})
public ApiResponse<MemberResponseDTO.MemberJoinResultDTO> join(@Valid @RequestBody MemberRequestDTO.MemberJoinDTO request) throws Exception {
Member member = memberService.joinMember(request);
memberService.connectToDayBudget(member.getId());
Expand All @@ -41,6 +49,10 @@ public ApiResponse<MemberResponseDTO.MemberJoinResultDTO> join(@Valid @RequestBo
@Parameter(name = "password", description = "회원가입을 진행할 비밀번호"),
@Parameter(name = "checkPassword", description = "확인용 비밀번호")
})
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4006", description = "비밀번호가 일치하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
})
public ApiResponse<MemberResponseDTO> verifyPassword(@RequestParam("password") String password,
@RequestParam("checkPassword") String verifyPassword) throws Exception {
memberService.checkPassword(password, verifyPassword);
Expand All @@ -52,6 +64,10 @@ public ApiResponse<MemberResponseDTO> verifyPassword(@RequestParam("password") S
@Parameters({
@Parameter(name = "email", description = "인증을 받을 메일 주소")
})
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4002",description = "이미 있는 이메일입니다."),
})
public ApiResponse<MemberResponseDTO> sendEmail(@Email(message = "이메일 형식이 올바르지 않습니다.")
@RequestParam("email") String email) throws Exception {
memberService.sendSimpleMessage(email);
Expand All @@ -64,6 +80,10 @@ public ApiResponse<MemberResponseDTO> sendEmail(@Email(message = "이메일 형
@Parameter(name = "email", description = "인증을 받은 메일 주소"),
@Parameter(name = "code", description = "받은 인증 코드")
})
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4004",description = "인증 번호가 일치하지 않습니다.")
})
public ApiResponse<MemberResponseDTO> verifyEmail(@Email(message = "이메일 형식이 올바르지 않습니다.")
@RequestParam("email") String email,
@RequestParam("code") String code) throws Exception {
Expand All @@ -82,6 +102,11 @@ public ApiResponse<MemberResponseDTO> verifyEmail(@Email(message = "이메일

@PostMapping("/login")
@Operation(summary = "로그인 API", description = "로그인을 진행하는 API (토큰 방급; 액세스 토큰 필요 없음)")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4005", description = "존재하지 않는 회원입니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4006", description = "비밀번호가 일치하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
})
public ApiResponse<MemberResponseDTO.NewLoginJwtTokenDTO> login(@Valid @RequestBody MemberRequestDTO.MemberLoginDTO request) {
MemberResponseDTO.NewLoginJwtTokenDTO token = memberService.newLogin(request);
return ApiResponse.onSuccess(token);
Expand All @@ -105,6 +130,10 @@ public String loginTest() {

@PostMapping("/logout")
@Operation(summary = "로그아웃 API", description = "로그아웃을 진행하는 API (토큰 만료 및 블랙리스트화)")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4022",description = "해당 토큰은 유효한 토큰이 아닙니다."),
})
public ApiResponse<MemberResponseDTO> logout(@RequestHeader("Authorization") String accessToken) {
memberService.newLogout(accessToken.substring(7));
return ApiResponse.onSuccess(null);
Expand All @@ -125,6 +154,11 @@ public ApiResponse<MemberResponseDTO> logout(@RequestHeader("Authorization") Str

@PostMapping("/delete")
@Operation(summary = "회원탈퇴 API", description = "회원탈퇴를 진행하는 API (토큰 만료 및 회원 영구 삭제)")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4005", description = "존재하지 않는 회원입니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4022",description = "해당 토큰은 유효한 토큰이 아닙니다."),
})
public ApiResponse<MemberResponseDTO> deleteMember(@RequestHeader("Authorization") String accessToken,
@RequestParam String reason) {
memberService.newWithdrawer(reason,accessToken.substring(7));
Expand All @@ -143,13 +177,19 @@ public ApiResponse<MemberResponseDTO> deleteMember(@RequestHeader("Authorization

@GetMapping("/")
@Operation(summary = "회원정보조회 API", description = "헤더에 있는 토큰으로 회원을 식별하고, 더보기 화면에서 회원의 정보를 조회하는 API")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
})
public ApiResponse<MemberResponseDTO.MemberDetailResultDTO> getMemberDetail(@AuthenticationPrincipal MemberDetail memberDetail) {
String email = memberDetail.getMember().getEmail();
return ApiResponse.onSuccess(memberService.getMemberDetail(email));
}

@GetMapping("/safebox")
@Operation(summary = "회원 세이프박스 조회 API", description = "헤더에 있는 토큰으로 회원을 식별하고, 회원의 세이프박스 금액 조회하는 API")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
})
public ApiResponse<MemberResponseDTO.MemberSafeBoxResultDTO> getMemberSafeBox(@AuthenticationPrincipal MemberDetail memberDetail) {
Long safeBox = memberDetail.getMember().getSafeBox();
return ApiResponse.onSuccess(MemberConverter.toSafeBoxResultDTO(safeBox));
Expand Down
Loading