-
Notifications
You must be signed in to change notification settings - Fork 36
[volume-10] Collect, Stack, Zip #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
minor7295
merged 2 commits into
Loopers-dev-lab:minor7295
from
minor7295:base-pr-round10
Jan 4, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
apps/commerce-api/src/main/java/com/loopers/domain/rank/ProductRank.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| package com.loopers.domain.rank; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
|
|
||
| /** | ||
| * ์ํ ๋ญํน Materialized View ์ํฐํฐ. | ||
| * <p> | ||
| * ์ฃผ๊ฐ/์๊ฐ TOP 100 ๋ญํน์ ์ ์ฅํ๋ ์กฐํ ์ ์ฉ ํ ์ด๋ธ์ ๋๋ค. | ||
| * </p> | ||
| * <p> | ||
| * <b>Materialized View ์ค๊ณ:</b> | ||
| * <ul> | ||
| * <li>ํ ์ด๋ธ: `mv_product_rank` (๋จ์ผ ํ ์ด๋ธ)</li> | ||
| * <li>์ฃผ๊ฐ ๋ญํน: period_type = WEEKLY</li> | ||
| * <li>์๊ฐ ๋ญํน: period_type = MONTHLY</li> | ||
| * <li>TOP 100๋ง ์ ์ฅํ์ฌ ์กฐํ ์ฑ๋ฅ ์ต์ ํ</li> | ||
| * </ul> | ||
| * </p> | ||
| * <p> | ||
| * <b>์ธ๋ฑ์ค ์ ๋ต:</b> | ||
| * <ul> | ||
| * <li>๋ณตํฉ ์ธ๋ฑ์ค: (period_type, period_start_date, rank) - ๊ธฐ๊ฐ๋ณ ๋ญํน ์กฐํ ์ต์ ํ</li> | ||
| * <li>๋ณตํฉ ์ธ๋ฑ์ค: (period_type, period_start_date, product_id) - ํน์ ์ํ ๋ญํน ์กฐํ ์ต์ ํ</li> | ||
| * </ul> | ||
| * </p> | ||
| * | ||
| * @author Loopers | ||
| * @version 1.0 | ||
| */ | ||
| @Entity | ||
| @Table( | ||
| name = "mv_product_rank", | ||
| indexes = { | ||
| @Index(name = "idx_period_type_start_date_rank", columnList = "period_type, period_start_date, rank"), | ||
| @Index(name = "idx_period_type_start_date_product_id", columnList = "period_type, period_start_date, product_id") | ||
| } | ||
| ) | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Getter | ||
| public class ProductRank { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "id") | ||
| private Long id; | ||
|
|
||
| /** | ||
| * ๊ธฐ๊ฐ ํ์ (WEEKLY: ์ฃผ๊ฐ, MONTHLY: ์๊ฐ) | ||
| */ | ||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "period_type", nullable = false, length = 20) | ||
| private PeriodType periodType; | ||
|
|
||
| /** | ||
| * ๊ธฐ๊ฐ ์์์ผ | ||
| * <ul> | ||
| * <li>์ฃผ๊ฐ: ํด๋น ์ฃผ์ ์์์ผ (ISO 8601 ๊ธฐ์ค)</li> | ||
| * <li>์๊ฐ: ํด๋น ์์ 1์ผ</li> | ||
| * </ul> | ||
| */ | ||
| @Column(name = "period_start_date", nullable = false) | ||
| private LocalDate periodStartDate; | ||
|
|
||
| /** | ||
| * ์ํ ID | ||
| */ | ||
| @Column(name = "product_id", nullable = false) | ||
| private Long productId; | ||
|
|
||
| /** | ||
| * ๋ญํน (1-100) | ||
| */ | ||
| @Column(name = "rank", nullable = false) | ||
| private Integer rank; | ||
|
|
||
| /** | ||
| * ์ข์์ ์ | ||
| */ | ||
| @Column(name = "like_count", nullable = false) | ||
| private Long likeCount; | ||
|
|
||
| /** | ||
| * ํ๋งค๋ | ||
| */ | ||
| @Column(name = "sales_count", nullable = false) | ||
| private Long salesCount; | ||
|
|
||
| /** | ||
| * ์กฐํ ์ | ||
| */ | ||
| @Column(name = "view_count", nullable = false) | ||
| private Long viewCount; | ||
|
|
||
| /** | ||
| * ์์ฑ ์๊ฐ | ||
| */ | ||
| @Column(name = "created_at", nullable = false, updatable = false) | ||
| private LocalDateTime createdAt; | ||
|
|
||
| /** | ||
| * ์์ ์๊ฐ | ||
| */ | ||
| @Column(name = "updated_at", nullable = false) | ||
| private LocalDateTime updatedAt; | ||
|
|
||
| /** | ||
| * ๊ธฐ๊ฐ ํ์ ์ด๊ฑฐํ. | ||
| */ | ||
| public enum PeriodType { | ||
| WEEKLY, // ์ฃผ๊ฐ | ||
| MONTHLY // ์๊ฐ | ||
| } | ||
| } | ||
|
|
||
39 changes: 39 additions & 0 deletions
39
apps/commerce-api/src/main/java/com/loopers/domain/rank/ProductRankRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package com.loopers.domain.rank; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * ProductRank ๋๋ฉ์ธ Repository ์ธํฐํ์ด์ค. | ||
| * <p> | ||
| * Materialized View์ ์ ์ฅ๋ ์ํ ๋ญํน ๋ฐ์ดํฐ๋ฅผ ์กฐํํฉ๋๋ค. | ||
| * </p> | ||
| */ | ||
| public interface ProductRankRepository { | ||
|
|
||
| /** | ||
| * ํน์ ๊ธฐ๊ฐ์ ๋ญํน ๋ฐ์ดํฐ๋ฅผ ์กฐํํฉ๋๋ค. | ||
| * | ||
| * @param periodType ๊ธฐ๊ฐ ํ์ | ||
| * @param periodStartDate ๊ธฐ๊ฐ ์์์ผ | ||
| * @param limit ์กฐํํ ๋ญํน ์ (๊ธฐ๋ณธ: 100) | ||
| * @return ๋ญํน ๋ฆฌ์คํธ (rank ์ค๋ฆ์ฐจ์) | ||
| */ | ||
| List<ProductRank> findByPeriod(ProductRank.PeriodType periodType, LocalDate periodStartDate, int limit); | ||
|
|
||
| /** | ||
| * ํน์ ๊ธฐ๊ฐ์ ํน์ ์ํ ๋ญํน์ ์กฐํํฉ๋๋ค. | ||
| * | ||
| * @param periodType ๊ธฐ๊ฐ ํ์ | ||
| * @param periodStartDate ๊ธฐ๊ฐ ์์์ผ | ||
| * @param productId ์ํ ID | ||
| * @return ๋ญํน ์ ๋ณด (์์ผ๋ฉด Optional.empty()) | ||
| */ | ||
| Optional<ProductRank> findByPeriodAndProductId( | ||
| ProductRank.PeriodType periodType, | ||
| LocalDate periodStartDate, | ||
| Long productId | ||
| ); | ||
| } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.