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); }