From ad0292ec46aacf08638f84f90ef41adc088c7a55 Mon Sep 17 00:00:00 2001 From: capDoYeonLee Date: Fri, 6 Dec 2024 13:30:32 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=ED=95=84=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/demo/filter/persistence/FilterEntity.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/BE/error/src/main/java/com/example/demo/filter/persistence/FilterEntity.java b/BE/error/src/main/java/com/example/demo/filter/persistence/FilterEntity.java index 1fa198f..34ad7cf 100644 --- a/BE/error/src/main/java/com/example/demo/filter/persistence/FilterEntity.java +++ b/BE/error/src/main/java/com/example/demo/filter/persistence/FilterEntity.java @@ -29,10 +29,6 @@ public class FilterEntity extends BaseEntity { @Column(nullable = false) private String filterColor; -// @OneToOne(fetch = FetchType.LAZY) -// @JoinColumn(name = "member_id") -// private MemberEntity member; - @Column(nullable = false) private Long memberId; } From 7a7aeeccdcc666adf4d3ff1af030d1968a4c957d Mon Sep 17 00:00:00 2001 From: capDoYeonLee Date: Fri, 6 Dec 2024 13:31:23 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=ED=95=9C=20=ED=95=99=EA=B8=B0=20?= =?UTF-8?q?=EC=9D=BC=EC=A0=95=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/service/ScheduleService.java | 6 ++++ .../converter/ScheduleResponseConverter.java | 15 +++++++++ .../persistence/ScheduleJpaRepository.java | 33 +++++++++++++++++++ .../presentation/ScheduleController.java | 6 ++++ 4 files changed, 60 insertions(+) diff --git a/BE/error/src/main/java/com/example/demo/schedule/application/service/ScheduleService.java b/BE/error/src/main/java/com/example/demo/schedule/application/service/ScheduleService.java index 788e3f5..d7d99ae 100644 --- a/BE/error/src/main/java/com/example/demo/schedule/application/service/ScheduleService.java +++ b/BE/error/src/main/java/com/example/demo/schedule/application/service/ScheduleService.java @@ -73,6 +73,12 @@ public List getPrivateSchedule() { return responseConverter.toPrivateModel(model); } + public List getSemesterSchedule() { + LocalDateTime requestNow = LocalDateTime.now(); + List semesterScheduleResponses = scheduleJpaRepository.findOneSemesterPublicSchedule(requestNow); + return responseConverter.toSemesterScheduleResponse(semesterScheduleResponses); + } + public List findWeekendSchedule() { diff --git a/BE/error/src/main/java/com/example/demo/schedule/domain/model/converter/ScheduleResponseConverter.java b/BE/error/src/main/java/com/example/demo/schedule/domain/model/converter/ScheduleResponseConverter.java index 5f4a401..59ad1e4 100644 --- a/BE/error/src/main/java/com/example/demo/schedule/domain/model/converter/ScheduleResponseConverter.java +++ b/BE/error/src/main/java/com/example/demo/schedule/domain/model/converter/ScheduleResponseConverter.java @@ -3,6 +3,7 @@ import com.example.demo.filter.persistence.FilterRepository; import com.example.demo.schedule.application.dto.*; import com.example.demo.schedule.domain.model.ScheduleModel; +import com.example.demo.schedule.infrastructure.persistence.ScheduleEntity; import org.springframework.stereotype.Component; import java.time.LocalDateTime; @@ -64,6 +65,20 @@ private AllPublicCalendarResponse toPublicCalendarResponse(ScheduleModel model) .build(); } + public List toSemesterScheduleResponse(List entities) { + return entities.stream() + .map(this::buildSemesterResponse) + .collect(Collectors.toList()); + } + + private SemesterScheduleResponse buildSemesterResponse(ScheduleEntity entity) { + return SemesterScheduleResponse.builder() + .eventName(entity.getEventName()) + .eventStartDate(entity.getEventStartDate().toString()) + .eventEndDate(entity.getEventEndDate().toString()) + .build(); + } + public List toPrivateModel(List models) { return models.stream() diff --git a/BE/error/src/main/java/com/example/demo/schedule/infrastructure/persistence/ScheduleJpaRepository.java b/BE/error/src/main/java/com/example/demo/schedule/infrastructure/persistence/ScheduleJpaRepository.java index 26e1b92..f7de841 100644 --- a/BE/error/src/main/java/com/example/demo/schedule/infrastructure/persistence/ScheduleJpaRepository.java +++ b/BE/error/src/main/java/com/example/demo/schedule/infrastructure/persistence/ScheduleJpaRepository.java @@ -3,6 +3,7 @@ import com.example.demo.filter.persistence.FilterEntity; import com.example.demo.schedule.domain.ScheduleRepository; import jakarta.persistence.EntityManager; +import jakarta.persistence.TypedQuery; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @@ -32,6 +33,38 @@ public ScheduleEntity save(ScheduleEntity entity) { } } + public List findOneSemesterPublicSchedule(LocalDateTime requestDate) { + int month = requestDate.getMonthValue(); + int year = requestDate.getYear(); + + LocalDateTime startDate; + LocalDateTime endDate; + + if (month >= 2 && month <= 7) { + // 2월 ~ 7월 + startDate = LocalDateTime.of(year, 2, 1, 0, 0); + endDate = LocalDateTime.of(year, 7, 31, 23, 59, 59); + } else if (month >= 8 && month <= 12) { + // 8월 ~ 다음해 1월 + startDate = LocalDateTime.of(year, 8, 1, 0, 0); + endDate = LocalDateTime.of(year + 1, 1, 31, 23, 59, 59); + } else { // month == 1 + // 전년도 8월 ~ 해당 연도 1월 + startDate = LocalDateTime.of(year - 1, 8, 1, 0, 0); + endDate = LocalDateTime.of(year, 1, 31, 23, 59, 59); + } + + String jpql = "SELECT s FROM ScheduleEntity s " + + "WHERE s.eventStartDate BETWEEN :startDate AND :endDate"; + + TypedQuery query = em.createQuery(jpql, ScheduleEntity.class); + query.setParameter("startDate", startDate); + query.setParameter("endDate", endDate); + + return query.getResultList(); + } + + public List findWeekPublic(LocalDateTime startDate, LocalDateTime endDate) { diff --git a/BE/error/src/main/java/com/example/demo/schedule/presentation/ScheduleController.java b/BE/error/src/main/java/com/example/demo/schedule/presentation/ScheduleController.java index 0cf23b1..30d0935 100644 --- a/BE/error/src/main/java/com/example/demo/schedule/presentation/ScheduleController.java +++ b/BE/error/src/main/java/com/example/demo/schedule/presentation/ScheduleController.java @@ -74,6 +74,12 @@ public ApiResponse>> getPrivate() { return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.GETALL); } + @GetMapping("semester") + public ApiResponse>> getSemesterSchedule() { + List response = scheduleService.getSemesterSchedule(); + return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.GET); + } + @GetMapping("slack/test") @Scheduled(cron = "0 0 9 * * MON") public void sendSlackMessage() { From d5b09cf9e9ead5fa9d56e5353b956c9b19aaf74d Mon Sep 17 00:00:00 2001 From: capDoYeonLee Date: Fri, 6 Dec 2024 13:32:06 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=ED=95=9C=20=ED=95=99=EA=B8=B0=20?= =?UTF-8?q?=EC=9D=BC=EC=A0=95=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/SemesterScheduleResponse.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 BE/error/src/main/java/com/example/demo/schedule/application/dto/SemesterScheduleResponse.java diff --git a/BE/error/src/main/java/com/example/demo/schedule/application/dto/SemesterScheduleResponse.java b/BE/error/src/main/java/com/example/demo/schedule/application/dto/SemesterScheduleResponse.java new file mode 100644 index 0000000..99a4b08 --- /dev/null +++ b/BE/error/src/main/java/com/example/demo/schedule/application/dto/SemesterScheduleResponse.java @@ -0,0 +1,18 @@ +package com.example.demo.schedule.application.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class SemesterScheduleResponse { + private String eventName; + private String eventStartDate; + private String eventEndDate; +}