Skip to content

Commit

Permalink
[refactor/Inhabas#293] 공모전게시판 writerId 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
skytin1004 committed Apr 28, 2024
1 parent 6458871 commit 6752365
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class ContestBoardDetailDto {

@NotBlank private String content;

@NotNull private Long writerId;

@NotBlank private String writerName;

@NotBlank private String association;
Expand Down Expand Up @@ -66,6 +68,7 @@ public ContestBoardDetailDto(
Long contestFieldId,
String title,
String content,
Long writerId,
String writerName,
String association,
String topic,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Integer> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class NormalBoardDetailDto {
@NotBlank private String title;

@NotBlank private String content;

@NotNull private Long writerId;

@NotBlank private String writerName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void createContestBoardDetailDto() {
.contestFieldId(1L)
.title("테스트 제목")
.content("테스트 내용")
.writerId(1L)
.writerName("송민석")
.association("(주) 아이바스")
.topic("테스트 주제")
Expand Down Expand Up @@ -75,6 +76,7 @@ public void nullTitleTest() {
.contestFieldId(1L)
// title 필드 null
.content("테스트 내용")
.writerId(1L)
.writerName("송민석")
.association("(주) 아이바스")
.topic("테스트 주제")
Expand Down

0 comments on commit 6752365

Please sign in to comment.