Skip to content

Commit

Permalink
[refactor/Inhabas#273] 공모전 게시판 시작일 및 종료일 LocalDateTime으로 변경
Browse files Browse the repository at this point in the history
[refactor/Inhabas#273] 공모전 게시판 시작일 및 종료일 LocalDateTime으로 변경
  • Loading branch information
whitem4rk authored Mar 31, 2024
2 parents 4a78f55 + 082e010 commit 1699f70
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.inhabas.api.domain.contest.domain;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -52,10 +52,10 @@ public class ContestBoard extends BaseBoard {
@Embedded private Content content;

@Column(name = "DATE_CONTEST_START", nullable = false)
private LocalDate dateContestStart;
private LocalDateTime dateContestStart;

@Column(name = "DATE_CONTEST_END", nullable = false)
private LocalDate dateContestEnd;
private LocalDateTime dateContestEnd;

@OneToMany(mappedBy = "parentBoard", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Comment> comments = new ArrayList<>();
Expand All @@ -69,8 +69,8 @@ public ContestBoard(
String content,
String association,
String topic,
LocalDate dateContestStart,
LocalDate dateContestEnd) {
LocalDateTime dateContestStart,
LocalDateTime dateContestEnd) {

super(title, menu);
this.contestField = contestField;
Expand Down Expand Up @@ -108,8 +108,8 @@ public void updateContest(
String content,
String association,
String topic,
LocalDate dateContestStart,
LocalDate dateContestEnd) {
LocalDateTime dateContestStart,
LocalDateTime dateContestEnd) {

this.contestField = contestField;
this.title = new Title(title);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.inhabas.api.domain.contest.dto;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

Expand Down Expand Up @@ -41,11 +40,15 @@ public class ContestBoardDetailDto {

private List<FileDownloadDto> otherFiles;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate dateContestStart;
@NotNull
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Schema(type = "string", example = "2024-11-01T00:00:00")
private LocalDateTime dateContestStart;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate dateContestEnd;
@NotNull
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Schema(type = "string", example = "2024-11-01T00:00:00")
private LocalDateTime dateContestEnd;

@NotNull
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
Expand All @@ -66,8 +69,8 @@ public ContestBoardDetailDto(
String writerName,
String association,
String topic,
LocalDate dateContestStart,
LocalDate dateContestEnd,
LocalDateTime dateContestStart,
LocalDateTime dateContestEnd,
LocalDateTime dateCreated,
LocalDateTime dateUpdated,
FileDownloadDto thumbnail,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.inhabas.api.domain.contest.dto;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

import lombok.Builder;
Expand All @@ -10,6 +11,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.inhabas.api.domain.file.dto.FileDownloadDto;
import io.swagger.v3.oas.annotations.media.Schema;

// 공모전 게시판 전체 조회
@Getter
Expand All @@ -22,11 +24,13 @@ public class ContestBoardDto {
private String topic;
private String association;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate dateContestStart;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Schema(type = "string", example = "2024-11-01T00:00:00")
private LocalDateTime dateContestStart;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate dateContestEnd;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Schema(type = "string", example = "2024-11-01T00:00:00")
private LocalDateTime dateContestEnd;

@JsonProperty("D-day")
private long dDay;
Expand All @@ -40,8 +44,8 @@ public ContestBoardDto(
String title,
String topic,
String association,
LocalDate dateContestStart,
LocalDate dateContestEnd,
LocalDateTime dateContestStart,
LocalDateTime dateContestEnd,
FileDownloadDto thumbnail) {
this.id = id;
this.contestFieldId = contestFieldId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.inhabas.api.domain.contest.dto;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -12,6 +12,8 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import org.hibernate.validator.constraints.Length;

// 공모전 게시판 글 업데이트 및 저장
Expand All @@ -38,11 +40,15 @@ public class SaveContestBoardDto {
private String topic;

@NotNull(message = "공모전 모집 시작일을 등록해주세요.")
private LocalDate dateContestStart;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Schema(type = "string", example = "2024-11-01T00:00:00")
private LocalDateTime dateContestStart;

@NotNull(message = "공모전 모집 마감일을 등록해주세요.")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Schema(type = "string", example = "2024-11-01T00:00:00")
@Future(message = "이미 모집기간이 종료된 공모전은 등록할 수 없습니다.")
private LocalDate dateContestEnd;
private LocalDateTime dateContestEnd;

private List<String> files = new ArrayList<>();

Expand All @@ -53,8 +59,8 @@ public SaveContestBoardDto(
String content,
String association,
String topic,
LocalDate dateContestStart,
LocalDate dateContestEnd,
LocalDateTime dateContestStart,
LocalDateTime dateContestEnd,
List<String> files) {

this.contestFieldId = contestFieldId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.inhabas.api.domain.contest.domain;

import java.time.LocalDate;
import java.time.LocalDateTime;

import org.springframework.test.util.ReflectionTestUtils;

Expand All @@ -16,8 +16,8 @@ public static ContestBoard getBoard1(Menu menu, ContestField contestField) {
.content("테스트 내용1")
.association("(주) 아이바스1")
.topic("테스트 주제1")
.dateContestStart(LocalDate.now())
.dateContestEnd(LocalDate.now().plusDays(10))
.dateContestStart(LocalDateTime.now())
.dateContestEnd(LocalDateTime.now().plusDays(10))
.build();
return contestBoard;
}
Expand All @@ -31,8 +31,8 @@ public static ContestBoard getBoard2(Menu menu, ContestField contestField) {
.content("테스트 내용2")
.association("(주) 아이바스2")
.topic("테스트 주제2")
.dateContestStart(LocalDate.now())
.dateContestEnd(LocalDate.now().plusDays(10))
.dateContestStart(LocalDateTime.now())
.dateContestEnd(LocalDateTime.now().plusDays(10))
.build();
return contestBoard;
}
Expand All @@ -46,8 +46,8 @@ public static ContestBoard getBoard3(Menu menu, ContestField contestField) {
.content("테스트 내용3")
.association("(주) 아이바스3")
.topic("테스트 주제3")
.dateContestStart(LocalDate.now())
.dateContestEnd(LocalDate.now().plusDays(10))
.dateContestStart(LocalDateTime.now())
.dateContestEnd(LocalDateTime.now().plusDays(10))
.build();
return contestBoard;
}
Expand All @@ -62,8 +62,8 @@ public static ContestBoard getTestBoard(Integer id, Menu menu, ContestField cont
.content("테스트 내용1")
.association("(주) 아이바스1")
.topic("테스트 주제1")
.dateContestStart(LocalDate.now())
.dateContestEnd(LocalDate.now().plusDays(10))
.dateContestStart(LocalDateTime.now())
.dateContestEnd(LocalDateTime.now().plusDays(10))
.build();
ReflectionTestUtils.setField(contestBoard, "id", id);
return contestBoard;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -36,8 +36,8 @@ void setUp() {
String content = "테스트 내용";
String association = "테스트 협회";
String topic = "테스트 주제";
LocalDate dateContestStart = LocalDate.of(2023, 1, 1);
LocalDate dateContestEnd = LocalDate.of(2023, 12, 31);
LocalDateTime dateContestStart = LocalDateTime.of(2023, 1, 1, 0, 0, 0);
LocalDateTime dateContestEnd = LocalDateTime.of(2023, 12, 31, 0, 0, 0);

when(contestField.getId()).thenReturn(contestFieldId);

Expand All @@ -63,8 +63,8 @@ void createContestBoardTest() {
assertThat(contestBoard.getContent()).isEqualTo("테스트 내용");
assertThat(contestBoard.getAssociation()).isEqualTo("테스트 협회");
assertThat(contestBoard.getTopic()).isEqualTo("테스트 주제");
assertThat(contestBoard.getDateContestStart()).isEqualTo(LocalDate.of(2023, 1, 1));
assertThat(contestBoard.getDateContestEnd()).isEqualTo(LocalDate.of(2023, 12, 31));
assertThat(contestBoard.getDateContestStart()).isEqualTo(LocalDateTime.of(2023, 1, 1, 0, 0, 0));
assertThat(contestBoard.getDateContestEnd()).isEqualTo(LocalDateTime.of(2023, 12, 31, 0, 0, 0));
}

@Test
Expand All @@ -78,8 +78,8 @@ void updateContestBoardTest() {
String newContent = "새로운 내용";
String newAssociation = "새로운 협회";
String newTopic = "새로운 주제";
LocalDate newDateContestStart = LocalDate.now();
LocalDate newDateContestEnd = LocalDate.now().plusDays(30);
LocalDateTime newDateContestStart = LocalDateTime.now();
LocalDateTime newDateContestEnd = LocalDateTime.now().plusDays(30);

ContestField newContestField = new ContestField("새로운 분야");
ReflectionTestUtils.setField(newContestField, "id", newContestFieldId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Set;
Expand Down Expand Up @@ -48,8 +47,8 @@ public void createContestBoardDetailDto() {
.writerName("송민석")
.association("(주) 아이바스")
.topic("테스트 주제")
.dateContestStart(LocalDate.now())
.dateContestEnd(LocalDate.now().plusDays(10))
.dateContestStart(LocalDateTime.now())
.dateContestEnd(LocalDateTime.now().plusDays(10))
.dateCreated(LocalDateTime.now())
.dateUpdated(LocalDateTime.now())
.thumbnail(
Expand Down Expand Up @@ -79,8 +78,8 @@ public void nullTitleTest() {
.writerName("송민석")
.association("(주) 아이바스")
.topic("테스트 주제")
.dateContestStart(LocalDate.now())
.dateContestEnd(LocalDate.now().plusDays(10))
.dateContestStart(LocalDateTime.now())
.dateContestEnd(LocalDateTime.now().plusDays(10))
.dateCreated(LocalDateTime.now())
.dateUpdated(LocalDateTime.now())
.thumbnail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.assertj.core.api.Assertions.assertThat;

import java.time.LocalDate;
import java.time.LocalDateTime;

import com.inhabas.api.domain.file.dto.FileDownloadDto;

Expand All @@ -21,8 +22,8 @@ public void createContestBoardDto() {
String title = "테스트 제목";
String topic = "테스트 주제";
String association = "테스트 협회";
LocalDate dateContestStart = LocalDate.of(2024, 1, 1);
LocalDate dateContestEnd = LocalDate.of(2024, 3, 1);
LocalDateTime dateContestStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0);
LocalDateTime dateContestEnd = LocalDateTime.of(2024, 3, 1, 0, 0, 0);
FileDownloadDto thumbnail =
new FileDownloadDto("random", "thumbnail.jpg", "/thumbnailUrl", 10L, "image/jpeg");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.inhabas.api.domain.contest.dto;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -93,8 +93,8 @@ public void InputsAreExceededError() {
"content! Cucumber paste has to have a sun-dried, chilled sauerkraut component.",
"Assoc".repeat(20) + ".",
"topic".repeat(100) + ".",
LocalDate.of(2022, 1, 1),
LocalDate.of(9999, 3, 3),
LocalDateTime.of(2022, 1, 1, 0, 0, 0),
LocalDateTime.of(9999, 3, 3, 0, 0, 0),
null);

// when
Expand All @@ -121,8 +121,8 @@ public void DeadlineIsOutdatedError() {
"content",
"association",
"topic",
LocalDate.of(2022, 1, 1),
LocalDate.of(2022, 2, 1),
LocalDateTime.of(2022, 1, 1, 0, 0, 0),
LocalDateTime.of(2022, 2, 1, 0, 0, 0),
null);

// when
Expand Down
Loading

0 comments on commit 1699f70

Please sign in to comment.