-
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.
Post 필드에 티어정보를 추가. 생성시 티어정보의 필드가 필수로 넘어오도록 설정
- Loading branch information
Showing
7 changed files
with
62 additions
and
13 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
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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/api/TaveShot/domain/post/domain/PostTier.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,31 @@ | ||
package com.api.TaveShot.domain.post.domain; | ||
|
||
import com.api.TaveShot.global.exception.ApiException; | ||
import com.api.TaveShot.global.exception.ErrorType; | ||
|
||
public enum PostTier { | ||
BRONZE_SILVER("BronzeSilver"), | ||
GOLD("Gold"), | ||
PLATINUM("Platinum"), | ||
HIGH("High"); | ||
|
||
private final String tier; | ||
|
||
PostTier(String tier) { | ||
this.tier = tier; | ||
} | ||
|
||
// 문자열을 enum으로 변환하는 메서드 | ||
public static PostTier findTier(String input) { | ||
for (PostTier post : PostTier.values()) { | ||
if (post.tier.equalsIgnoreCase(input)) { | ||
return post; | ||
} | ||
} | ||
throw new ApiException(ErrorType._POST_INVALID_TIER); | ||
} | ||
|
||
public static boolean isHighTier(PostTier tier) { | ||
return tier == HIGH; | ||
} | ||
} |
15 changes: 12 additions & 3 deletions
15
src/main/java/com/api/TaveShot/domain/post/dto/request/PostCreateRequest.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,26 +1,35 @@ | ||
package com.api.TaveShot.domain.post.dto.request; | ||
|
||
import com.api.TaveShot.domain.post.domain.PostTier; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotEmpty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
/** 게시글의 등록, 수정을 처리할 Request 클래스 **/ | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
public class PostCreateRequest { | ||
|
||
@Schema(description = "게시글 제목", example = "게시글 제목 예시") | ||
@NotEmpty | ||
private String title; | ||
|
||
@Schema(description = "게시글 내용", example = "게시글 내용 예시") | ||
@NotEmpty | ||
private String content; | ||
|
||
@Schema(description = "게시글 작성자", example = "작성자 예시") | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
private String writer; | ||
@Schema(description = "게시판 등급", example = "BronzeSilver or Gold or Platinum or High") | ||
@NotEmpty | ||
private String postTier; | ||
|
||
@Schema(description = "게시글 첨부 파일", type = "string", format = "binary") | ||
private MultipartFile attachmentFile; | ||
|
||
public PostTier getPostTier() { | ||
// 문자열을 enum으로 변환 | ||
return PostTier.findTier(postTier); | ||
} | ||
} |
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 comments
on commit faf6d8e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
converter class를 이용하기 보단 service class에서 처리하는 게 더 효율적이지 않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
단일 책임 원칙을 적용하였습니다. Service에서는 비즈니스 로직만을 책임지고, Converter는 Dto-> Entity, Entity -> Dto, Dto -> Response 와 같이, 바꾸는 책임만을 갖기 위해 분리한 것입니다.
작성자는 member에서 가져오기 때문에 삭제한 건가요?