Skip to content

Commit 52dbf4b

Browse files
committed
feat: 주간 랭킹 엔티티 및 인덱스 추가
1 parent 0d50304 commit 52dbf4b

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.loopers.domain.ranking;
2+
3+
import jakarta.persistence.*;
4+
import lombok.Getter;
5+
import lombok.NoArgsConstructor;
6+
7+
import java.time.LocalDate;
8+
9+
@Entity
10+
@Getter
11+
@Table(name = "mv_product_rank_weekly")
12+
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
13+
public class WeeklyRanking {
14+
15+
@Id
16+
@GeneratedValue(strategy = GenerationType.IDENTITY)
17+
private Long id;
18+
19+
@Column(name = "weekly_rank")
20+
private int rank;
21+
22+
private Long productId;
23+
24+
private double score;
25+
26+
private LocalDate weekStart;
27+
28+
private LocalDate weekEnd;
29+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.loopers.batch.domain.ranking;
2+
3+
import jakarta.persistence.*;
4+
import lombok.Getter;
5+
import lombok.NoArgsConstructor;
6+
7+
import java.time.LocalDate;
8+
9+
@Entity
10+
@Getter
11+
@Table(
12+
name = "mv_product_rank_weekly",
13+
indexes = {
14+
@Index(name = "idx_week", columnList = "week_start, week_end"),
15+
@Index(name = "idx_score", columnList = "score")
16+
},
17+
uniqueConstraints = {
18+
@UniqueConstraint(name = "uq_weekly_rank", columnNames = {"product_id", "week_start", "week_end"})
19+
}
20+
)
21+
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
22+
public class WeeklyRanking {
23+
24+
@Id
25+
@GeneratedValue(strategy = GenerationType.IDENTITY)
26+
private Long id;
27+
28+
@Column(name = "weekly_rank")
29+
private int rank;
30+
31+
private Long productId;
32+
33+
private double score;
34+
35+
private LocalDate weekStart;
36+
37+
private LocalDate weekEnd;
38+
39+
public static WeeklyRanking create(int rank, Long productId, double score, LocalDate weekStart, LocalDate weekEnd) {
40+
WeeklyRanking weeklyRanking = new WeeklyRanking();
41+
42+
weeklyRanking.rank = rank;
43+
weeklyRanking.productId = productId;
44+
weeklyRanking.score = score;
45+
weeklyRanking.weekStart = weekStart;
46+
weeklyRanking.weekEnd = weekEnd;
47+
48+
return weeklyRanking;
49+
}
50+
}

0 commit comments

Comments
 (0)