@@ -22,43 +22,47 @@ public class ProductMetric extends BaseEntity {
2222 @ Column (name = "sales_volume" , nullable = false )
2323 private Long salesVolume ;
2424
25+ @ Column (name = "metric_date" , nullable = false )
26+ private String metricDate ;
27+
2528 @ Enumerated (EnumType .STRING )
2629 @ Column (name = "event_type" , nullable = false )
2730 private ProductEventType eventType ;
2831
29- public ProductMetric (Long productId , Long viewCount , Long likeCount , Long salesVolume , ProductEventType eventType ) {
32+ public ProductMetric (Long productId , Long viewCount , Long likeCount , Long salesVolume , String metricDate , ProductEventType eventType ) {
3033 this .productId = productId ;
3134 this .viewCount = viewCount ;
3235 this .likeCount = likeCount ;
3336 this .salesVolume = salesVolume ;
37+ this .metricDate = metricDate ;
3438 this .eventType = eventType ;
3539 }
3640
3741 /*
3842 - [ ] 리팩토링 예정
3943 */
40- public static ProductMetric of (Long productId , ProductEventType eventType ) {
44+ public static ProductMetric of (Long productId , String date , ProductEventType eventType ) {
4145 if (eventType == null ) {
4246 throw new IllegalArgumentException ("정의되지 않은 event type입니다." );
4347 }
4448
4549 return switch (eventType ) {
46- case PRODUCT_VIEWED -> ofProductViewed (productId );
47- case PRODUCT_LIKED -> ofProductLiked (productId );
48- case PRODUCT_SALES -> ofProductSales (productId );
50+ case PRODUCT_VIEWED -> ofProductViewed (productId , date );
51+ case PRODUCT_LIKED -> ofProductLiked (productId , date );
52+ case PRODUCT_SALES -> ofProductSales (productId , date );
4953 };
5054 }
5155
52- public static ProductMetric ofProductViewed (Long productId ) {
53- return new ProductMetric (productId , 1L , 0L , 0L , ProductEventType .PRODUCT_VIEWED );
56+ public static ProductMetric ofProductViewed (Long productId , String date ) {
57+ return new ProductMetric (productId , 1L , 0L , 0L , date , ProductEventType .PRODUCT_VIEWED );
5458 }
5559
56- public static ProductMetric ofProductLiked (Long productId ) {
57- return new ProductMetric (productId , 0L , 1L , 0L , ProductEventType .PRODUCT_LIKED );
60+ public static ProductMetric ofProductLiked (Long productId , String date ) {
61+ return new ProductMetric (productId , 0L , 1L , 0L , date , ProductEventType .PRODUCT_LIKED );
5862 }
5963
60- public static ProductMetric ofProductSales (Long productId ) {
61- return new ProductMetric (productId , 0L , 0L , 1L , ProductEventType .PRODUCT_SALES );
64+ public static ProductMetric ofProductSales (Long productId , String date ) {
65+ return new ProductMetric (productId , 0L , 0L , 1L , date , ProductEventType .PRODUCT_SALES );
6266 }
6367
6468 public void increaseProductMetric (ProductEventType eventType ) {
0 commit comments