-
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.
Merge branch 'feature/#97-community-post-search/GAJI-124' into develop
- Loading branch information
Showing
59 changed files
with
778 additions
and
605 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...n/annotation/CheckHashtagListElement.java → .../common/annotation/CheckHashtagBlank.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
17 changes: 17 additions & 0 deletions
17
src/main/java/gaji/service/domain/common/annotation/CheckHashtagLength.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,17 @@ | ||
package gaji.service.domain.common.annotation; | ||
|
||
import gaji.service.domain.common.validation.HashtagLengthValidator; | ||
import jakarta.validation.Constraint; | ||
import jakarta.validation.Payload; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Constraint(validatedBy = HashtagLengthValidator.class) | ||
@Target( { ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface CheckHashtagLength { | ||
String message() default "올바른 해시태그 값을 입력해주세요."; | ||
Class<?>[] groups() default {}; | ||
Class<? extends Payload>[] payload() default {}; | ||
} |
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
39 changes: 39 additions & 0 deletions
39
src/main/java/gaji/service/domain/common/validation/HashtagLengthValidator.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,39 @@ | ||
package gaji.service.domain.common.validation; | ||
|
||
import gaji.service.domain.common.annotation.CheckHashtagBlank; | ||
import gaji.service.domain.common.annotation.CheckHashtagLength; | ||
import gaji.service.global.exception.code.status.GlobalErrorStatus; | ||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
public class HashtagLengthValidator implements ConstraintValidator<CheckHashtagLength, List<String>> { | ||
|
||
@Override | ||
public void initialize(CheckHashtagLength constraintAnnotation) { | ||
ConstraintValidator.super.initialize(constraintAnnotation); | ||
} | ||
|
||
@Override | ||
public boolean isValid(List<String> values, ConstraintValidatorContext context) { | ||
// 리스트 자체가 null인 경우 유효성 검사에서 제외 | ||
if (values == null) { | ||
return true; | ||
} | ||
|
||
// 유효성 검사 통과 조건 | ||
// 리스트 안의 모든 element의 글자 수가 15자 이하여야함 | ||
boolean isValid = values.stream() | ||
.allMatch(value -> value.length() <= 15); | ||
|
||
if (!isValid) { | ||
context.disableDefaultConstraintViolation(); | ||
context.buildConstraintViolationWithTemplate(GlobalErrorStatus._INVALID_HASHTAG_LENGTH.getMessage()).addConstraintViolation(); | ||
} | ||
|
||
return isValid; | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
src/main/java/gaji/service/domain/post/code/CommunityCommentErrorStatus.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,32 @@ | ||
package gaji.service.domain.post.code; | ||
|
||
import gaji.service.global.exception.code.BaseCodeDto; | ||
import gaji.service.global.exception.code.BaseErrorCodeInterface; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum CommunityCommentErrorStatus implements BaseErrorCodeInterface { | ||
|
||
_COMMENT_NOT_FOUND(HttpStatus.BAD_REQUEST, "COMMENT_4001", "존재하지 않는 댓글입니다."), | ||
_NOT_AUTHORIZED(HttpStatus.FORBIDDEN, "COMMENT_4031", "해당 댓글에 접근 권한이 없습니다.") | ||
; | ||
|
||
private final HttpStatus httpStatus; | ||
private final boolean isSuccess = false; | ||
private final String code; | ||
private final String message; | ||
|
||
@Override | ||
public BaseCodeDto getErrorCode() { | ||
return BaseCodeDto.builder() | ||
.httpStatus(httpStatus) | ||
.isSuccess(isSuccess) | ||
.code(code) | ||
.message(message) | ||
.build(); | ||
} | ||
} |
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.