-
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.
- TaskBoardStatus.Request - TaskBoardStatus.Response 연관 이슈 - #178
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
module-service/src/main/java/com/checkping/dto/TaskBoardStatus.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,60 @@ | ||
package com.checkping.dto; | ||
|
||
import com.checkping.domain.board.TaskBoard; | ||
import com.checkping.domain.board.TaskBoard.BoardCategory; | ||
import com.checkping.exception.project.TaskBoardInvalidBoardCategoryException; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class TaskBoardStatus { | ||
|
||
@Getter | ||
public static class Request { | ||
|
||
/* | ||
label : Enum 한글 설명 | ||
value : Enum 값(DB) | ||
*/ | ||
@Schema(description = "Enum 이름") | ||
private String label; | ||
@Schema(description = "Enum 설명") | ||
private String value; | ||
|
||
/** | ||
* Request Dto -> Entity | ||
* | ||
* @param request 게시글 상태 Dto | ||
* @return TaskBoard.BoardCategory | ||
*/ | ||
public static TaskBoard.BoardStatus toEntity(Request request) { | ||
try { | ||
return TaskBoard.BoardStatus.valueOf(request.getValue().toUpperCase()); | ||
} catch (IllegalArgumentException e) { | ||
throw new TaskBoardInvalidBoardCategoryException(request.toString()); | ||
} | ||
} | ||
} | ||
|
||
@Getter | ||
public static class Response { | ||
|
||
/* | ||
label : Enum 한글 설명 | ||
value : Enum 값(DB) | ||
*/ | ||
@Schema(description = "Enum 이름") | ||
private String label; | ||
@Schema(description = "Enum 설명") | ||
private String value; | ||
|
||
public static Response toDto(BoardCategory boardCategory) { | ||
Response dto = new Response(); | ||
dto.label = boardCategory.name(); | ||
dto.value = boardCategory.getDescription(); | ||
return dto; | ||
} | ||
} | ||
} |