Skip to content

Commit

Permalink
feat : TaskBoardStatus Dto 생성
Browse files Browse the repository at this point in the history
- TaskBoardStatus.Request
- TaskBoardStatus.Response

연관 이슈
- #178
  • Loading branch information
oowtl committed Jan 16, 2025
1 parent 6435bd4 commit 618d60f
Showing 1 changed file with 60 additions and 0 deletions.
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;
}
}
}

0 comments on commit 618d60f

Please sign in to comment.