-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
418 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 15 additions & 2 deletions
17
src/main/java/com/dnd/dndtravel/auth/controller/request/AppleLoginRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
package com.dnd.dndtravel.auth.controller.request; | ||
|
||
//todo 필드값들 유효성 체크 | ||
// todo 입력 색상 예시는 클라에서 String 타입들. RED, ORANGE, YELLOW, MELON, BLUE, PURPLE | ||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
||
import com.dnd.dndtravel.auth.controller.request.validation.ColorValidation; | ||
import com.dnd.dndtravel.member.domain.SelectedColor; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public record AppleLoginRequest( | ||
@Schema(description = "authorization code", requiredMode = REQUIRED) | ||
@NotBlank(message = "authorization code는 필수 입니다.") | ||
@Size(max = 300, message = "authorization code 형식이 아닙니다") | ||
String appleToken, | ||
|
||
@Schema(description = "유저가 선택한 색상", requiredMode = REQUIRED) | ||
@ColorValidation(enumClass = SelectedColor.class) | ||
String selectedColor | ||
){ | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/dnd/dndtravel/auth/controller/request/validation/ColorValidation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.dnd.dndtravel.auth.controller.request.validation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import jakarta.validation.Constraint; | ||
|
||
@Constraint(validatedBy = {ColorValidator.class}) | ||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface ColorValidation { | ||
String message() default "invalid region"; | ||
Class<? extends java.lang.Enum<?>> enumClass(); | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/dnd/dndtravel/auth/controller/request/validation/ColorValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.dnd.dndtravel.auth.controller.request.validation; | ||
|
||
import java.util.Arrays; | ||
|
||
import com.dnd.dndtravel.map.controller.request.validation.RegionCondition; | ||
import com.dnd.dndtravel.map.controller.request.validation.RegionEnum; | ||
import com.dnd.dndtravel.member.domain.SelectedColor; | ||
|
||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
|
||
public class ColorValidator implements ConstraintValidator<ColorValidation, String> { | ||
|
||
private ColorValidation annotation; | ||
|
||
|
||
@Override | ||
public void initialize(ColorValidation constraintAnnotation) { | ||
this.annotation = constraintAnnotation; | ||
} | ||
|
||
@Override | ||
public boolean isValid(String color, ConstraintValidatorContext context) { | ||
// 색상 없으면 예외 | ||
if (color == null || color.isBlank()) { | ||
return false; | ||
} | ||
|
||
Object[] enumValues = this.annotation.enumClass().getEnumConstants(); | ||
if (enumValues == null) { | ||
return false; | ||
} | ||
|
||
// 색상 Enum중 하나라도 해당되면 true | ||
return Arrays.stream(enumValues).anyMatch(enumValue -> SelectedColor.isMatch(color)); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/com/dnd/dndtravel/auth/controller/swagger/AuthControllerSwagger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.dnd.dndtravel.auth.controller.swagger; | ||
|
||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import com.dnd.dndtravel.auth.controller.request.AppleLoginRequest; | ||
import com.dnd.dndtravel.auth.controller.request.ReIssueTokenRequest; | ||
import com.dnd.dndtravel.auth.service.dto.response.ReissueTokenResponse; | ||
import com.dnd.dndtravel.auth.service.dto.response.TokenResponse; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
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; | ||
|
||
@Tag(name = "auth", description = "인증 API") | ||
public interface AuthControllerSwagger { | ||
|
||
String STATUS_CODE_400_BODY_MESSAGE = "{\"message\":\"잘못된 요청입니다\"}"; | ||
|
||
@Operation( | ||
summary = "애플 OAuth login API" | ||
) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "정상 로그인", | ||
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)), | ||
@ApiResponse(responseCode = "204", description = "refresh token 재발급 필요시", | ||
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)), | ||
@ApiResponse( | ||
responseCode = "500", description = "서버 오류", | ||
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, | ||
schema = @Schema(example = "{\"message\":\"Internal Server Error\"}") | ||
) | ||
) | ||
}) | ||
ResponseEntity<TokenResponse> appleOAuthLogin( | ||
@Parameter(description = "로그인 요청 정보(authorization code, color)", required = true) | ||
AppleLoginRequest appleLoginRequest | ||
); | ||
|
||
@Operation( | ||
summary = "Refresh Token 재발급 API" | ||
) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "정상 발급", | ||
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, | ||
schema = @Schema(implementation = ReissueTokenResponse.class))), | ||
@ApiResponse(responseCode = "400", description = "유효하지 않은 RefreshToken 요청시", | ||
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, | ||
schema = @Schema(example = STATUS_CODE_400_BODY_MESSAGE) | ||
) | ||
), | ||
@ApiResponse( | ||
responseCode = "500", description = "서버 오류", | ||
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, | ||
schema = @Schema(example = "{\"message\":\"Internal Server Error\"}") | ||
) | ||
) | ||
}) | ||
ReissueTokenResponse reissueToken( | ||
@Parameter(description = "refreshToken", required = true) | ||
ReIssueTokenRequest reissueTokenRequest | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.