-
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.
[fix] #63 post api enum code 적용 후 enum dto로 변환
- Loading branch information
1 parent
80eeb31
commit e6428d2
Showing
5 changed files
with
91 additions
and
32 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
38 changes: 38 additions & 0 deletions
38
src/main/java/org/gachon/checkmate/domain/post/dto/request/PostRequestDto.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,38 @@ | ||
package org.gachon.checkmate.domain.post.dto.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import org.gachon.checkmate.domain.checkList.dto.request.CheckListRequestDto; | ||
import org.gachon.checkmate.domain.post.dto.support.PostEnumDto; | ||
import org.gachon.checkmate.domain.post.entity.DormitoryType; | ||
import org.gachon.checkmate.domain.post.entity.ImportantKeyType; | ||
import org.gachon.checkmate.domain.post.entity.RoomType; | ||
import org.gachon.checkmate.domain.post.entity.SimilarityKeyType; | ||
|
||
import java.time.LocalDate; | ||
|
||
import static org.gachon.checkmate.global.utils.EnumValueUtils.toEntityCode; | ||
|
||
public record PostRequestDto( | ||
@NotBlank(message = "제목을 입력해주세요") String title, | ||
@NotBlank(message = "내용을 입력해주세요") String content, | ||
@NotNull(message = "중요 키워드를 입력해주세요") String importantKey, | ||
@NotNull(message = "유사도를 입력해주세요") String similarityKey, | ||
@NotNull(message = "호실을 입력해주세요") String roomType, | ||
@NotNull(message = "기숙사 유형을 입력해주세요") String dormitoryType, | ||
@NotNull(message = "모집 마감기간을 입력해주세요") LocalDate endDate, | ||
@NotNull(message = "체크리스트를 입력해주세요") CheckListRequestDto checkList | ||
) { | ||
public static PostEnumDto toEnumDto(PostRequestDto requestDto) { | ||
return PostEnumDto.builder() | ||
.title(requestDto.title()) | ||
.content(requestDto.content()) | ||
.importantKey(toEntityCode(ImportantKeyType.class, requestDto.importantKey())) | ||
.similarityKey(toEntityCode(SimilarityKeyType.class, requestDto.similarityKey())) | ||
.roomType(toEntityCode(RoomType.class, requestDto.roomType())) | ||
.dormitoryType(toEntityCode(DormitoryType.class, requestDto.dormitoryType())) | ||
.endDate(requestDto.endDate()) | ||
.checkList(CheckListRequestDto.toEnumDto(requestDto.checkList())) | ||
.build(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/org/gachon/checkmate/domain/post/dto/support/PostEnumDto.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 org.gachon.checkmate.domain.post.dto.support; | ||
|
||
import lombok.Builder; | ||
import org.gachon.checkmate.domain.checkList.dto.support.CheckListEnumDto; | ||
import org.gachon.checkmate.domain.post.entity.DormitoryType; | ||
import org.gachon.checkmate.domain.post.entity.ImportantKeyType; | ||
import org.gachon.checkmate.domain.post.entity.RoomType; | ||
import org.gachon.checkmate.domain.post.entity.SimilarityKeyType; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Builder | ||
public record PostEnumDto( | ||
String title, | ||
String content, | ||
ImportantKeyType importantKey, | ||
SimilarityKeyType similarityKey, | ||
RoomType roomType, | ||
DormitoryType dormitoryType, | ||
LocalDate endDate, | ||
CheckListEnumDto checkList | ||
) { | ||
} |
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