-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
40 changed files
with
755 additions
and
327 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
FROM eclipse-temurin:17-jdk-alpine | ||
|
||
# Redis 설치 | ||
RUN apk add --no-cache redis | ||
|
||
COPY ./build/libs/*SNAPSHOT.jar project.jar | ||
ENTRYPOINT ["java", "-jar", "project.jar"] | ||
ENTRYPOINT redis-server & java -jar project.jar |
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
2 changes: 0 additions & 2 deletions
2
src/main/java/com/example/mate/common/config/SecurityConfig.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
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
23 changes: 23 additions & 0 deletions
23
src/main/java/com/example/mate/common/config/WebMvcConfig.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,23 @@ | ||
package com.example.mate.common.config; | ||
|
||
import com.example.mate.common.validator.ValidPageableArgumentResolver; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
import java.util.List; | ||
|
||
@Configuration | ||
public class WebMvcConfig implements WebMvcConfigurer { | ||
|
||
private final ValidPageableArgumentResolver validPageableArgumentResolver; | ||
|
||
public WebMvcConfig(ValidPageableArgumentResolver validPageableArgumentResolver) { | ||
this.validPageableArgumentResolver = validPageableArgumentResolver; | ||
} | ||
|
||
@Override | ||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) { | ||
resolvers.add(validPageableArgumentResolver); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...common/utils/validator/EnumValidator.java → .../mate/common/validator/EnumValidator.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
2 changes: 1 addition & 1 deletion
2
...ate/common/utils/validator/ValidEnum.java → ...mple/mate/common/validator/ValidEnum.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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/example/mate/common/validator/ValidPageable.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,27 @@ | ||
package com.example.mate.common.validator; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import org.springframework.core.annotation.AliasFor; | ||
import org.springframework.data.domain.Sort.Direction; | ||
|
||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.PARAMETER}) | ||
public @interface ValidPageable { | ||
|
||
@AliasFor("size") | ||
int value() default 10; | ||
|
||
@AliasFor("value") | ||
int size() default 10; | ||
|
||
int page() default 0; | ||
|
||
String[] sort() default {}; | ||
|
||
Direction direction() default Direction.ASC; | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/example/mate/common/validator/ValidPageableArgumentResolver.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.example.mate.common.validator; | ||
|
||
import org.springframework.core.MethodParameter; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.support.WebDataBinderFactory; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.method.support.ModelAndViewContainer; | ||
|
||
/** | ||
* 커스텀 Pageable 리졸버로, {@code @ValidPageable} 어노테이션이 붙은 Pageable 매개변수의 유효성 검사를 수행합니다. | ||
*/ | ||
@Component | ||
public class ValidPageableArgumentResolver extends PageableHandlerMethodArgumentResolver { | ||
|
||
@Override | ||
public Pageable resolveArgument(MethodParameter methodParameter, | ||
ModelAndViewContainer mavContainer, | ||
NativeWebRequest webRequest, | ||
WebDataBinderFactory binderFactory) { | ||
|
||
// 기본 Pageable 생성 | ||
Pageable pageable = super.resolveArgument(methodParameter, mavContainer, webRequest, binderFactory); | ||
|
||
// @ValidPageable 어노테이션 확인 | ||
ValidPageable validPageable = methodParameter.getParameterAnnotation(ValidPageable.class); | ||
|
||
int pageNumber = Math.max(pageable.getPageNumber(), validPageable != null ? validPageable.page() : 0); | ||
int pageSize = pageable.getPageSize() > 0 | ||
? pageable.getPageSize() | ||
: validPageable != null ? validPageable.size() : 10; | ||
|
||
return PageRequest.of(pageNumber, pageSize, pageable.getSort()); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/example/mate/domain/goods/dto/request/GoodsPostRequest.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/example/mate/domain/goods/dto/request/GoodsReviewRequest.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
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.