Skip to content

Commit e5128b7

Browse files
committed
refactor(ranking): 코드 포맷팅 및 불필요한 임포트 제거
- 코드 가독성을 높이기 위해 불필요한 임포트 문을 제거 - 주석 및 공백 정리로 코드 일관성 향상
1 parent 2c8e554 commit e5128b7

50 files changed

Lines changed: 458 additions & 397 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/commerce-api/src/main/java/com/loopers/application/product/ProductDetailInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public static ProductDetailInfo of(ProductEntity product, BrandEntity brand, Lon
6262
return of(product, brand, likeCount, isLiked, null);
6363
}
6464

65-
public static ProductDetailInfo of(ProductEntity product, BrandEntity brand, Long likeCount, Boolean isLiked, RankingItem ranking) {
65+
public static ProductDetailInfo of(ProductEntity product, BrandEntity brand, Long likeCount, Boolean isLiked,
66+
RankingItem ranking) {
6667
if (product == null) {
6768
throw new IllegalArgumentException("상품 정보는 필수입니다.");
6869
}

apps/commerce-api/src/main/java/com/loopers/application/product/ProductFacade.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public Page<ProductInfo> getProducts(ProductSearchFilter productSearchFilter) {
7777
* 도메인 서비스에서 엔티티를 조회하고, Facade에서 DTO로 변환합니다.
7878
*
7979
* @param productId 상품 ID
80-
* @param username 사용자 ID (nullable)
80+
* @param username 사용자 ID (nullable)
8181
* @return 상품 상세 정보
8282
*/
8383
@Transactional(readOnly = true)
@@ -136,25 +136,25 @@ public ProductDetailInfo getProductDetail(Long productId, String username) {
136136
@Transactional(readOnly = true)
137137
public Page<ProductInfo> getRankingProducts(Pageable pageable, LocalDate date) {
138138
LocalDate targetDate = date != null ? date : LocalDate.now();
139-
139+
140140
// 1. 랭킹 조회
141141
List<RankingItem> rankings = rankingRedisService.getRanking(
142142
targetDate,
143-
pageable.getPageNumber() + 1,
143+
pageable.getPageNumber() + 1,
144144
pageable.getPageSize()
145145
);
146146

147147
// 2. 콜드 스타트 Fallback: 오늘 랭킹이 비어있으면 어제 랭킹 조회
148148
if (rankings.isEmpty() && date == null) {
149149
LocalDate yesterday = targetDate.minusDays(1);
150150
log.info("콜드 스타트 Fallback: 오늘({}) 랭킹 없음, 어제({}) 랭킹 조회", targetDate, yesterday);
151-
151+
152152
rankings = rankingRedisService.getRanking(
153153
yesterday,
154154
pageable.getPageNumber() + 1,
155155
pageable.getPageSize()
156156
);
157-
157+
158158
if (!rankings.isEmpty()) {
159159
targetDate = yesterday; // totalCount 계산을 위해 날짜 변경
160160
}
@@ -190,22 +190,22 @@ public Page<ProductInfo> getRankingProducts(Pageable pageable, LocalDate date) {
190190

191191
/**
192192
* 기간별 랭킹 상품 목록 조회
193-
*
194-
* @param period 랭킹 기간 (DAILY, WEEKLY, MONTHLY)
195-
* @param pageable 페이징 정보
196-
* @param date 조회 날짜 (DAILY용, null이면 오늘)
197-
* @param yearWeek 조회 주차 (WEEKLY용, 예: "2024-W52")
193+
*
194+
* @param period 랭킹 기간 (DAILY, WEEKLY, MONTHLY)
195+
* @param pageable 페이징 정보
196+
* @param date 조회 날짜 (DAILY용, null이면 오늘)
197+
* @param yearWeek 조회 주차 (WEEKLY용, 예: "2024-W52")
198198
* @param yearMonth 조회 월 (MONTHLY용, 예: "2024-12")
199199
* @return 랭킹 상품 목록
200200
*/
201201
@Transactional(readOnly = true)
202202
public Page<ProductInfo> getRankingProductsByPeriod(
203-
RankingPeriod period,
204-
Pageable pageable,
205-
LocalDate date,
206-
String yearWeek,
203+
RankingPeriod period,
204+
Pageable pageable,
205+
LocalDate date,
206+
String yearWeek,
207207
String yearMonth) {
208-
208+
209209
return switch (period) {
210210
case DAILY -> getRankingProducts(pageable, date);
211211
case WEEKLY -> getWeeklyRankingProducts(pageable, yearWeek);
@@ -215,7 +215,7 @@ public Page<ProductInfo> getRankingProductsByPeriod(
215215

216216
/**
217217
* 주간 랭킹 상품 목록 조회
218-
*
218+
*
219219
* @param pageable 페이징 정보
220220
* @param yearWeek 조회 주차 (예: "2024-W52")
221221
* @return 주간 랭킹 상품 목록
@@ -229,7 +229,7 @@ public Page<ProductInfo> getWeeklyRankingProducts(Pageable pageable, String year
229229

230230
// 1. 주간 랭킹 조회
231231
Page<WeeklyRankEntity> weeklyRankings = weeklyRankingService.getWeeklyRanking(yearWeek, pageable);
232-
232+
233233
if (weeklyRankings.isEmpty()) {
234234
log.debug("주간 랭킹 데이터 없음: yearWeek={}", yearWeek);
235235
return Page.empty(pageable);
@@ -259,8 +259,8 @@ public Page<ProductInfo> getWeeklyRankingProducts(Pageable pageable, String year
259259

260260
/**
261261
* 월간 랭킹 상품 목록 조회
262-
*
263-
* @param pageable 페이징 정보
262+
*
263+
* @param pageable 페이징 정보
264264
* @param yearMonth 조회 월 (예: "2024-12")
265265
* @return 월간 랭킹 상품 목록
266266
*/
@@ -273,7 +273,7 @@ public Page<ProductInfo> getMonthlyRankingProducts(Pageable pageable, String yea
273273

274274
// 1. 월간 랭킹 조회
275275
Page<MonthlyRankEntity> monthlyRankings = monthlyRankingService.getMonthlyRanking(yearMonth, pageable);
276-
276+
277277
if (monthlyRankings.isEmpty()) {
278278
log.debug("월간 랭킹 데이터 없음: yearMonth={}", yearMonth);
279279
return Page.empty(pageable);
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
package com.loopers.application.ranking;
22

3-
import com.loopers.domain.ranking.MonthlyRankEntity;
4-
import com.loopers.domain.ranking.MonthlyRankRepository;
5-
import lombok.RequiredArgsConstructor;
6-
import lombok.extern.slf4j.Slf4j;
3+
import java.util.List;
4+
75
import org.springframework.data.domain.Page;
86
import org.springframework.data.domain.PageImpl;
97
import org.springframework.data.domain.Pageable;
108
import org.springframework.stereotype.Service;
119
import org.springframework.transaction.annotation.Transactional;
1210

13-
import java.util.List;
11+
import com.loopers.domain.ranking.MonthlyRankEntity;
12+
import com.loopers.domain.ranking.MonthlyRankRepository;
13+
14+
import lombok.RequiredArgsConstructor;
15+
import lombok.extern.slf4j.Slf4j;
1416

1517
/**
1618
* 월간 랭킹 조회 서비스
@@ -25,18 +27,18 @@ public class MonthlyRankingService {
2527

2628
/**
2729
* 특정 월의 랭킹을 페이지네이션하여 조회합니다.
28-
*
30+
*
2931
* @param yearMonth 조회할 월 (예: "2024-12")
30-
* @param pageable 페이징 정보
32+
* @param pageable 페이징 정보
3133
* @return 월간 랭킹 페이지
3234
*/
3335
public Page<MonthlyRankEntity> getMonthlyRanking(String yearMonth, Pageable pageable) {
34-
log.debug("월간 랭킹 조회: yearMonth={}, page={}, size={}",
36+
log.debug("월간 랭킹 조회: yearMonth={}, page={}, size={}",
3537
yearMonth, pageable.getPageNumber(), pageable.getPageSize());
3638

3739
// 1. 전체 랭킹 조회 (순위 순으로 정렬됨)
3840
List<MonthlyRankEntity> allRankings = monthlyRankRepository.findByYearMonth(yearMonth);
39-
41+
4042
if (allRankings.isEmpty()) {
4143
log.debug("월간 랭킹 데이터 없음: yearMonth={}", yearMonth);
4244
return Page.empty(pageable);
@@ -45,27 +47,27 @@ public Page<MonthlyRankEntity> getMonthlyRanking(String yearMonth, Pageable page
4547
// 2. 페이징 처리
4648
int start = (int) pageable.getOffset();
4749
int end = Math.min(start + pageable.getPageSize(), allRankings.size());
48-
50+
4951
if (start >= allRankings.size()) {
5052
return Page.empty(pageable);
5153
}
5254

5355
List<MonthlyRankEntity> pagedRankings = allRankings.subList(start, end);
54-
55-
log.debug("월간 랭킹 조회 완료: yearMonth={}, 전체={}, 페이지={}",
56+
57+
log.debug("월간 랭킹 조회 완료: yearMonth={}, 전체={}, 페이지={}",
5658
yearMonth, allRankings.size(), pagedRankings.size());
5759

5860
return new PageImpl<>(pagedRankings, pageable, allRankings.size());
5961
}
6062

6163
/**
6264
* 특정 월의 전체 랭킹 개수를 조회합니다.
63-
*
65+
*
6466
* @param yearMonth 조회할 월
6567
* @return 랭킹 개수
6668
*/
6769
public long getMonthlyRankingCount(String yearMonth) {
6870
List<MonthlyRankEntity> rankings = monthlyRankRepository.findByYearMonth(yearMonth);
6971
return rankings.size();
7072
}
71-
}
73+
}
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
package com.loopers.application.ranking;
22

3-
import com.loopers.domain.ranking.WeeklyRankEntity;
4-
import com.loopers.domain.ranking.WeeklyRankRepository;
5-
import lombok.RequiredArgsConstructor;
6-
import lombok.extern.slf4j.Slf4j;
3+
import java.util.List;
4+
75
import org.springframework.data.domain.Page;
86
import org.springframework.data.domain.PageImpl;
97
import org.springframework.data.domain.Pageable;
108
import org.springframework.stereotype.Service;
119
import org.springframework.transaction.annotation.Transactional;
1210

13-
import java.util.List;
11+
import com.loopers.domain.ranking.WeeklyRankEntity;
12+
import com.loopers.domain.ranking.WeeklyRankRepository;
13+
14+
import lombok.RequiredArgsConstructor;
15+
import lombok.extern.slf4j.Slf4j;
1416

1517
/**
1618
* 주간 랭킹 조회 서비스
@@ -25,18 +27,18 @@ public class WeeklyRankingService {
2527

2628
/**
2729
* 특정 주차의 랭킹을 페이지네이션하여 조회합니다.
28-
*
30+
*
2931
* @param yearWeek 조회할 주차 (예: "2024-W52")
3032
* @param pageable 페이징 정보
3133
* @return 주간 랭킹 페이지
3234
*/
3335
public Page<WeeklyRankEntity> getWeeklyRanking(String yearWeek, Pageable pageable) {
34-
log.debug("주간 랭킹 조회: yearWeek={}, page={}, size={}",
36+
log.debug("주간 랭킹 조회: yearWeek={}, page={}, size={}",
3537
yearWeek, pageable.getPageNumber(), pageable.getPageSize());
3638

3739
// 1. 전체 랭킹 조회 (순위 순으로 정렬됨)
3840
List<WeeklyRankEntity> allRankings = weeklyRankRepository.findByYearWeek(yearWeek);
39-
41+
4042
if (allRankings.isEmpty()) {
4143
log.debug("주간 랭킹 데이터 없음: yearWeek={}", yearWeek);
4244
return Page.empty(pageable);
@@ -45,27 +47,27 @@ public Page<WeeklyRankEntity> getWeeklyRanking(String yearWeek, Pageable pageabl
4547
// 2. 페이징 처리
4648
int start = (int) pageable.getOffset();
4749
int end = Math.min(start + pageable.getPageSize(), allRankings.size());
48-
50+
4951
if (start >= allRankings.size()) {
5052
return Page.empty(pageable);
5153
}
5254

5355
List<WeeklyRankEntity> pagedRankings = allRankings.subList(start, end);
54-
55-
log.debug("주간 랭킹 조회 완료: yearWeek={}, 전체={}, 페이지={}",
56+
57+
log.debug("주간 랭킹 조회 완료: yearWeek={}, 전체={}, 페이지={}",
5658
yearWeek, allRankings.size(), pagedRankings.size());
5759

5860
return new PageImpl<>(pagedRankings, pageable, allRankings.size());
5961
}
6062

6163
/**
6264
* 특정 주차의 전체 랭킹 개수를 조회합니다.
63-
*
65+
*
6466
* @param yearWeek 조회할 주차
6567
* @return 랭킹 개수
6668
*/
6769
public long getWeeklyRankingCount(String yearWeek) {
6870
List<WeeklyRankEntity> rankings = weeklyRankRepository.findByYearWeek(yearWeek);
6971
return rankings.size();
7072
}
71-
}
73+
}

apps/commerce-api/src/main/java/com/loopers/domain/point/PointHistoryEntity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.util.Objects;
55

66
import com.loopers.domain.BaseEntity;
7-
import com.loopers.domain.product.ProductEntity;
87
import com.loopers.domain.user.UserEntity;
98

109
import lombok.AccessLevel;

apps/commerce-api/src/main/java/com/loopers/domain/ranking/RankingPeriod.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ public enum RankingPeriod {
88
* 일간 랭킹 (Redis ZSET 기반)
99
*/
1010
DAILY,
11-
11+
1212
/**
1313
* 주간 랭킹 (mv_product_rank_weekly 기반)
1414
*/
1515
WEEKLY,
16-
16+
1717
/**
1818
* 월간 랭킹 (mv_product_rank_monthly 기반)
1919
*/
2020
MONTHLY
21-
}
21+
}

apps/commerce-api/src/main/java/com/loopers/domain/user/UserEntity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.Objects;
77

88
import com.loopers.domain.BaseEntity;
9-
import com.loopers.support.Uris;
109

1110
import lombok.AccessLevel;
1211
import lombok.Getter;

apps/commerce-api/src/main/java/com/loopers/infrastructure/ranking/MonthlyRankJpaRepository.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package com.loopers.infrastructure.ranking;
22

3-
import com.loopers.domain.ranking.MonthlyRankEntity;
4-
import com.loopers.domain.ranking.MonthlyRankId;
3+
import java.util.List;
4+
55
import org.springframework.data.domain.Pageable;
66
import org.springframework.data.jpa.repository.JpaRepository;
77
import org.springframework.data.jpa.repository.Modifying;
88
import org.springframework.data.jpa.repository.Query;
99
import org.springframework.data.repository.query.Param;
1010

11-
import java.util.List;
11+
import com.loopers.domain.ranking.MonthlyRankEntity;
12+
import com.loopers.domain.ranking.MonthlyRankId;
1213

1314
/**
1415
* 월간 랭킹 JPA Repository (commerce-api용)
@@ -29,11 +30,11 @@ public interface MonthlyRankJpaRepository extends JpaRepository<MonthlyRankEntit
2930

3031
/**
3132
* 특정 월의 모든 랭킹을 삭제합니다.
32-
*
33+
*
3334
* @param yearMonth 삭제할 월
3435
* @return 삭제된 레코드 수
3536
*/
3637
@Modifying
3738
@Query("DELETE FROM MonthlyRankEntity m WHERE m.id.yearMonth = :yearMonth")
3839
long deleteByIdYearMonth(@Param("yearMonth") String yearMonth);
39-
}
40+
}

apps/commerce-api/src/main/java/com/loopers/infrastructure/ranking/MonthlyRankRepositoryImpl.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.loopers.infrastructure.ranking;
22

3-
import com.loopers.domain.ranking.MonthlyRankEntity;
4-
import com.loopers.domain.ranking.MonthlyRankRepository;
5-
import lombok.RequiredArgsConstructor;
3+
import java.util.List;
4+
65
import org.springframework.data.domain.PageRequest;
76
import org.springframework.data.domain.Pageable;
87
import org.springframework.stereotype.Repository;
98

10-
import java.util.List;
9+
import com.loopers.domain.ranking.MonthlyRankEntity;
10+
import com.loopers.domain.ranking.MonthlyRankRepository;
11+
12+
import lombok.RequiredArgsConstructor;
1113

1214
/**
1315
* 월간 랭킹 Repository 구현체 (commerce-api용)
@@ -43,4 +45,4 @@ public List<MonthlyRankEntity> findByYearMonthWithPagination(String yearMonth, i
4345
public long deleteByYearMonth(String yearMonth) {
4446
return jpaRepository.deleteByIdYearMonth(yearMonth);
4547
}
46-
}
48+
}

0 commit comments

Comments
 (0)