From 67523652830532065c3460e591eab2b74bfa5eeb Mon Sep 17 00:00:00 2001 From: skytin1004 Date: Mon, 29 Apr 2024 08:58:39 +0900 Subject: [PATCH] =?UTF-8?q?[refactor/Inhabas#293]=20=EA=B3=B5=EB=AA=A8?= =?UTF-8?q?=EC=A0=84=EA=B2=8C=EC=8B=9C=ED=8C=90=20writerId=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contest/dto/ContestBoardDetailDto.java | 4 ++ .../menu/util/MenuTypeToMenuIdConverter.java | 40 +++++++++++++++++++ .../normalBoard/dto/NormalBoardDetailDto.java | 1 + .../dto/ContestBoardDetailDtoTest.java | 2 + 4 files changed, 47 insertions(+) create mode 100644 resource-server/src/main/java/com/inhabas/api/domain/menu/util/MenuTypeToMenuIdConverter.java diff --git a/resource-server/src/main/java/com/inhabas/api/domain/contest/dto/ContestBoardDetailDto.java b/resource-server/src/main/java/com/inhabas/api/domain/contest/dto/ContestBoardDetailDto.java index 9d5313a6..904aefbe 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/contest/dto/ContestBoardDetailDto.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/contest/dto/ContestBoardDetailDto.java @@ -28,6 +28,8 @@ public class ContestBoardDetailDto { @NotBlank private String content; + @NotNull private Long writerId; + @NotBlank private String writerName; @NotBlank private String association; @@ -66,6 +68,7 @@ public ContestBoardDetailDto( Long contestFieldId, String title, String content, + Long writerId, String writerName, String association, String topic, @@ -80,6 +83,7 @@ public ContestBoardDetailDto( this.contestFieldId = contestFieldId; this.title = title; this.content = content; + this.writerId = writerId; this.writerName = writerName; this.association = association; this.topic = topic; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/menu/util/MenuTypeToMenuIdConverter.java b/resource-server/src/main/java/com/inhabas/api/domain/menu/util/MenuTypeToMenuIdConverter.java new file mode 100644 index 00000000..c24d5d98 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/menu/util/MenuTypeToMenuIdConverter.java @@ -0,0 +1,40 @@ +package com.inhabas.api.domain.menu.util; + +import java.util.Optional; + +import com.inhabas.api.domain.contest.domain.ContestType; +import com.inhabas.api.domain.menu.domain.valueObject.MenuType; +import com.inhabas.api.domain.normalBoard.domain.NormalBoardType; +import com.inhabas.api.domain.project.domain.ProjectBoardType; + +public class MenuTypeToMenuIdConverter { + + // menuType을 boardType을 통해 menuId로 변환 + public static Optional MenuTypeToMenuId(MenuType menuType) { + Integer menuId = null; + + // NormalBoardType enum을 확인 + for (NormalBoardType boardType : NormalBoardType.values()) { + if (boardType.getBoardType().equalsIgnoreCase(menuType.toString())) { + return Optional.of(boardType.getMenuId()); + } + } + + // ProjectBoardType을 확인 + for (ProjectBoardType projectBoardType : ProjectBoardType.values()) { + if (projectBoardType.getBoardType().equalsIgnoreCase(menuType.toString())) { + return Optional.of(projectBoardType.getMenuId()); + } + } + + // ContestBoardType을 확인 + for (ContestType contestType : ContestType.values()) { + if (contestType.getBoardType().equalsIgnoreCase(menuType.toString())) { + return Optional.of(contestType.getMenuId()); + } + } + + // 못찾으면 Optional.empty() 반환 + return Optional.empty(); + } +} diff --git a/resource-server/src/main/java/com/inhabas/api/domain/normalBoard/dto/NormalBoardDetailDto.java b/resource-server/src/main/java/com/inhabas/api/domain/normalBoard/dto/NormalBoardDetailDto.java index 618a221b..8321cbac 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/normalBoard/dto/NormalBoardDetailDto.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/normalBoard/dto/NormalBoardDetailDto.java @@ -24,6 +24,7 @@ public class NormalBoardDetailDto { @NotBlank private String title; @NotBlank private String content; + @NotNull private Long writerId; @NotBlank private String writerName; diff --git a/resource-server/src/test/java/com/inhabas/api/domain/contest/dto/ContestBoardDetailDtoTest.java b/resource-server/src/test/java/com/inhabas/api/domain/contest/dto/ContestBoardDetailDtoTest.java index b9d04c1e..41507db8 100644 --- a/resource-server/src/test/java/com/inhabas/api/domain/contest/dto/ContestBoardDetailDtoTest.java +++ b/resource-server/src/test/java/com/inhabas/api/domain/contest/dto/ContestBoardDetailDtoTest.java @@ -44,6 +44,7 @@ public void createContestBoardDetailDto() { .contestFieldId(1L) .title("테스트 제목") .content("테스트 내용") + .writerId(1L) .writerName("송민석") .association("(주) 아이바스") .topic("테스트 주제") @@ -75,6 +76,7 @@ public void nullTitleTest() { .contestFieldId(1L) // title 필드 null .content("테스트 내용") + .writerId(1L) .writerName("송민석") .association("(주) 아이바스") .topic("테스트 주제")