Skip to content

Commit

Permalink
feat: 논문에 제목 필드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
2Jin1031 committed Dec 7, 2024
1 parent 611daa2 commit a595bdc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ThesisReqDto {
private String title;
private String author;
private String journal;
private String content;
Expand All @@ -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;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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())
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit a595bdc

Please sign in to comment.