From a595bdc436a8ae22ca279e263d0972d5d984ce4e Mon Sep 17 00:00:00 2001 From: "2jin2.1031" <2jin2.1031@gmail.com> Date: Sat, 7 Dec 2024 21:41:06 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=85=BC=EB=AC=B8=EC=97=90=20=EC=A0=9C?= =?UTF-8?q?=EB=AA=A9=20=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/backend/thesis/domain/dto/ThesisReqDto.java | 7 +++++-- .../org/example/backend/thesis/domain/entity/Thesis.java | 8 +++++++- .../backend/thesis/exception/ThesisExceptionType.java | 2 +- .../org/example/backend/thesis/service/ThesisService.java | 3 +++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/org/example/backend/thesis/domain/dto/ThesisReqDto.java b/backend/src/main/java/org/example/backend/thesis/domain/dto/ThesisReqDto.java index 6b2cbf53..cd710807 100644 --- a/backend/src/main/java/org/example/backend/thesis/domain/dto/ThesisReqDto.java +++ b/backend/src/main/java/org/example/backend/thesis/domain/dto/ThesisReqDto.java @@ -9,6 +9,7 @@ @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class ThesisReqDto { + private String title; private String author; private String journal; private String content; @@ -23,9 +24,10 @@ public class ThesisReqDto { private Long professorId; @Builder - private ThesisReqDto(String author, String journal, String content, String link, + private ThesisReqDto(String title, String author, String journal, String content, String link, String publicationDate, String publicationCollection, String publicationIssue, String publicationPage, String issn, Long professorId) { + this.title = title; this.author = author; this.journal = journal; this.content = content; @@ -38,10 +40,11 @@ private ThesisReqDto(String author, String journal, String content, String link, this.professorId = professorId; } - public static ThesisReqDto of(String author, String journal, String content, String link, + public static ThesisReqDto of(String title, String author, String journal, String content, String link, String publicationDate, String publicationCollection, String publicationIssue, String publicationPage, String issn, Long professorId) { return ThesisReqDto.builder() + .title(title) .author(author) .journal(journal) .content(content) diff --git a/backend/src/main/java/org/example/backend/thesis/domain/entity/Thesis.java b/backend/src/main/java/org/example/backend/thesis/domain/entity/Thesis.java index 93868edd..66b5ffd7 100644 --- a/backend/src/main/java/org/example/backend/thesis/domain/entity/Thesis.java +++ b/backend/src/main/java/org/example/backend/thesis/domain/entity/Thesis.java @@ -18,6 +18,9 @@ public class Thesis { @Column(name = "thesis_id", nullable = false) private Long id; + @Column(name = "title") + private String title; + @Column(name = "author") private String author; @@ -53,9 +56,10 @@ public class Thesis { private Professor professor; @Builder - private Thesis(String author, String journal, String content, String link, + private Thesis(String title, String author, String journal, String content, String link, String publicationDate, String thesisImage, String publicationCollection, String publicationIssue, String publicationPage, String issn, Professor professor) { + this.title = title; this.author = author; this.journal = journal; this.content = content; @@ -71,6 +75,7 @@ private Thesis(String author, String journal, String content, String link, public static Thesis of(ThesisReqDto dto, Professor professor) { return Thesis.builder() + .title(dto.getTitle()) .author(dto.getAuthor()) .journal(dto.getJournal()) .content(dto.getContent()) @@ -86,6 +91,7 @@ public static Thesis of(ThesisReqDto dto, Professor professor) { } public void update(ThesisReqDto dto, Professor professor) { + this.title = dto.getTitle(); this.author = dto.getAuthor(); this.journal = dto.getJournal(); this.content = dto.getContent(); diff --git a/backend/src/main/java/org/example/backend/thesis/exception/ThesisExceptionType.java b/backend/src/main/java/org/example/backend/thesis/exception/ThesisExceptionType.java index 8ef6efd3..de16fb39 100644 --- a/backend/src/main/java/org/example/backend/thesis/exception/ThesisExceptionType.java +++ b/backend/src/main/java/org/example/backend/thesis/exception/ThesisExceptionType.java @@ -13,7 +13,7 @@ public enum ThesisExceptionType implements BaseExceptionType { NOT_FOUND_THESIS(NOT_FOUND, "논문를 찾을 수 없습니다"), REQUIRED_AUTHOR(BAD_REQUEST, "저자는 필수 입력값입니다."), - ; + REQUIRED_TITLE(BAD_REQUEST, "제목은 필수 입력값입니다"); private final HttpStatus httpStatus; private final String errorMessage; diff --git a/backend/src/main/java/org/example/backend/thesis/service/ThesisService.java b/backend/src/main/java/org/example/backend/thesis/service/ThesisService.java index f9225c28..11a3c432 100644 --- a/backend/src/main/java/org/example/backend/thesis/service/ThesisService.java +++ b/backend/src/main/java/org/example/backend/thesis/service/ThesisService.java @@ -46,6 +46,9 @@ public Long saveThesis(ThesisReqDto thesisReqDto, MultipartFile multipartFile) { } private void validateUserRequiredFields(ThesisReqDto dto) { + if (dto.getTitle() == null || dto.getTitle().isEmpty()) { + throw new ThesisException(ThesisExceptionType.REQUIRED_TITLE); + } if (dto.getAuthor() == null || dto.getAuthor().isEmpty()) { throw new ThesisException(ThesisExceptionType.REQUIRED_AUTHOR); }