From ea9b4ba4ddbf756d0e591bbbf1a80c68a22fc5a2 Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 17 Nov 2025 17:46:01 +0900 Subject: [PATCH 01/13] =?UTF-8?q?feat=20:=20=ED=95=98=EC=9D=B4=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EC=84=A0=ED=83=9D=20=EC=BA=98=EB=A6=B0?= =?UTF-8?q?=EB=8D=94=20=EC=A1=B0=ED=9A=8C=20DTO=20=EA=B5=AC=ED=98=84=20#22?= =?UTF-8?q?5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/HighlightCalendarResponse.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarResponse.java diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarResponse.java b/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarResponse.java new file mode 100644 index 00000000..b17fe88b --- /dev/null +++ b/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarResponse.java @@ -0,0 +1,19 @@ +package com.midas.shootpointer.domain.highlight.dto; + +import jakarta.validation.constraints.NotNull; + +import java.time.LocalDate; +import java.util.List; + +public record HighlightCalendarResponse( + @NotNull Integer year, + @NotNull Integer month, + @NotNull List days +) { + public record CalendarDaysResponse( + @NotNull LocalDate date, + @NotNull List highlights + ){ + } +} + From a0be82e161d1f8ad17330eb1dafcf5a489638a0b Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 17 Nov 2025 20:41:11 +0900 Subject: [PATCH 02/13] =?UTF-8?q?feat=20:=20=EC=9C=A0=EC=A0=80=EC=9D=98=20?= =?UTF-8?q?=ED=95=98=EC=9D=B4=EB=9D=BC=EC=9D=B4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B5=AC=ED=98=84=20#225?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/HighlightCalendarDaysResponse.java | 13 +++++++++ .../dto/HighlightCalendarResponse.java | 8 +----- .../repository/HighlightQueryRepository.java | 27 +++++++++++++++++++ 3 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarDaysResponse.java diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarDaysResponse.java b/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarDaysResponse.java new file mode 100644 index 00000000..69651ea9 --- /dev/null +++ b/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarDaysResponse.java @@ -0,0 +1,13 @@ +package com.midas.shootpointer.domain.highlight.dto; + +import jakarta.validation.constraints.NotNull; + +import java.time.LocalDate; +import java.util.List; + +public record HighlightCalendarDaysResponse( + @NotNull LocalDate date, + @NotNull Integer count, + @NotNull List highlights +) { +} diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarResponse.java b/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarResponse.java index b17fe88b..328b3e76 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarResponse.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightCalendarResponse.java @@ -2,18 +2,12 @@ import jakarta.validation.constraints.NotNull; -import java.time.LocalDate; import java.util.List; public record HighlightCalendarResponse( @NotNull Integer year, @NotNull Integer month, - @NotNull List days + @NotNull List days ) { - public record CalendarDaysResponse( - @NotNull LocalDate date, - @NotNull List highlights - ){ - } } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java index 4fdf324e..19eac7e4 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java @@ -1,5 +1,7 @@ package com.midas.shootpointer.domain.highlight.repository; +import com.midas.shootpointer.domain.highlight.dto.HighlightCalendarDaysResponse; +import com.midas.shootpointer.domain.highlight.dto.HighlightInfoResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodHighlightResponse; import com.midas.shootpointer.domain.highlight.entity.HighlightEntity; import org.springframework.data.domain.Page; @@ -43,6 +45,9 @@ public interface HighlightQueryRepository extends JpaRepository fetchAllMembersHighlights(@Param("memberId") UUID memberId, Pageable pageable); + /** + * 기간 내에 눌린 좋아요 개수 기준으로 내림차순으로 인기 하이라이트 조회. + */ @Query(value = """ SELECT DISTINCT new com.midas.shootpointer.domain.highlight.dto.PeriodHighlightResponse @@ -69,6 +74,28 @@ public interface HighlightQueryRepository extends JpaRepository fetchPeriodHighlight(LocalDateTime startDate, LocalDateTime endDate, int limit,Pageable page); + /** + * 캘린더형 유저의 하이라이트 영상 목록 조회 + */ + @Query(value = """ + SELECT + new com.midas.shootpointer.domain.highlight.dto.HighlightInfoResponse( + h.highlightId, + h.createdAt, + (SUM (h.twoPointCount) * 2), + (SUM (h.threePointCount) * 3), + h.highlightURL + ) + FROM + HighlightEntity AS h + WHERE + h.member.memberId = :memberId + AND + h.createdAt BETWEEN :startDate AND :endDate + ORDER BY + h.createdAt DESC + """ ) + List fetchFlatHighlights(LocalDateTime startDate,LocalDateTime endDate,UUID memberId); /** * =========================== *

From cb8b5df238c2a23275009ba0b879852478973268 Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 17 Nov 2025 21:11:37 +0900 Subject: [PATCH 03/13] =?UTF-8?q?feat=20:=20=EB=85=84=20=EC=9B=94=20?= =?UTF-8?q?=EA=B8=B0=EA=B0=84=20=EB=82=B4=20=EC=83=9D=EC=84=B1=EB=90=9C=20?= =?UTF-8?q?=ED=95=98=EC=9D=B4=EB=9D=BC=EC=9D=B4=ED=8A=B8=20=EC=98=81?= =?UTF-8?q?=EC=83=81=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EB=B0=8F?= =?UTF-8?q?=20=EA=B7=B8=EB=A3=B9=ED=95=91=20=EB=B9=84=EC=A6=88=EB=8B=88?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84=20#224?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../highlight/business/HighlightManager.java | 4 ++ .../controller/HighlightQueryController.java | 6 +++ .../highlight/helper/HighlightUtil.java | 5 +++ .../highlight/helper/HighlightUtilImpl.java | 45 ++++++++++++++++++- .../repository/HighlightQueryRepository.java | 2 +- 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java b/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java index fad87548..35739593 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java @@ -118,4 +118,8 @@ public List fetchAllMembersHighlights(String period){ PeriodType convertedType=PeriodType.valueOf(period); return highlightHelper.fetchAllMembersHighlights(convertedType); } + + public HighlightCalendarResponse fetchCalendar(int year, int month) { + + } } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java b/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java index 31a61951..af24ccd8 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java @@ -1,6 +1,7 @@ package com.midas.shootpointer.domain.highlight.controller; import com.midas.shootpointer.domain.highlight.business.HighlightManager; +import com.midas.shootpointer.domain.highlight.dto.HighlightCalendarResponse; import com.midas.shootpointer.domain.highlight.dto.HighlightInfoResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodHighlightResponse; import com.midas.shootpointer.global.dto.ApiResponse; @@ -35,4 +36,9 @@ public ResponseEntity>> highlightList( public ResponseEntity>> periodHighlight(@RequestParam(value = "period")String period){ return ResponseEntity.ok(ApiResponse.ok(manager.fetchAllMembersHighlights(period))); } + + @GetMapping("/calendar") + public ResponseEntity> fetchCalendar(@RequestParam(value = "year") int year,@RequestParam(value = "month")int month){ + return ResponseEntity.ok(ApiResponse.ok(manager.fetchCalendar(year,month))); + } } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java index 945aa86b..7e4f52a1 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java @@ -1,13 +1,16 @@ package com.midas.shootpointer.domain.highlight.helper; +import com.midas.shootpointer.domain.highlight.dto.HighlightInfoResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodHighlightResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodType; import com.midas.shootpointer.domain.highlight.entity.HighlightEntity; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import java.util.Map; import java.util.UUID; public interface HighlightUtil { @@ -18,4 +21,6 @@ public interface HighlightUtil { List fetchAllMembersHighlights(PeriodType period); LocalDateTime calculateStartDate(PeriodType type,LocalDateTime now); LocalDateTime calculateEndDate(PeriodType type,LocalDateTime now); + Map> groupingHighlights(List flatHighlightList); + List fetchFlatHighlightList(int year,int month,UUID memberId); } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java index 47ba129b..4326ba4f 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java @@ -1,5 +1,6 @@ package com.midas.shootpointer.domain.highlight.helper; +import com.midas.shootpointer.domain.highlight.dto.HighlightInfoResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodHighlightResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodType; import com.midas.shootpointer.domain.highlight.entity.HighlightEntity; @@ -19,9 +20,9 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.time.DayOfWeek; +import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.List; -import java.util.UUID; +import java.util.*; @Component @Slf4j @@ -125,5 +126,45 @@ public LocalDateTime calculateEndDate(PeriodType type,LocalDateTime now) { } } + /** + * @param flatHighlightList 년 월 기간 내 생성된 하이라이트 영상 목록 + * @return LocalDate(ex. 2022-10-22T) 형태로 그룹핑 + */ + @Override + public Map> groupingHighlights(List flatHighlightList) { + Map> results=new HashMap<>(); + + for (HighlightInfoResponse response:flatHighlightList){ + //LocalDateTime -> LocalDate + LocalDate date=response.createdDate().toLocalDate(); + + //key 매핑 + results.putIfAbsent(date,new ArrayList<>()); + + //value 삽입 + results.get(date).add(response); + } + + //flatHighlightList는 오름차순으로 정렬되어 반환되므로 따로 정렬할 필요 없음. + return results; + } + + /** + * @param year 연도 + * @param month 달 + * @param memberId 멤버 ID + * @return 유저의 입력된 년 월 기간 내 생성된 하이라이트 영상 조회 + */ + @Override + public List fetchFlatHighlightList(int year, int month,UUID memberId) { + LocalDate startDate = LocalDate.of(year, month, 1); + LocalDate endDate = startDate.withDayOfMonth(startDate.lengthOfMonth()); + + LocalDateTime start = startDate.atStartOfDay(); + LocalDateTime end = endDate.atTime(23, 59, 59); + + return highlightQueryRepository.fetchFlatHighlights(start,end,memberId); + } + } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java index 19eac7e4..046c1ae7 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java @@ -93,7 +93,7 @@ public interface HighlightQueryRepository extends JpaRepository fetchFlatHighlights(LocalDateTime startDate,LocalDateTime endDate,UUID memberId); /** From 17d98c0dd631a0db28c50bd6c7b21de56cde6bac Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 17 Nov 2025 21:27:23 +0900 Subject: [PATCH 04/13] =?UTF-8?q?feat=20:=20=EC=8B=9C=EC=9E=91/=EB=A7=88?= =?UTF-8?q?=EC=A7=80=EB=A7=89=20=EC=9D=BC=20=EA=B3=84=EC=82=B0=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84=20#224?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/highlight/dto/DateTimeRange.java | 6 ++++++ .../highlight/helper/HighlightHelperImpl.java | 19 +++++++++++++++++++ .../highlight/helper/HighlightUtil.java | 2 ++ .../highlight/helper/HighlightUtilImpl.java | 10 ++++++++-- .../highlight/mapper/HighlightMapper.java | 3 +++ .../highlight/mapper/HighlightMapperImpl.java | 7 +++++++ 6 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/midas/shootpointer/domain/highlight/dto/DateTimeRange.java diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/dto/DateTimeRange.java b/src/main/java/com/midas/shootpointer/domain/highlight/dto/DateTimeRange.java new file mode 100644 index 00000000..4ca6f9c0 --- /dev/null +++ b/src/main/java/com/midas/shootpointer/domain/highlight/dto/DateTimeRange.java @@ -0,0 +1,6 @@ +package com.midas.shootpointer.domain.highlight.dto; + +import java.time.LocalDateTime; + +public record DateTimeRange(LocalDateTime start,LocalDateTime end) { +} diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java index 2d110fd0..ad51d2f8 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java @@ -1,5 +1,7 @@ package com.midas.shootpointer.domain.highlight.helper; +import com.midas.shootpointer.domain.highlight.dto.DateTimeRange; +import com.midas.shootpointer.domain.highlight.dto.HighlightInfoResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodHighlightResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodType; import com.midas.shootpointer.domain.highlight.entity.HighlightEntity; @@ -9,8 +11,10 @@ import org.springframework.stereotype.Component; import org.springframework.web.multipart.MultipartFile; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import java.util.Map; import java.util.UUID; @Component @@ -53,6 +57,21 @@ public LocalDateTime calculateEndDate(PeriodType type, LocalDateTime now) { return highlightUtil.calculateEndDate(type,now); } + @Override + public Map> groupingHighlights(List flatHighlightList) { + return Map.of(); + } + + @Override + public List fetchFlatHighlightList(int year, int month, UUID memberId) { + return List.of(); + } + + @Override + public DateTimeRange getMonthDateTimeRange(int year, int month) { + return null; + } + @Override public boolean filesExist(String directory) { return highlightValidator.filesExist(directory); diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java index 7e4f52a1..28cf0ba9 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java @@ -1,5 +1,6 @@ package com.midas.shootpointer.domain.highlight.helper; +import com.midas.shootpointer.domain.highlight.dto.DateTimeRange; import com.midas.shootpointer.domain.highlight.dto.HighlightInfoResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodHighlightResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodType; @@ -23,4 +24,5 @@ public interface HighlightUtil { LocalDateTime calculateEndDate(PeriodType type,LocalDateTime now); Map> groupingHighlights(List flatHighlightList); List fetchFlatHighlightList(int year,int month,UUID memberId); + DateTimeRange getMonthDateTimeRange(int year, int month); } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java index 4326ba4f..6366c3c0 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java @@ -1,5 +1,6 @@ package com.midas.shootpointer.domain.highlight.helper; +import com.midas.shootpointer.domain.highlight.dto.DateTimeRange; import com.midas.shootpointer.domain.highlight.dto.HighlightInfoResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodHighlightResponse; import com.midas.shootpointer.domain.highlight.dto.PeriodType; @@ -157,13 +158,18 @@ public Map> groupingHighlights(List fetchFlatHighlightList(int year, int month,UUID memberId) { + DateTimeRange range=getMonthDateTimeRange(year,month); + return highlightQueryRepository.fetchFlatHighlights(range.start(),range.end(),memberId); + } + + @Override + public DateTimeRange getMonthDateTimeRange(int year, int month) { LocalDate startDate = LocalDate.of(year, month, 1); LocalDate endDate = startDate.withDayOfMonth(startDate.lengthOfMonth()); LocalDateTime start = startDate.atStartOfDay(); LocalDateTime end = endDate.atTime(23, 59, 59); - - return highlightQueryRepository.fetchFlatHighlights(start,end,memberId); + return new DateTimeRange(start,end); } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapper.java b/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapper.java index 1ee71489..b7612f1f 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapper.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapper.java @@ -1,13 +1,16 @@ package com.midas.shootpointer.domain.highlight.mapper; +import com.midas.shootpointer.domain.highlight.dto.HighlightCalendarDaysResponse; import com.midas.shootpointer.domain.highlight.dto.HighlightInfoResponse; import com.midas.shootpointer.domain.highlight.dto.HighlightSelectResponse; import com.midas.shootpointer.domain.highlight.entity.HighlightEntity; +import java.time.LocalDate; import java.util.List; import java.util.UUID; public interface HighlightMapper { HighlightSelectResponse entityToResponse(List selectedHighlights); HighlightInfoResponse infoResponseToEntity(HighlightEntity entity); + HighlightCalendarDaysResponse flatResponseToDaysResponse(List flatHighlightsResponse, LocalDate date); } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImpl.java b/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImpl.java index 66cba5dd..64abd527 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImpl.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImpl.java @@ -1,10 +1,12 @@ package com.midas.shootpointer.domain.highlight.mapper; +import com.midas.shootpointer.domain.highlight.dto.HighlightCalendarDaysResponse; import com.midas.shootpointer.domain.highlight.dto.HighlightInfoResponse; import com.midas.shootpointer.domain.highlight.dto.HighlightSelectResponse; import com.midas.shootpointer.domain.highlight.entity.HighlightEntity; import org.springframework.stereotype.Component; +import java.time.LocalDate; import java.util.List; import java.util.UUID; @@ -23,5 +25,10 @@ public HighlightInfoResponse infoResponseToEntity(HighlightEntity entity) { return HighlightInfoResponse.of(entity.getHighlightId(),entity.getCreatedAt(),entity.totalTwoPoint(),entity.totalThreePoint(),entity.getHighlightURL()); } + @Override + public HighlightCalendarDaysResponse flatResponseToDaysResponse(List flatHighlightsResponse, LocalDate date) { + return new HighlightCalendarDaysResponse(date,flatHighlightsResponse.size(),flatHighlightsResponse); + } + } From c250ac94bbde78d2a5e2eab963f26b8098fa293b Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 17 Nov 2025 21:35:22 +0900 Subject: [PATCH 05/13] =?UTF-8?q?refact=20:=20=EB=82=A2=EC=A7=9C=20?= =?UTF-8?q?=EB=B2=94=EC=9C=84=20=EA=B3=84=EC=82=B0=20DateTimeRange=20recor?= =?UTF-8?q?d=20=EB=B0=98=ED=99=98=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20#224?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../highlight/helper/HighlightHelperImpl.java | 9 +-- .../highlight/helper/HighlightUtil.java | 3 +- .../highlight/helper/HighlightUtilImpl.java | 77 ++++++++----------- 3 files changed, 37 insertions(+), 52 deletions(-) diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java index ad51d2f8..0c6d01c0 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java @@ -48,13 +48,8 @@ public List fetchAllMembersHighlights(PeriodType period } @Override - public LocalDateTime calculateStartDate(PeriodType type, LocalDateTime now) { - return highlightUtil.calculateStartDate(type,now); - } - - @Override - public LocalDateTime calculateEndDate(PeriodType type, LocalDateTime now) { - return highlightUtil.calculateEndDate(type,now); + public DateTimeRange calculateDateTimeRange(PeriodType type, LocalDateTime now) { + return null; } @Override diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java index 28cf0ba9..56860ae3 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java @@ -20,8 +20,7 @@ public interface HighlightUtil { List savedAll(List entities); Page fetchMembersHighlights(UUID memberId, Pageable pageable); List fetchAllMembersHighlights(PeriodType period); - LocalDateTime calculateStartDate(PeriodType type,LocalDateTime now); - LocalDateTime calculateEndDate(PeriodType type,LocalDateTime now); + DateTimeRange calculateDateTimeRange(PeriodType type,LocalDateTime now); Map> groupingHighlights(List flatHighlightList); List fetchFlatHighlightList(int year,int month,UUID memberId); DateTimeRange getMonthDateTimeRange(int year, int month); diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java index 6366c3c0..03d19ca2 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java @@ -79,54 +79,13 @@ public Page fetchMembersHighlights(UUID memberId, Pageable page @Override public List fetchAllMembersHighlights(PeriodType period) { LocalDateTime now=LocalDateTime.now(); - LocalDateTime startDate=calculateStartDate(period,now); - LocalDateTime endDate=calculateEndDate(period,now); + LocalDateTime startDate=calculateDateTimeRange(period,now).start(); + LocalDateTime endDate=calculateDateTimeRange(period,now).end(); Pageable page= PageRequest.of(0,HIGHLIGHT_SIZE); return highlightQueryRepository.fetchPeriodHighlight(startDate,endDate,FETCH_SIZE,page); } - @Override - public LocalDateTime calculateStartDate(PeriodType type,LocalDateTime now) { - switch (type){ - case MONTHLY -> { - return now.withDayOfMonth(1).toLocalDate().atStartOfDay(); - } - case WEEKLY -> { - return now - .with(DayOfWeek.MONDAY) - .toLocalDate() - .atStartOfDay(); - } - case DAILY -> { - return now.toLocalDate() - .atStartOfDay(); - } - default -> throw new IllegalArgumentException("LocalDateTime 지원하지 않는 타입"); - } - } - - @Override - public LocalDateTime calculateEndDate(PeriodType type,LocalDateTime now) { - switch (type){ - case MONTHLY -> { - return now.withDayOfMonth(now.toLocalDate().lengthOfMonth()) - .toLocalDate() - .atTime(23,59,59); - } - case WEEKLY -> { - return now.with(DayOfWeek.SUNDAY) - .toLocalDate() - .atTime(23,59,59); - } - case DAILY -> { - return now.toLocalDate() - .atTime(23,59,59); - } - default -> throw new IllegalArgumentException("LocalDateTime 지원하지 않는 타입"); - } - } - /** * @param flatHighlightList 년 월 기간 내 생성된 하이라이트 영상 목록 * @return LocalDate(ex. 2022-10-22T) 형태로 그룹핑 @@ -162,6 +121,38 @@ public List fetchFlatHighlightList(int year, int month,UU return highlightQueryRepository.fetchFlatHighlights(range.start(),range.end(),memberId); } + @Override + public DateTimeRange calculateDateTimeRange(PeriodType type, LocalDateTime now) { + LocalDateTime start; + LocalDateTime end; + + switch (type){ + case MONTHLY -> { + start= now.withDayOfMonth(1).toLocalDate().atStartOfDay(); + end=now.withDayOfMonth(now.toLocalDate().lengthOfMonth()) + .toLocalDate() + .atTime(23,59,59); + } + case WEEKLY -> { + start=now + .with(DayOfWeek.MONDAY) + .toLocalDate() + .atStartOfDay(); + end=now.with(DayOfWeek.SUNDAY) + .toLocalDate() + .atTime(23,59,59); + } + case DAILY -> { + start= now.toLocalDate() + .atStartOfDay(); + end= now.toLocalDate() + .atTime(23,59,59); + } + default -> throw new IllegalArgumentException("LocalDateTime 지원하지 않는 타입"); + } + return new DateTimeRange(start,end); + } + @Override public DateTimeRange getMonthDateTimeRange(int year, int month) { LocalDate startDate = LocalDate.of(year, month, 1); From 8227be543a24c2efaa3b7e4fdda1c675920cda96 Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 17 Nov 2025 22:08:30 +0900 Subject: [PATCH 06/13] =?UTF-8?q?feat=20:=20=EB=85=84=20=EC=9B=94=20?= =?UTF-8?q?=EA=B8=B0=EA=B0=84=20=EB=82=B4=20=EC=83=9D=EC=84=B1=EB=90=9C=20?= =?UTF-8?q?=ED=95=98=EC=9D=B4=EB=9D=BC=EC=9D=B4=ED=8A=B8=20=EC=98=81?= =?UTF-8?q?=EC=83=81=20=EC=BA=98=EB=A6=B0=EB=8D=94=ED=98=95=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EB=B9=84=EC=A6=88=EB=8B=88?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84=20#224?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../highlight/business/HighlightManager.java | 24 ++++++++++++++++++- .../highlight/helper/HighlightHelperImpl.java | 17 ++++++++----- .../highlight/helper/HighlightUtil.java | 4 ++-- .../highlight/helper/HighlightUtilImpl.java | 4 ++-- .../highlight/helper/HighlightValidator.java | 1 + .../helper/HighlightValidatorImpl.java | 11 +++++++++ .../highlight/mapper/HighlightMapper.java | 3 ++- .../highlight/mapper/HighlightMapperImpl.java | 13 ++++++++-- .../shootpointer/global/common/ErrorCode.java | 2 ++ 9 files changed, 65 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java b/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java index 35739593..7b229d1b 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java @@ -18,7 +18,9 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDate; import java.util.List; +import java.util.TreeMap; import java.util.UUID; @Component @@ -119,7 +121,27 @@ public List fetchAllMembersHighlights(String period){ return highlightHelper.fetchAllMembersHighlights(convertedType); } - public HighlightCalendarResponse fetchCalendar(int year, int month) { + public HighlightCalendarResponse fetchCalendar(int year, int month,UUID memberId) { + /** + * 1. year,month 입력 값 검증 + */ + highlightHelper.isValidDateRange(year,month); + + /** + * 2.년 월 기간 내 생성된 하이라이트 영상 조회 - flat data 조회 + */ + List flatHighlightList=highlightHelper.fetchFlatHighlightList(year,month,memberId); + + /** + * 3. flat data 그룹핑한 데이터 조회 + */ + TreeMap> groupingHighlights=highlightHelper.groupingHighlights(flatHighlightList); + + /** + * 4.date와 매핑된 데이터 반환 + */ + List daysResponses=mapper.groupingHighlightToDaysResponse(groupingHighlights); + return new HighlightCalendarResponse(year,month,daysResponses); } } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java index 0c6d01c0..2e413060 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightHelperImpl.java @@ -14,7 +14,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; -import java.util.Map; +import java.util.TreeMap; import java.util.UUID; @Component @@ -49,22 +49,22 @@ public List fetchAllMembersHighlights(PeriodType period @Override public DateTimeRange calculateDateTimeRange(PeriodType type, LocalDateTime now) { - return null; + return highlightUtil.calculateDateTimeRange(type,now); } @Override - public Map> groupingHighlights(List flatHighlightList) { - return Map.of(); + public TreeMap> groupingHighlights(List flatHighlightList) { + return highlightUtil.groupingHighlights(flatHighlightList); } @Override public List fetchFlatHighlightList(int year, int month, UUID memberId) { - return List.of(); + return highlightUtil.fetchFlatHighlightList(year,month,memberId); } @Override public DateTimeRange getMonthDateTimeRange(int year, int month) { - return null; + return highlightUtil.getMonthDateTimeRange(year,month); } @Override @@ -101,4 +101,9 @@ public boolean isExistDirectory(String directory) { public void areValidFiles(List files) { highlightValidator.areValidFiles(files); } + + @Override + public void isValidDateRange(int year, int month) { + highlightValidator.isValidDateRange(year,month); + } } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java index 56860ae3..d19b9341 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtil.java @@ -11,7 +11,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; -import java.util.Map; +import java.util.TreeMap; import java.util.UUID; public interface HighlightUtil { @@ -21,7 +21,7 @@ public interface HighlightUtil { Page fetchMembersHighlights(UUID memberId, Pageable pageable); List fetchAllMembersHighlights(PeriodType period); DateTimeRange calculateDateTimeRange(PeriodType type,LocalDateTime now); - Map> groupingHighlights(List flatHighlightList); + TreeMap> groupingHighlights(List flatHighlightList); List fetchFlatHighlightList(int year,int month,UUID memberId); DateTimeRange getMonthDateTimeRange(int year, int month); } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java index 03d19ca2..4d3a1e8d 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightUtilImpl.java @@ -91,8 +91,8 @@ public List fetchAllMembersHighlights(PeriodType period * @return LocalDate(ex. 2022-10-22T) 형태로 그룹핑 */ @Override - public Map> groupingHighlights(List flatHighlightList) { - Map> results=new HashMap<>(); + public TreeMap> groupingHighlights(List flatHighlightList) { + TreeMap> results=new TreeMap<>(); for (HighlightInfoResponse response:flatHighlightList){ //LocalDateTime -> LocalDate diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightValidator.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightValidator.java index 3a7bf828..50265ecf 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightValidator.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightValidator.java @@ -13,4 +13,5 @@ public interface HighlightValidator { void isValidFileSize(MultipartFile file); boolean isExistDirectory(String directory); void areValidFiles(List files); + void isValidDateRange(int year,int month); } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightValidatorImpl.java b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightValidatorImpl.java index 13a6209f..31dc3e84 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightValidatorImpl.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/helper/HighlightValidatorImpl.java @@ -27,6 +27,11 @@ public class HighlightValidatorImpl implements HighlightValidator{ private static final long MAX_FILE_SIZE = 500L * 1024L * 1024L; private final HighlightQueryRepository highlightQueryRepository; + private static final int MAX_YEAR=2100; + private static final int MIN_YEAR=2000; + + private static final int JANUARY=1; + private static final int DECEMBER=12; @Override public boolean filesExist(String directory) { Path directoryPath= Paths.get(directory); @@ -87,4 +92,10 @@ public void areValidFiles(List files) { isValidMp4File(file); }); } + + @Override + public void isValidDateRange(int year, int month) { + if(year>MAX_YEAR || yearDECEMBER) throw new CustomException(ErrorCode.INVALID_MONTH); + } } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapper.java b/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapper.java index b7612f1f..a55bf38f 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapper.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapper.java @@ -7,10 +7,11 @@ import java.time.LocalDate; import java.util.List; +import java.util.TreeMap; import java.util.UUID; public interface HighlightMapper { HighlightSelectResponse entityToResponse(List selectedHighlights); HighlightInfoResponse infoResponseToEntity(HighlightEntity entity); - HighlightCalendarDaysResponse flatResponseToDaysResponse(List flatHighlightsResponse, LocalDate date); + List groupingHighlightToDaysResponse(TreeMap> groupingHighlights); } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImpl.java b/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImpl.java index 64abd527..50ede7a1 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImpl.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImpl.java @@ -7,7 +7,9 @@ import org.springframework.stereotype.Component; import java.time.LocalDate; +import java.util.ArrayList; import java.util.List; +import java.util.TreeMap; import java.util.UUID; @Component @@ -26,8 +28,15 @@ public HighlightInfoResponse infoResponseToEntity(HighlightEntity entity) { } @Override - public HighlightCalendarDaysResponse flatResponseToDaysResponse(List flatHighlightsResponse, LocalDate date) { - return new HighlightCalendarDaysResponse(date,flatHighlightsResponse.size(),flatHighlightsResponse); + public List groupingHighlightToDaysResponse(TreeMap> groupingHighlights) { + List calendarDaysResponses=new ArrayList<>(); + + for (LocalDate date:groupingHighlights.keySet()){ + List daysResponse=groupingHighlights.get(date); + + calendarDaysResponses.add(new HighlightCalendarDaysResponse(date,daysResponse.size(),daysResponse)); + } + return calendarDaysResponses; } diff --git a/src/main/java/com/midas/shootpointer/global/common/ErrorCode.java b/src/main/java/com/midas/shootpointer/global/common/ErrorCode.java index bc2198ce..ffe887c2 100644 --- a/src/main/java/com/midas/shootpointer/global/common/ErrorCode.java +++ b/src/main/java/com/midas/shootpointer/global/common/ErrorCode.java @@ -51,6 +51,8 @@ public enum ErrorCode { FILE_SIZE_EXCEEDED(20204,HttpStatus.BAD_REQUEST,"파일의 크기가 초과했습니다.(제한 : 200MB)"), FILE_UPLOAD_FAILED(20205,HttpStatus.BAD_REQUEST,"파일 업로드에 실패했습니다."), IMAGE_CONVERT_FAILED(20206,HttpStatus.INTERNAL_SERVER_ERROR,"이미지 파일을 변환하던 중 오류가 발생했습니다."), + INVALID_YEAR(20207,HttpStatus.BAD_REQUEST,"유효한 연도를 입력해주세요.(2000년 ~ 2100년)"), + INVALID_MONTH(20208,HttpStatus.BAD_REQUEST,"유효한 달을 입력해주세요.(1월 ~ 12월)"), //300(member - entity) part IS_AGGREGATION_TRUE(30001,HttpStatus.BAD_REQUEST,"이미 하이라이트 영상 정보 수집에 동의했습니다."), From 9f657d456daacec6b91f2d1aeddf036ca7c2c347 Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 17 Nov 2025 22:39:50 +0900 Subject: [PATCH 07/13] =?UTF-8?q?refact=20:=20highlight=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=82=A0=EC=A7=9C=20=ED=95=84=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 3 +++ .../highlight/business/HighlightManager.java | 2 +- .../controller/HighlightQueryController.java | 8 ++++++-- .../highlight/entity/HighlightEntity.java | 4 ++++ .../highlight/mapper/HighlightFactory.java | 5 ++++- .../repository/HighlightQueryRepository.java | 4 ++-- .../test/SetRealPostDataLoader.java | 11 ++++------ src/main/resources/application.yml | 20 +++++++++++++++++-- src/main/resources/logback-spring.xml | 14 +++++++++++++ 9 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 src/main/resources/logback-spring.xml diff --git a/build.gradle b/build.gradle index 3e8f5116..bfaaa354 100644 --- a/build.gradle +++ b/build.gradle @@ -98,6 +98,9 @@ dependencies { testCompileOnly 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0' + implementation 'com.github.p493cc:logback-color:1.0.3' + implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.9.0' + //redisson implementation 'org.redisson:redisson-spring-boot-starter:3.18.0' diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java b/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java index 7b229d1b..b4cf4988 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java @@ -91,7 +91,7 @@ public void saveHighlights(HighlightRequest request, UUID memberId) { /* * 2. 하이라이트 엔티티 생성 */ - List entities=factory.createHighlightEntities(request.getHighlightUrls(),request.getHighlightIdentifier(),member,backNumber); + List entities=factory.createHighlightEntities(request.getHighlightUrls(),request.getHighlightIdentifier(),member,backNumber,request.getCreatedAt()); /* 3. DB 저장 diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java b/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java index af24ccd8..eab99e13 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java @@ -38,7 +38,11 @@ public ResponseEntity>> periodHighligh } @GetMapping("/calendar") - public ResponseEntity> fetchCalendar(@RequestParam(value = "year") int year,@RequestParam(value = "month")int month){ - return ResponseEntity.ok(ApiResponse.ok(manager.fetchCalendar(year,month))); + public ResponseEntity> fetchCalendar( + @RequestParam(value = "year") int year, + @RequestParam(value = "month")int month + ){ + UUID memberId=SecurityUtils.getCurrentMemberId(); + return ResponseEntity.ok(ApiResponse.ok(manager.fetchCalendar(year,month,memberId))); } } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntity.java b/src/main/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntity.java index 5724e71f..1ae8b358 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntity.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntity.java @@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j; import org.hibernate.annotations.UuidGenerator; +import java.time.LocalDateTime; import java.util.UUID; @Entity @@ -55,6 +56,9 @@ public class HighlightEntity extends BaseEntity { @Builder.Default private Integer threePointCount=0; + @Column(name = "video_created_at") + private LocalDateTime videoCreatedAt; + /* =========== [ 도메인-행위 ] ============== */ diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightFactory.java b/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightFactory.java index d26a3bd9..95ddf587 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightFactory.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/mapper/HighlightFactory.java @@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import java.time.LocalDateTime; import java.util.List; import java.util.UUID; @@ -19,7 +20,8 @@ public class HighlightFactory { public List createHighlightEntities(List highlightInfos, UUID key, Member member, - BackNumberEntity backNumber + BackNumberEntity backNumber, + LocalDateTime createAt ){ return highlightInfos.stream() .map(info -> HighlightEntity.builder() @@ -29,6 +31,7 @@ public List createHighlightEntities(List highlig .twoPointCount(info.twoPointCount()) .threePointCount(info.threePointCount()) .backNumber(backNumber) + .videoCreatedAt(createAt) .build()) .toList(); } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java index 046c1ae7..c097f87b 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java @@ -82,8 +82,8 @@ public interface HighlightQueryRepository extends JpaRepository repositoryAll = postQueryRepository.findAllWithMemberAndHighlight(); // PostEntity → PostDocument 변환 - List docs = repositoryAll.stream() + /*List docs = repositoryAll.stream() .map(mapper::entityToDoc) .toList(); postElasticSearchRepository.saveAll(docs); - System.out.println("ES - 삽입 완료"); + System.out.println("ES - 삽입 완료");*/ } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ddcb2ec4..9e7373cc 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -16,6 +16,9 @@ jwt: refresh_expiration_time: 259200000 spring: + output: + ansi: + enabled: always jackson: serialization: write-dates-as-timestamps: false @@ -134,7 +137,9 @@ management: endpoint: health: show-details: always - + health: + elasticsearch: + enabled: false #Kakao kakao: auth: @@ -187,4 +192,15 @@ sse: ttl: 1800000 event-name: progress cache-max-size: 360 - clean-up-interval: 60000 \ No newline at end of file + clean-up-interval: 60000 + +#logging + +decorator: + datasource: + p6spy: + enable-logging: true + +p6spy: + formatting: + stdout: true diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..a0375ed1 --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,14 @@ + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + + From 2b0925241f242b88157ff30b21cdb8de3446b6ae Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 17 Nov 2025 22:53:47 +0900 Subject: [PATCH 08/13] =?UTF-8?q?refact=20:=20highlight=20video=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=20=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../highlight/business/HighlightManager.java | 30 ---------- .../command/HighlightCommandService.java | 6 -- .../command/HighlightCommandServiceImpl.java | 15 ----- .../HighlightCommandController.java | 13 ----- .../controller/HighlightQueryController.java | 9 +++ .../highlight/dto/HighlightSelectRequest.java | 11 ++-- .../repository/HighlightQueryRepository.java | 2 +- .../test/SetRealPostDataLoader.java | 30 +++++----- .../business/HighlightManagerTest.java | 38 ------------- .../HighlightCommandServiceImplTest.java | 31 ----------- .../controller/HighlightControllerTest.java | 55 ------------------- 11 files changed, 30 insertions(+), 210 deletions(-) diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java b/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java index b4cf4988..0f5475f8 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/business/HighlightManager.java @@ -33,36 +33,6 @@ public class HighlightManager { private final HighlightFactory factory; private final MemberHelper memberHelper; - /*========================== - * - *HighlightManager - * 여러개의 하이라이트 영상 중 유저가 선택하는 메서드 - * @parm request : 요청 dto memberId : 멤버 Id - * @return 선택된 하이라이트 영상 Id 리스트 - * @author kimdoyeon - * @version 1.0.0 - * @date 25. 10. 7. - * - ==========================**/ - @Transactional - @CustomLog - public HighlightSelectResponse selectHighlight(HighlightSelectRequest request, Member member){ - List selectedIds=request.getSelectedHighlightIds(); - /** - * 1. 유저가 선택 요청한 하이라이트 Id 리스트 -> 엔티티로 가져오기 - */ - List highlights = selectedIds.stream() - .map(highlightHelper::findHighlightByHighlightId) - .toList(); - - /* - * 2. 선택 수행 - */ - highlights.forEach(entity -> entity.select(member)); - - return mapper.entityToResponse(selectedIds); - } - /*========================== * *HighlightManager diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandService.java b/src/main/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandService.java index 53235cc8..a3ba3115 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandService.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandService.java @@ -1,15 +1,9 @@ package com.midas.shootpointer.domain.highlight.business.command; import com.midas.shootpointer.domain.highlight.dto.HighlightRequest; -import com.midas.shootpointer.domain.highlight.dto.HighlightSelectRequest; -import com.midas.shootpointer.domain.highlight.dto.HighlightSelectResponse; -import com.midas.shootpointer.domain.member.entity.Member; import java.util.UUID; public interface HighlightCommandService { - HighlightSelectResponse selectHighlight(HighlightSelectRequest request, Member member); - void uploadHighlights(HighlightRequest highlights, UUID memberId); } -//// \ No newline at end of file diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandServiceImpl.java b/src/main/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandServiceImpl.java index d68e5ea7..0ecbebee 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandServiceImpl.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandServiceImpl.java @@ -16,21 +16,6 @@ @Slf4j public class HighlightCommandServiceImpl implements HighlightCommandService { private final HighlightManager manager; - /*========================== - * - *HighlightCommandServiceImpl - * - * @parm HighlightSelectRequest : 하이라이트 선택 요청 Dto , token : JWT - * @return 하이라이트 선택 성공 시 선택한 하이라이트 id 반환 dto - * @author kimdoyeon - * @version 1.0.0 - * @date 6/23/25 - * - ==========================**/ - @Override - public HighlightSelectResponse selectHighlight(HighlightSelectRequest request, Member member) { - return manager.selectHighlight(request,member); - } /*========================== * diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightCommandController.java b/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightCommandController.java index 3bf8f748..2ba4c40a 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightCommandController.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightCommandController.java @@ -2,11 +2,7 @@ import com.midas.shootpointer.domain.highlight.business.command.HighlightCommandService; import com.midas.shootpointer.domain.highlight.dto.HighlightRequest; -import com.midas.shootpointer.domain.highlight.dto.HighlightSelectRequest; -import com.midas.shootpointer.domain.highlight.dto.HighlightSelectResponse; -import com.midas.shootpointer.domain.member.entity.Member; import com.midas.shootpointer.global.dto.ApiResponse; -import com.midas.shootpointer.global.security.SecurityUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; @@ -24,15 +20,6 @@ public class HighlightCommandController { private final HighlightCommandService highlightCommandService; - @PostMapping("/select") - public ResponseEntity> selectHighlight( - @RequestBody HighlightSelectRequest request - ) { - Member member = SecurityUtils.getCurrentMember(); - - return ResponseEntity.ok(ApiResponse.ok(highlightCommandService.selectHighlight(request, member))); - } - @Operation( summary = "하이라이트 URL 전송 API (OpenCV 에서 사용) - [담당자 : 김도연]", responses = { diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java b/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java index eab99e13..af481997 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/controller/HighlightQueryController.java @@ -32,11 +32,20 @@ public ResponseEntity>> highlightList( return ResponseEntity.ok(ApiResponse.ok( manager.listByPaging(page,size,memberId))); } + /** + * @param period WEEKLY : 이번 주 / MONTHLY : 이번 달 + * @return 이번 주 / 이번 달 인기 하이라이트 조회 + */ @GetMapping public ResponseEntity>> periodHighlight(@RequestParam(value = "period")String period){ return ResponseEntity.ok(ApiResponse.ok(manager.fetchAllMembersHighlights(period))); } + /** + * @param year 조회 연도 + * @param month 조회 달 + * @return 캘린더형 유저의 날짜별 하이라이트 영상 리스트 조회 + */ @GetMapping("/calendar") public ResponseEntity> fetchCalendar( @RequestParam(value = "year") int year, diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightSelectRequest.java b/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightSelectRequest.java index d3a8c061..1f9c7f26 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightSelectRequest.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/dto/HighlightSelectRequest.java @@ -1,14 +1,12 @@ package com.midas.shootpointer.domain.highlight.dto; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.Size; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; import java.util.UUID; @AllArgsConstructor @@ -18,9 +16,8 @@ @Schema(description = "하이라이트 선택 요청 DTO 입니다.") public class HighlightSelectRequest { /** - * 3가지 중 2개 선택 + * 게시물 - 3가지 중 1개 선택 */ - @NotEmpty - @Size(min = 2,max = 2,message = "하이라이트를 정확히 2개를 선택해주세요.") - private List selectedHighlightIds; + @NotNull + private UUID selectedHighlightIds; } diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java index c097f87b..0ab7dc72 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java @@ -93,7 +93,7 @@ public interface HighlightQueryRepository extends JpaRepository fetchFlatHighlights(LocalDateTime startDate,LocalDateTime endDate,UUID memberId); /** diff --git a/src/main/java/com/midas/shootpointer/test/SetRealPostDataLoader.java b/src/main/java/com/midas/shootpointer/test/SetRealPostDataLoader.java index 9216ba56..4e2aa9d6 100644 --- a/src/main/java/com/midas/shootpointer/test/SetRealPostDataLoader.java +++ b/src/main/java/com/midas/shootpointer/test/SetRealPostDataLoader.java @@ -135,6 +135,21 @@ public void run(String... args) throws Exception { for (int i = 0; i < SIZE; i++) { Member member = memberList.get(random.nextInt(memberList.size())); BackNumberEntity backNumber = memberBackNumberMap.get(member); + LocalDateTime randomDateTime; + + if (i < 20) { + //이번주 데이터 (7일 이내) + randomDateTime = LocalDateTime.now().minusDays(new Random().nextInt(7)); + } else if (i < 40) { + //이번달 데이터 (30일 이내) + randomDateTime = LocalDateTime.now().minusDays(new Random().nextInt(30)); + } else { + // 기존 3년 랜덤 데이터 + long start = threeYearsAgo.toEpochSecond(ZoneOffset.UTC); + long end = now.toEpochSecond(ZoneOffset.UTC); + long randomEpoch = start + (long) (random.nextDouble() * (end - start)); + randomDateTime = LocalDateTime.ofEpochSecond(randomEpoch, 0, ZoneOffset.UTC); + } /* Highlight 생성 */ @@ -149,6 +164,7 @@ public void run(String... args) throws Exception { .threePointCount(random.nextInt(1, 100)) .twoPointCount(random.nextInt(1, 100)) .member(member) + .videoCreatedAt(randomDateTime) .build() ); @@ -165,21 +181,7 @@ public void run(String... args) throws Exception { Long likeCnt = postData.getLikeCnt(); //게시물 id Long postId = postData.getPostId(); - LocalDateTime randomDateTime; - if (i < 20) { - //이번주 데이터 (7일 이내) - randomDateTime = LocalDateTime.now().minusDays(new Random().nextInt(7)); - } else if (i < 40) { - //이번달 데이터 (30일 이내) - randomDateTime = LocalDateTime.now().minusDays(new Random().nextInt(30)); - } else { - // 기존 3년 랜덤 데이터 - long start = threeYearsAgo.toEpochSecond(ZoneOffset.UTC); - long end = now.toEpochSecond(ZoneOffset.UTC); - long randomEpoch = start + (long) (random.nextDouble() * (end - start)); - randomDateTime = LocalDateTime.ofEpochSecond(randomEpoch, 0, ZoneOffset.UTC); - } //UTC 기준으로 하여 LocalDateTime를 long 형태로 변환. jdbcTemplate.update(sql, diff --git a/src/test/java/com/midas/shootpointer/domain/highlight/business/HighlightManagerTest.java b/src/test/java/com/midas/shootpointer/domain/highlight/business/HighlightManagerTest.java index f039e959..ce9ae553 100644 --- a/src/test/java/com/midas/shootpointer/domain/highlight/business/HighlightManagerTest.java +++ b/src/test/java/com/midas/shootpointer/domain/highlight/business/HighlightManagerTest.java @@ -1,8 +1,6 @@ package com.midas.shootpointer.domain.highlight.business; import com.midas.shootpointer.domain.highlight.dto.HighlightInfoResponse; -import com.midas.shootpointer.domain.highlight.dto.HighlightSelectRequest; -import com.midas.shootpointer.domain.highlight.dto.HighlightSelectResponse; import com.midas.shootpointer.domain.highlight.entity.HighlightEntity; import com.midas.shootpointer.domain.highlight.repository.HighlightCommandRepository; import com.midas.shootpointer.domain.member.entity.Member; @@ -20,7 +18,6 @@ import java.nio.file.Path; import java.time.LocalDateTime; -import java.util.List; import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; @@ -56,41 +53,6 @@ void cleanUp(){ repository.deleteAll(); } - @Test - @DisplayName("하이라이트 영상 객체를 호출하고 가져온 하이라이트 영상의 is_selected를 true 상태로 변환합니다.") - void selectHighlight(){ - //given - //하이라이트 영상 URL 저장 - UUID highlightKey=UUID.randomUUID(); - Member member=memberCommandRepository.save(makeMember()); - List highlightEntities=List.of( - makeHighlightEntity("url",highlightKey,member), - makeHighlightEntity("url",highlightKey,member), - makeHighlightEntity("url",highlightKey,member) - ); - highlightEntities=repository.saveAll(highlightEntities); - List selectedIds=highlightEntities.stream() - .map(HighlightEntity::getHighlightId) - .toList(); - - HighlightSelectRequest request=HighlightSelectRequest.builder() - .selectedHighlightIds(selectedIds) - .build(); - - - //when - HighlightSelectResponse response=highlightManager.selectHighlight(request,member); - - //then - assertThat(response).isNotNull(); - assertThat(response.getSelectedHighlightIds()).hasSize(3); - assertThat(response.getSelectedHighlightIds().get(0)).isEqualTo(selectedIds.get(0)); - assertThat(response.getSelectedHighlightIds().get(1)).isEqualTo(selectedIds.get(1)); - assertThat(response.getSelectedHighlightIds().get(2)).isEqualTo(selectedIds.get(2)); - - } - - @Test @DisplayName("실제 하이라이트 영상을 저장하고 엔티티를 DB에 저장한 후 DTO로 변환합니다.") void uploadHighlights(){ diff --git a/src/test/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandServiceImplTest.java b/src/test/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandServiceImplTest.java index 1f8c6f79..2201928e 100644 --- a/src/test/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandServiceImplTest.java +++ b/src/test/java/com/midas/shootpointer/domain/highlight/business/command/HighlightCommandServiceImplTest.java @@ -1,21 +1,11 @@ package com.midas.shootpointer.domain.highlight.business.command; import com.midas.shootpointer.domain.highlight.business.HighlightManager; -import com.midas.shootpointer.domain.highlight.dto.HighlightSelectRequest; -import com.midas.shootpointer.domain.member.entity.Member; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import java.util.List; -import java.util.UUID; - -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - @ExtendWith(MockitoExtension.class) class HighlightCommandServiceImplTest { @InjectMocks @@ -24,25 +14,4 @@ class HighlightCommandServiceImplTest { @Mock private HighlightManager highlightManager; - @DisplayName("manager.selectHighlight(HighlightSelectRequest, Member)가 실행되는지 검증합니다.") - @Test - void selectHighlight(){ - //given - HighlightSelectRequest request=HighlightSelectRequest.builder() - .selectedHighlightIds(List.of(UUID.randomUUID())) - .build(); - Member member=Member.builder() - .memberId(UUID.randomUUID()) - .username("test") - .email("test@naver.com") - .build(); - - //when - commandService.selectHighlight(request,member); - - //then - verify(highlightManager, times(1)).selectHighlight(request,member); - } - - } diff --git a/src/test/java/com/midas/shootpointer/domain/highlight/controller/HighlightControllerTest.java b/src/test/java/com/midas/shootpointer/domain/highlight/controller/HighlightControllerTest.java index 9f1dd914..dd4fb0fc 100644 --- a/src/test/java/com/midas/shootpointer/domain/highlight/controller/HighlightControllerTest.java +++ b/src/test/java/com/midas/shootpointer/domain/highlight/controller/HighlightControllerTest.java @@ -3,28 +3,16 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.midas.shootpointer.WithMockCustomMember; import com.midas.shootpointer.domain.highlight.business.HighlightManager; -import com.midas.shootpointer.domain.highlight.dto.HighlightSelectRequest; import com.midas.shootpointer.domain.highlight.dto.HighlightSelectResponse; -import com.midas.shootpointer.domain.member.entity.Member; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; import java.util.List; import java.util.UUID; - -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.mockito.Mockito.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @AutoConfigureMockMvc @SpringBootTest @ActiveProfiles("test") @@ -40,39 +28,6 @@ class HighlightCommandControllerTest { private HighlightManager manager; - @Test - @DisplayName("하이라이트 영상 선택 POST 요청 성공시 HighlightSelectResponse를 반환합니다._SUCCESS") - void selectHighlight() throws Exception { - //given - String url="/api/highlight/select"; - - UUID highlight1=UUID.randomUUID(); - UUID highlight2=UUID.randomUUID(); - - List uuids=List.of(highlight1,highlight2); - HighlightSelectResponse expectedResponse=mockHighlightSelectResponse(uuids); - HighlightSelectRequest request=mockHighlightSelectRequest(uuids); - - when(manager.selectHighlight(any(HighlightSelectRequest.class),any(Member.class))) - .thenReturn(expectedResponse); - - //when & then - mockMvc.perform(post(url) - .content(objectMapper.writeValueAsString(request)) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("OK")) - .andExpect(jsonPath("$.success").value(true)) - .andExpect(jsonPath("$.data.selectedHighlightIds",containsInAnyOrder( - highlight1.toString(), - highlight2.toString() - ))) - .andDo(print()); - - verify(manager).selectHighlight(any(HighlightSelectRequest.class),any(Member.class)); - } - - private HighlightSelectResponse mockHighlightSelectResponse(List uuids){ @@ -80,14 +35,4 @@ private HighlightSelectResponse mockHighlightSelectResponse(List uuids){ .selectedHighlightIds(uuids) .build(); } - - /* - * Mock HighlightSelectRequest - */ - - private HighlightSelectRequest mockHighlightSelectRequest(List uuids){ - return HighlightSelectRequest.builder() - .selectedHighlightIds(uuids) - .build(); - } } From 94da6fa4a5e68306ddd81b66dbabc86912cd7a9a Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 17 Nov 2025 22:59:19 +0900 Subject: [PATCH 09/13] =?UTF-8?q?refact=20:=20Highlight=20entity=20is=5Fse?= =?UTF-8?q?lected=20=ED=95=84=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../batch/reader/ranking/RankingReader.java | 2 - .../highlight/entity/HighlightEntity.java | 17 ---- .../repository/HighlightQueryRepository.java | 7 +- .../test/SetRealPostDataLoader.java | 1 - src/main/resources/query/ranking.sql | 1 - .../business/HighlightManagerTest.java | 1 - .../highlight/entity/HighlightEntityTest.java | 83 ------------------- .../mapper/HighlightMapperImplTest.java | 1 - .../HighlightQueryRepositoryTest.java | 1 - .../sql/CreateHighlightDummyData.sql | 2 - .../sql/VerificationHighlightData.sql | 1 - 11 files changed, 3 insertions(+), 114 deletions(-) diff --git a/src/main/java/com/midas/shootpointer/batch/reader/ranking/RankingReader.java b/src/main/java/com/midas/shootpointer/batch/reader/ranking/RankingReader.java index f27639a8..2e3d58e2 100644 --- a/src/main/java/com/midas/shootpointer/batch/reader/ranking/RankingReader.java +++ b/src/main/java/com/midas/shootpointer/batch/reader/ranking/RankingReader.java @@ -80,7 +80,6 @@ private PagingQueryProvider pagingQueryProvider(){ /** * 1. 시간 조건 - * + is_selected = true * + is_aggregation_agreed = true */ queryProvider.setSelectClause(""" @@ -103,7 +102,6 @@ private PagingQueryProvider pagingQueryProvider(){ queryProvider.setWhereClause(""" WHERE m.is_aggregation_agreed = true - AND h.is_selected = true AND h.created_at BETWEEN :begin AND :end """); diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntity.java b/src/main/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntity.java index 1ae8b358..1d1e7e8a 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntity.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntity.java @@ -2,9 +2,7 @@ import com.midas.shootpointer.domain.backnumber.entity.BackNumberEntity; import com.midas.shootpointer.domain.member.entity.Member; -import com.midas.shootpointer.global.common.ErrorCode; import com.midas.shootpointer.global.entity.BaseEntity; -import com.midas.shootpointer.global.exception.CustomException; import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; @@ -35,10 +33,6 @@ public class HighlightEntity extends BaseEntity { @Column(name = "highlight_key",nullable = false,columnDefinition = "uuid") private UUID highlightKey; - @Column(name = "is_selected") - @Builder.Default - private Boolean isSelected=false; - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "member_id",nullable = false, columnDefinition = "uuid") private Member member; @@ -62,17 +56,6 @@ public class HighlightEntity extends BaseEntity { /* =========== [ 도메인-행위 ] ============== */ - public void select(Member actor){ - //유저의 하이라이트 영상이 아닌경우 - if (!actor.getMemberId().equals(member.getMemberId())){ - throw new CustomException(ErrorCode.IS_NOT_CORRECT_MEMBERS_HIGHLIGHT_ID); - } - //이미 선택된 하이라이트 영상인 경우 - if (Boolean.TRUE.equals(this.isSelected)){ - throw new CustomException(ErrorCode.EXISTED_SELECTED); - } - this.isSelected=true; - } //2점 슛 계산 public int totalTwoPoint(){ diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java index 0ab7dc72..2e704375 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java @@ -39,7 +39,6 @@ public interface HighlightQueryRepository extends JpaRepository= ? AND h.created_at < ? ) diff --git a/src/test/java/com/midas/shootpointer/domain/highlight/business/HighlightManagerTest.java b/src/test/java/com/midas/shootpointer/domain/highlight/business/HighlightManagerTest.java index ce9ae553..f488a658 100644 --- a/src/test/java/com/midas/shootpointer/domain/highlight/business/HighlightManagerTest.java +++ b/src/test/java/com/midas/shootpointer/domain/highlight/business/HighlightManagerTest.java @@ -75,7 +75,6 @@ void listByPagingHighlights(){ HighlightEntity entity=HighlightEntity.builder() .highlightKey(UUID.randomUUID()) .highlightURL("https://cdn.example.com/video" + i + ".mp4") - .isSelected(true) .member(member) .build(); entity.setCreatedAt(LocalDateTime.now().minusDays(i)); diff --git a/src/test/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntityTest.java b/src/test/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntityTest.java index 8ab38dee..5b1cd287 100644 --- a/src/test/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntityTest.java +++ b/src/test/java/com/midas/shootpointer/domain/highlight/entity/HighlightEntityTest.java @@ -1,97 +1,14 @@ package com.midas.shootpointer.domain.highlight.entity; import com.midas.shootpointer.domain.member.entity.Member; -import com.midas.shootpointer.global.common.ErrorCode; -import com.midas.shootpointer.global.exception.CustomException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; class HighlightEntityTest { - @Test - @DisplayName("유저의 하이라이트 영상이 아닌 경우 IS_NOT_CORRECT_MEMBERS_HIGHLIGHT_ID 예외를 반환합니다.") - void select_IS_NOT_USERS_HIGHLIGHT(){ - //given - UUID memberId1=UUID.randomUUID(); - UUID memberId2=UUID.randomUUID(); - - Member member1=Member.builder() - .email("test@naver.com") - .username("test") - .memberId(memberId1) - .build(); - Member member2=Member.builder() - .email("test2@naver.com") - .username("test2") - .memberId(memberId2) - .build(); - - HighlightEntity highlight=HighlightEntity.builder() - .member(member1) - .highlightKey(UUID.randomUUID()) - .highlightURL("url") - .build(); - - //when & then - assertThatThrownBy(() -> highlight.select(member2)) - .isInstanceOf(CustomException.class) - .hasMessageContaining(ErrorCode.IS_NOT_CORRECT_MEMBERS_HIGHLIGHT_ID.getMessage()); - } - - @Test - @DisplayName("이미 선택된 하이라이트인 경우 EXISTED_SELECTED 예외를 발생시킵니다.") - void select_EXIST_SELECTED(){ - //given - UUID memberId=UUID.randomUUID(); - - Member member=Member.builder() - .email("test@naver.com") - .username("test") - .memberId(memberId) - .build(); - - HighlightEntity highlight=HighlightEntity.builder() - .member(member) - .highlightKey(UUID.randomUUID()) - .highlightURL("url") - .isSelected(true) - .build(); - - //when & then - assertThatThrownBy(() -> highlight.select(member)) - .isInstanceOf(CustomException.class) - .hasMessageContaining(ErrorCode.EXISTED_SELECTED.getMessage()); - - } - - @Test - @DisplayName("select 메서드 실행 시 isSelected가 True로 변환됩니다.") - void select(){ - //given - UUID memberId=UUID.randomUUID(); - - Member member=Member.builder() - .email("test@naver.com") - .username("test") - .memberId(memberId) - .build(); - - HighlightEntity highlight=HighlightEntity.builder() - .member(member) - .highlightKey(UUID.randomUUID()) - .highlightURL("url") - .build(); - - //when - highlight.select(member); - - //then - assertThat(highlight.getIsSelected()).isTrue(); - } @Test @DisplayName("하이라이트 객체의 2점 슛 총합계를 계산합니다.") diff --git a/src/test/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImplTest.java b/src/test/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImplTest.java index e09451f2..4955cab3 100644 --- a/src/test/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImplTest.java +++ b/src/test/java/com/midas/shootpointer/domain/highlight/mapper/HighlightMapperImplTest.java @@ -46,7 +46,6 @@ void infoResponseToEntity(){ .highlightURL("url") .highlightKey(highlightKey) .highlightId(highlightId) - .isSelected(true) .twoPointCount(20) .threePointCount(30) .build(); diff --git a/src/test/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepositoryTest.java b/src/test/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepositoryTest.java index 8036a249..10d4e407 100644 --- a/src/test/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepositoryTest.java +++ b/src/test/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepositoryTest.java @@ -145,7 +145,6 @@ void fetchAllMembersHighlightsPagination(){ .member(member) .threePointCount(random.nextInt(1,100)) .twoPointCount(random.nextInt(1,100)) - .isSelected(true) .highlightURL("test") .build(); highlight.setCreatedAt(LocalDateTime.now().minusDays(idx)); diff --git a/src/test/resources/sql/CreateHighlightDummyData.sql b/src/test/resources/sql/CreateHighlightDummyData.sql index f1c87662..28862df6 100644 --- a/src/test/resources/sql/CreateHighlightDummyData.sql +++ b/src/test/resources/sql/CreateHighlightDummyData.sql @@ -117,7 +117,6 @@ $$ member_id, two_point_count, three_point_count, - is_selected, created_at, modified_at) VALUES (gen_random_uuid(), @@ -126,7 +125,6 @@ $$ m.member_id, FLOOR(random() * 20)::INT, -- 0 ~ 19개 FLOOR(random() * 15)::INT, --0~14개 - CASE WHEN random() > 0.15 THEN TRUE ELSE FALSE END, created_at, created_at); END LOOP; diff --git a/src/test/resources/sql/VerificationHighlightData.sql b/src/test/resources/sql/VerificationHighlightData.sql index b60f45c8..ffddef46 100644 --- a/src/test/resources/sql/VerificationHighlightData.sql +++ b/src/test/resources/sql/VerificationHighlightData.sql @@ -13,7 +13,6 @@ WITH filtered AS ( member AS m ON h.member_id = m.member_id WHERE m.is_aggregation_agreed = TRUE - AND h.is_selected = TRUE AND h.created_at >= ? AND h.created_at < ? ) From 7dee147e93e665631adbd895a531dbc5585b6e11 Mon Sep 17 00:00:00 2001 From: tkv00 Date: Mon, 17 Nov 2025 23:02:14 +0900 Subject: [PATCH 10/13] =?UTF-8?q?refact=20:=20HashTag=20BLOCKING=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/midas/shootpointer/domain/post/entity/HashTag.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/midas/shootpointer/domain/post/entity/HashTag.java b/src/main/java/com/midas/shootpointer/domain/post/entity/HashTag.java index 18c425e0..8a453cdd 100644 --- a/src/main/java/com/midas/shootpointer/domain/post/entity/HashTag.java +++ b/src/main/java/com/midas/shootpointer/domain/post/entity/HashTag.java @@ -7,7 +7,8 @@ @AllArgsConstructor public enum HashTag { TWO_POINT("2점슛"), - THREE_POINT("3점슛"); + THREE_POINT("3점슛"), + BLOCKING("블락"); private final String name; } From 116b45f88f6c6da558be999eaf12c1fd91cf4afa Mon Sep 17 00:00:00 2001 From: tkv00 Date: Tue, 18 Nov 2025 00:19:00 +0900 Subject: [PATCH 11/13] =?UTF-8?q?refact=20:=20=EA=B8=B0=EA=B0=84=20?= =?UTF-8?q?=EB=82=B4=20=EB=88=8C=EB=A6=B0=20=EC=A2=8B=EC=95=84=EC=9A=94=20?= =?UTF-8?q?=EA=B8=B0=EC=A4=80=20=EC=9D=B8=EA=B8=B0=20=ED=95=98=EC=9D=B4?= =?UTF-8?q?=EB=9D=BC=EC=9D=B4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20GROUP=20BY?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/HighlightQueryRepository.java | 7 +++++++ src/main/resources/application.yml | 12 ++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java index 2e704375..5f047ca3 100644 --- a/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java +++ b/src/main/java/com/midas/shootpointer/domain/highlight/repository/HighlightQueryRepository.java @@ -67,6 +67,13 @@ public interface HighlightQueryRepository extends JpaRepository Date: Tue, 18 Nov 2025 00:27:43 +0900 Subject: [PATCH 12/13] =?UTF-8?q?refact=20:=20HighlightFactory=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/highlight/mapper/HighlightFactoryTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/midas/shootpointer/domain/highlight/mapper/HighlightFactoryTest.java b/src/test/java/com/midas/shootpointer/domain/highlight/mapper/HighlightFactoryTest.java index 91571737..ee743ebe 100644 --- a/src/test/java/com/midas/shootpointer/domain/highlight/mapper/HighlightFactoryTest.java +++ b/src/test/java/com/midas/shootpointer/domain/highlight/mapper/HighlightFactoryTest.java @@ -9,6 +9,7 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import java.time.LocalDateTime; import java.util.List; import java.util.UUID; @@ -47,9 +48,9 @@ void createHighlightEntities(){ BackNumberEntity backNumber=BackNumberEntity.builder() .backNumber(BackNumber.of(10)) .build(); - + LocalDateTime now=LocalDateTime.now(); //when - List result=factory.createHighlightEntities(highlightInfos,highlightKey,member,backNumber); + List result=factory.createHighlightEntities(highlightInfos,highlightKey,member,backNumber,now); //then From b11a83306e3f73a2433df6c26efddc677c368f04 Mon Sep 17 00:00:00 2001 From: tkv00 Date: Tue, 18 Nov 2025 16:26:01 +0900 Subject: [PATCH 13/13] =?UTF-8?q?chore=20:=20logback-color=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=84=B1=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 - src/main/resources/application.yml | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/build.gradle b/build.gradle index bfaaa354..cda7bd9a 100644 --- a/build.gradle +++ b/build.gradle @@ -98,7 +98,6 @@ dependencies { testCompileOnly 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0' - implementation 'com.github.p493cc:logback-color:1.0.3' implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.9.0' diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f95687d1..c1f80b4d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -193,18 +193,3 @@ sse: event-name: progress cache-max-size: 360 clean-up-interval: 60000 - -#logging -p6spy: - config: - logMessageFormat: com.p6spy.engine.spy.appender.CustomLineFormat - customLogMessageFormat: | - %(currentTime) | took %(executionTime)ms | category=%(category) - %(sqlPretty) - ------------------------------------------------------------- - -decorator: - datasource: - p6spy: - enable-logging: true - log-format: multiline