Skip to content

Commit

Permalink
Merge pull request #192 from urinaner/refactor/190
Browse files Browse the repository at this point in the history
[BE] [REFACTOR] reqDto에서 파일 필드 숨김 및 Board category 필드를 필수에 추가
  • Loading branch information
2Jin1031 authored Dec 7, 2024
2 parents d06407f + 5eee3d6 commit 611daa2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.example.backend.board.domain.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import lombok.AccessLevel;
import lombok.Builder;
Expand All @@ -12,16 +13,15 @@ public class BoardReqDto {
private String title;
private String content;
private String writer;
@Schema(hidden = true)
private List<String> fileList;
private String category;

@Builder
private BoardReqDto(String title, String content, String writer,
List<String> fileList, String category) {
private BoardReqDto(String title, String content, String writer, String category) {
this.title = title;
this.content = content;
this.writer = writer;
this.fileList = fileList;
this.category = category;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.example.backend.board.domain.entity;

import java.util.Arrays;

public enum Category {
undergraduate("학부"),
graduate("대학원"),
Expand All @@ -11,6 +13,11 @@ public enum Category {
Category(String description) {
this.description = description;
}

public static boolean contains(final String name) {
return Arrays.stream(Category.values())
.anyMatch(o -> o.name().equals(name));
}
public String getDescription() {
return description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public enum BoardExceptionType implements BaseExceptionType {
NOT_FOUND_BOARD(NOT_FOUND, "게시글을 찾을 수 없습니다"),
REQUIRED_TITLE(BAD_REQUEST, "제목은 필수 입력값입니다."),
REQUIRED_CONTENT(BAD_REQUEST, "내용은 필수 입력값입니다."),
REQUIRED_CATEGORY(BAD_REQUEST, "카티고리는 필수 입력값입니다"),
REQUIRED_DEPARTMENT_ID(BAD_REQUEST, "부서 ID는 필수 입력값입니다."),
REQUIRED_FILE(BAD_REQUEST, "파일이 비어 있습니다.")
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
import org.example.backend.board.repository.BoardRepository;
import org.example.backend.global.config.aws.S3Uploader;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
Expand Down Expand Up @@ -47,6 +45,9 @@ private void validateUserRequiredFields(BoardReqDto dto) {
if (dto.getContent() == null || dto.getContent().isEmpty()) {
throw new BoardException(BoardExceptionType.REQUIRED_CONTENT);
}
if (dto.getCategory() == null || dto.getCategory().isEmpty() || !Category.contains(dto.getCategory())) {
throw new BoardException(BoardExceptionType.REQUIRED_CATEGORY);
}
}

public BoardResDto getBoard(Long boardId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,23 @@ public class ProfessorReqDto {
@Schema(description = "교수 연구실 위치", example = "충무관 1128호")
private String lab;

@Schema(description = "교수 프로필 이미지", example = "https://www.sju.ac.kr/professor/example/profile.jpg")
@Schema(hidden = true)
private String profileImage;

@Builder
private ProfessorReqDto(String name, String major, String phoneN, String email,
String position, String homepage, String lab, String profileImage) {
String position, String homepage, String lab) {
this.name = name;
this.major = major;
this.phoneN = phoneN;
this.email = email;
this.position = position;
this.homepage = homepage;
this.lab = lab;
this.profileImage = profileImage;
}

public static ProfessorReqDto of(String name, String major, String phoneN, String email,
String position, String homepage, String lab, String profileImage) {
String position, String homepage, String lab) {
return ProfessorReqDto.builder()
.name(name)
.major(major)
Expand All @@ -57,7 +56,6 @@ public static ProfessorReqDto of(String name, String major, String phoneN, Strin
.position(position)
.homepage(homepage)
.lab(lab)
.profileImage(profileImage)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.example.backend.thesis.domain.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -13,6 +14,7 @@ public class ThesisReqDto {
private String content;
private String link;
private String publicationDate;
@Schema(hidden = true)
private String thesisImage;
private String publicationCollection;
private String publicationIssue;
Expand All @@ -22,14 +24,13 @@ public class ThesisReqDto {

@Builder
private ThesisReqDto(String author, String journal, String content, String link,
String publicationDate, String thesisImage, String publicationCollection,
String publicationDate, String publicationCollection,
String publicationIssue, String publicationPage, String issn, Long professorId) {
this.author = author;
this.journal = journal;
this.content = content;
this.link = link;
this.publicationDate = publicationDate;
this.thesisImage = thesisImage;
this.publicationCollection = publicationCollection;
this.publicationIssue = publicationIssue;
this.publicationPage = publicationPage;
Expand All @@ -38,15 +39,14 @@ private ThesisReqDto(String author, String journal, String content, String link,
}

public static ThesisReqDto of(String author, String journal, String content, String link,
String publicationDate, String thesisImage, String publicationCollection,
String publicationDate, String publicationCollection,
String publicationIssue, String publicationPage, String issn, Long professorId) {
return ThesisReqDto.builder()
.author(author)
.journal(journal)
.content(content)
.link(link)
.publicationDate(publicationDate)
.thesisImage(thesisImage)
.publicationCollection(publicationCollection)
.publicationIssue(publicationIssue)
.publicationPage(publicationPage)
Expand Down

0 comments on commit 611daa2

Please sign in to comment.