Skip to content

Commit

Permalink
Docs : API ๋ช…์„ธ
Browse files Browse the repository at this point in the history
  • Loading branch information
CYY1007 committed Oct 14, 2023
1 parent 52107c0 commit 10cfd9e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/briefing/exception/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public enum ErrorCode {

// member ๊ด€๋ จ ์—๋Ÿฌ

MEMBER_NOT_FOUND(BAD_REQUEST, "MEMBER_400_1", "์‚ฌ์šฉ์ž๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค"),
MEMBER_NOT_FOUND(BAD_REQUEST, "MEMBER_001", "์‚ฌ์šฉ์ž๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค"),
MEMBER_NOT_SAME(BAD_REQUEST, "MEMBER_002", "๋กœ๊ทธ์ธ ๋œ ์‚ฌ์šฉ์ž์™€ ๋Œ€์ƒ ์‚ฌ์šฉ์ž๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."),

// member ์—๋Ÿฌ
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/briefing/member/api/MemberApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
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.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand All @@ -32,6 +36,9 @@
@Validated
@RequestMapping("/members")
@RequiredArgsConstructor
@ApiResponses({
@ApiResponse(responseCode = "COMMON000", description = "SERVER ERROR, ๋ฐฑ์•ค๋“œ ๊ฐœ๋ฐœ์ž์—๊ฒŒ ์•Œ๋ ค์ฃผ์„ธ์š”", content = @Content(schema = @Schema(implementation = CommonResponse.class))),
})
public class MemberApi {
private final MemberQueryService memberQueryService;
private final MemberCommandService memberCommandService;
Expand Down Expand Up @@ -62,6 +69,13 @@ public CommonResponse<MemberResponse.LoginDTO> login(
return CommonResponse.onSuccess(MemberConverter.toLoginDTO(member, accessToken, refreshToken));
}

@Operation(summary = "02-01 Member\uD83D\uDC64 accessToken ์žฌ๋ฐœ๊ธ‰ ๋ฐ›๊ธฐ", description = "accessToken ๋งŒ๋ฃŒ ์‹œ refreshToken์œผ๋กœ ์žฌ๋ฐœ๊ธ‰์„ ๋ฐ›๋Š” API ์ž…๋‹ˆ๋‹ค.")
@ApiResponses({
@ApiResponse(responseCode = "1000",description = "OK, ์„ฑ๊ณต"),
@ApiResponse(responseCode = "COMMON001", description = "request body์— ๋‹ด๊ธธ ๊ฐ’์ด ์ด์ƒํ•จ, result๋ฅผ ํ™•์ธํ•ด์ฃผ์„ธ์š”!",content = @Content(schema = @Schema(implementation = CommonResponse.class))),
@ApiResponse(responseCode = "AUTH005", description = "๋ฆฌํ”„๋ ˆ์‹œ ํ† ํฐ๋„ ๋งŒ๋ฃŒ, ๋‹ค์‹œ ๋กœ๊ทธ์ธ",content = @Content(schema = @Schema(implementation = CommonResponse.class))),
@ApiResponse(responseCode = "AUTH009", description = "๋ฆฌํ”„๋ ˆ์‹œ ํ† ํฐ ๋ชจ์–‘์ด ์ž˜๋ชป ๋จ",content = @Content(schema = @Schema(implementation = CommonResponse.class))),
})
@PostMapping("/auth/token")
public CommonResponse<MemberResponse.ReIssueTokenDTO> reissueToken(@Valid @RequestBody MemberRequest.ReissueDTO request){
RefreshToken refreshToken = redisService.reGenerateRefreshToken(request);
Expand All @@ -70,12 +84,20 @@ public CommonResponse<MemberResponse.ReIssueTokenDTO> reissueToken(@Valid @Reque
return CommonResponse.onSuccess(MemberConverter.toReIssueTokenDTO(parsedMember.getId(), accessToken,refreshToken.getToken()));
}


@Operation(summary = "02-01 Member\uD83D\uDC64 ํšŒ์› ํƒˆํ‡ด", description = "ํšŒ์› ํƒˆํ‡ด API ์ž…๋‹ˆ๋‹ค.")
@DeleteMapping("/{memberId}")
@Parameters({
@Parameter(name = "member", hidden = true),
@Parameter(name = "memberId", description = "์‚ญ์ œ ๋Œ€์ƒ ๋ฉค๋ฒ„์•„์ด๋””")
})
@ApiResponses({
@ApiResponse(responseCode = "1000",description = "OK, ์„ฑ๊ณต"),
@ApiResponse(responseCode = "AUTH003", description = "access ํ† ํฐ์„ ์ฃผ์„ธ์š”!",content = @Content(schema = @Schema(implementation = CommonResponse.class))),
@ApiResponse(responseCode = "AUTH004", description = "acess ํ† ํฐ ๋งŒ๋ฃŒ",content = @Content(schema = @Schema(implementation = CommonResponse.class))),
@ApiResponse(responseCode = "AUTH006", description = "acess ํ† ํฐ ๋ชจ์–‘์ด ์ด์ƒํ•จ",content = @Content(schema = @Schema(implementation = CommonResponse.class))),
@ApiResponse(responseCode = "MEMBER_001", description = "์‚ฌ์šฉ์ž๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.",content = @Content(schema = @Schema(implementation = CommonResponse.class))),
@ApiResponse(responseCode = "MEMBER_002", description = "๋กœ๊ทธ์ธ ํ•œ ์‚ฌ์šฉ์ž์™€ ํƒˆํ‡ด ๋Œ€์ƒ์ด ๋™์ผํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.",content = @Content(schema = @Schema(implementation = CommonResponse.class))),
})
public CommonResponse<MemberResponse.QuitDTO> quitMember(@AuthMember Member member, @CheckSameMember @PathVariable Long memberId){
memberCommandService.deleteMember(memberId);
return CommonResponse.onSuccess(MemberConverter.toQuitDTO());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/briefing/redis/service/RedisServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public RefreshToken generateRefreshToken(String socialId, SocialType socialType)
public RefreshToken reGenerateRefreshToken(MemberRequest.ReissueDTO request) {
if(request.getRefreshToken() == null)
throw new MemberException(ErrorCode.INVALID_TOKEN_EXCEPTION);
RefreshToken findRefreshToken = refreshTokenRepository.findById(request.getRefreshToken()).orElseThrow(() -> new RefreshTokenException(ErrorCode.INVALID_TOKEN_EXCEPTION));
RefreshToken findRefreshToken = refreshTokenRepository.findById(request.getRefreshToken()).orElseThrow(() -> new RefreshTokenException(ErrorCode.INVALID_REFRESH_TOKEN));
LocalDateTime expireTime = findRefreshToken.getExpireTime();
LocalDateTime current = LocalDateTime.now();
// ํ…Œ์ŠคํŠธ์šฉ, ์‹ค์ œ๋กœ๋Š” ํ˜„์žฌ ์‹œ๊ฐ„ + accessToken ๋งŒ๋ฃŒ ์‹œ๊ฐ„
Expand Down

0 comments on commit 10cfd9e

Please sign in to comment.