-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge: conflict 해결 후 feature로 merge 진행
- 애플리케이션 실행 정상 - 테스트 실행 정상
- Loading branch information
Showing
37 changed files
with
775 additions
and
159 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
.../backendoori/ootw/avatar/domain/Type.java → ...kendoori/ootw/avatar/domain/ItemType.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,5 +1,5 @@ | ||
package com.backendoori.ootw.avatar.domain; | ||
|
||
public enum Type { | ||
public enum ItemType { | ||
HAIR, TOP, PANTS, ACCESSORY, SHOES, BACKGROUND | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/backendoori/ootw/avatar/dto/AvatarItemRequest.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
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,33 @@ | ||
package com.backendoori.ootw.common; | ||
|
||
import java.util.Objects; | ||
import java.util.function.Supplier; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.lang.Nullable; | ||
import org.springframework.util.Assert; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class AssertUtil extends Assert { | ||
|
||
public static void notBlank(@Nullable String string, String message) { | ||
if (string == null || string.isBlank()) { | ||
throw new IllegalArgumentException(message); | ||
} | ||
} | ||
|
||
public static void hasPattern(@Nullable String string, @Nullable String pattern, String message) { | ||
notNull(string, message); | ||
|
||
if (!string.matches(Objects.requireNonNull(pattern))) { | ||
throw new IllegalArgumentException(message); | ||
} | ||
} | ||
|
||
public static void throwIf(boolean state, Supplier<RuntimeException> exceptionSupplier) { | ||
if (state) { | ||
throw exceptionSupplier.get(); | ||
} | ||
} | ||
|
||
} |
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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/backendoori/ootw/common/validation/Enum.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,20 @@ | ||
package com.backendoori.ootw.common.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; | ||
import jakarta.validation.Payload; | ||
|
||
@Target(value = {ElementType.PARAMETER, ElementType.FIELD}) | ||
@Retention(value = RetentionPolicy.RUNTIME) | ||
@Constraint(validatedBy = EnumValidator.class) | ||
public @interface Enum { | ||
|
||
String message() default "유효하지 않은 값입니다 다시 입력해주세요"; | ||
Class<?>[] groups() default {}; | ||
Class<? extends Payload>[] payload() default {}; | ||
Class<? extends java.lang.Enum<?>> enumClass(); | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/backendoori/ootw/common/validation/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.backendoori.ootw.common.validation; | ||
|
||
import java.util.Arrays; | ||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
|
||
public class EnumValidator implements ConstraintValidator<Enum, String> { | ||
|
||
private Enum annotation; | ||
|
||
@Override | ||
public void initialize(Enum constraintAnnotation) { | ||
this.annotation = constraintAnnotation; | ||
} | ||
|
||
@Override | ||
public boolean isValid(String type, ConstraintValidatorContext context) { | ||
if (type == null) { | ||
return false; | ||
} | ||
|
||
return Arrays.stream(this.annotation.enumClass().getEnumConstants()) | ||
.anyMatch(e -> e.name().equals(type)); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/backendoori/ootw/common/validation/Image.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.backendoori.ootw.common.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; | ||
import jakarta.validation.Payload; | ||
|
||
@Target(value = ElementType.PARAMETER) | ||
@Retention(value = RetentionPolicy.RUNTIME) | ||
@Constraint(validatedBy = ImageValidator.class) | ||
public @interface Image { | ||
|
||
String message = "유효하지 않은 이미지를 업로드하였습니다. 다른 이미지를 업로드 해주세요"; | ||
|
||
String message() default message; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/backendoori/ootw/common/validation/ImageValidator.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,25 @@ | ||
package com.backendoori.ootw.common.validation; | ||
|
||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
public class ImageValidator implements ConstraintValidator<Image, MultipartFile> { | ||
|
||
@Override | ||
public boolean isValid(MultipartFile img, ConstraintValidatorContext context) { | ||
if(img == null || img.isEmpty()){ | ||
return false; | ||
} | ||
if(img.getSize() > 10_000_000){ | ||
return false; | ||
} | ||
String contentType = img.getContentType(); | ||
if(!contentType.startsWith("image")){ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
} |
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
38 changes: 0 additions & 38 deletions
38
src/main/java/com/backendoori/ootw/exception/ExceptionResponse.java
This file was deleted.
Oops, something went wrong.
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.