Skip to content

Commit

Permalink
Merge pull request #8 from gutanbug/fix/lineup
Browse files Browse the repository at this point in the history
fix : 라인업 무대 공연 날짜 LocalDateTime으로 변경
  • Loading branch information
gutanbug authored Apr 8, 2024
2 parents 7a4963b + 271b2ed commit f93b31b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class RequestCreateLineUpDto {
@Schema(description = "설명", example = "아이유의 공연입니다.")
private final String description;

@Schema(description = "공연 날짜", example = "2024-05-20")
@Schema(description = "공연 날짜", example = "2024-05-20 18:00")
private final String performanceDate;

@Schema(description = "축제 일자", example = "FIRST_DAY")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lombok.RequiredArgsConstructor;

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

@Getter
Expand All @@ -23,7 +24,7 @@ public class ResponseLineUpDto {

private final String description;

private final LocalDate performanceTime;
private final LocalDateTime performanceTime;

private final FestivalDate festivalDate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public class LineUp extends BaseEntity {
@Lob
private String description;

private LocalDate performanceTime;
private LocalDateTime performanceTime;

@Enumerated(EnumType.STRING)
private FestivalDate festivalDate;

private boolean isOpened;

@Builder
private LineUp(String singer, String description, LocalDate performanceTime, FestivalDate festivalDate, boolean isOpened) {
private LineUp(String singer, String description, LocalDateTime performanceTime, FestivalDate festivalDate, boolean isOpened) {
this.singer = singer;
this.description = description;
this.performanceTime = performanceTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.springframework.web.multipart.MultipartFile;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -47,7 +49,7 @@ public Long createLineUp(RequestCreateLineUpDto dto, Long userId) {
LineUp lineUp = LineUp.builder()
.singer(dto.getSinger())
.description(dto.getDescription())
.performanceTime(convertToLocalDate(dto.getPerformanceDate()))
.performanceTime(convertToLocalDateTime(dto.getPerformanceDate()))
.festivalDate(dto.getFestivalDate())
.isOpened(false)
.build();
Expand All @@ -57,6 +59,11 @@ public Long createLineUp(RequestCreateLineUpDto dto, Long userId) {
return result.getId();
}

private LocalDateTime convertToLocalDateTime(String performanceDate) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
return LocalDateTime.parse(performanceDate, formatter);
}

private void addLineUpImages(LineUp lineUp, List<MultipartFile> dtoImages) {
List<UploadedImage> images = imageUploadService.newContext().uploadImages(
ImageRequest.ofList(dtoImages),
Expand All @@ -78,11 +85,6 @@ private void addLineUpImages(LineUp lineUp, List<MultipartFile> dtoImages) {
}
}

private LocalDate convertToLocalDate(String performanceDate) {
String[] split = performanceDate.split("-");
return LocalDate.of(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]));
}

@Transactional(readOnly = true)
public List<ResponseLineUpDto> list(FestivalDate festivalDate) {
Specification<LineUp> spec = LineUpSpec.withFestivalDate(festivalDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class LineUpControllerTest extends AbstractContainerRedisTest {
void setup() {
lineUpRepository.deleteAll();

notOpenedList = LineUpMock.createList("singer", 3, 2024, 5, 20, FestivalDate.FIRST_DAY, false);
openedList = LineUpMock.createList("singer", 3, 2024, 5, 21, FestivalDate.SECOND_DAY, true);
notOpenedList = LineUpMock.createList("singer", 3, 2024, 5, 20, 18,0, FestivalDate.FIRST_DAY, false);
openedList = LineUpMock.createList("singer", 3, 2024, 5, 21, 18, 0, FestivalDate.SECOND_DAY, true);
lineUpRepository.saveAll(notOpenedList);
lineUpRepository.saveAll(openedList);
}
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/com/dku/council/mock/LineUpMock.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
import com.dku.council.domain.danfesta.model.entity.LineUp;

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

public class LineUpMock {

public static List<LineUp> createList(String prefix, int size, int year, int month, int dayOfMonth, FestivalDate festivalDate, boolean isOpened) {
public static List<LineUp> createList(String prefix, int size, int year, int month, int dayOfMonth, int hour, int minute, FestivalDate festivalDate, boolean isOpened) {
List<LineUp> result = new ArrayList<>();
for (int i = 0; i < size; i++) {
LineUp lineUp = LineUp.builder()
.singer(prefix + i)
.description(prefix + i + " description")
.performanceTime(LocalDate.of(year, month, dayOfMonth))
.performanceTime(LocalDateTime.of(year, month, dayOfMonth, hour, minute))
.festivalDate(festivalDate)
.isOpened(isOpened)
.build();
Expand All @@ -27,6 +28,6 @@ public static List<LineUp> createList(String prefix, int size, int year, int mon

public static ResponseLineUpDto createDummyDto(Long id, FestivalDate festivalDate, boolean isOpened) {
return new ResponseLineUpDto(id, "singer", new ArrayList<>(), "description",
LocalDate.of(2021, 1, 1), festivalDate, isOpened);
LocalDateTime.of(2021,1,1,12,0), festivalDate, isOpened);
}
}

0 comments on commit f93b31b

Please sign in to comment.