Skip to content

Commit

Permalink
엔티티 수정 후 통계, 정산 파일 ad,video 따로 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
chobeebee committed Jul 8, 2024
1 parent 710213c commit 5837b8c
Show file tree
Hide file tree
Showing 19 changed files with 284 additions and 184 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.sparta.binplay.controller;

import com.sparta.binplay.service.StatisticsVideoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/stat")
public class StatisticsVideoController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.sparta.binplay.dto.request;

import com.sparta.binplay.entity.Videos;
import lombok.Getter;

@Getter
public class PaymentVideoRequestDto {
private Double totalAmount;
private Videos video;

public PaymentVideoRequestDto(Double totalAmount, Videos video) {
this.totalAmount = totalAmount;
this.video = video;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import lombok.Getter;

@Getter
public class StatisticRequestDto {
public class StatisticVideoRequestDto {
private String period;
private long periodViews;
private int totalViewingTime;
private Videos video;

public StatisticRequestDto(String period, long periodViews, int totalViewingTime, Videos video) {
public StatisticVideoRequestDto(String period, long periodViews, int totalViewingTime, Videos video) {
this.period = period;
this.periodViews = periodViews;
this.totalViewingTime = totalViewingTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.sparta.binplay.dto.response;

import com.sparta.binplay.entity.PaymentVideo;
import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class PaymentVideoResponseDto {
private Long paymentId;
private Double totalAmount;
private LocalDateTime createAt;

public static PaymentVideoResponseDto from(PaymentVideo payment) {
return PaymentVideoResponseDto.builder()
.paymentId(payment.getPaymentVideoId())
.totalAmount(payment.getTotalAmount())
.createAt(payment.getCreatedAt())
.build();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.sparta.binplay.dto.response;

import com.sparta.binplay.entity.StatisticVideo;
import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class StatisticVideoResponseDto {
private Long statVideoId;
private long dailyViewCount;
private int dailyPlayTime;
private LocalDateTime createdAt;

public static StatisticVideoResponseDto from(StatisticVideo statisticVideo) {
return StatisticVideoResponseDto.builder()
.statVideoId(statisticVideo.getStatVideoId())
.dailyViewCount(statisticVideo.getDailyViewCount())
.dailyPlayTime(statisticVideo.getDailyPlayTime())
.createdAt(statisticVideo.getCreatedAt())
.build();
}
}
30 changes: 30 additions & 0 deletions src/main/java/com/sparta/binplay/entity/PaymentAd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.sparta.binplay.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;

import java.time.LocalDateTime;

@Entity
@Getter
@Table(name="payments_ad")
@NoArgsConstructor
public class PaymentAd {
@Id
@Column(name="payment_ad_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long paymentAdId;

@Column(name="total_amount", nullable = false)
private Double totalAmount;

@CreatedDate
@Column(name="created_at", updatable = false)
private LocalDateTime createdAt;

@ManyToOne
@JoinColumn(name = "ad_view_id", nullable = false)
private AdViews adView;
}
39 changes: 39 additions & 0 deletions src/main/java/com/sparta/binplay/entity/StatisticAd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.sparta.binplay.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;

import java.time.LocalDateTime;

@Entity
@Getter
@Table(name="statistics_ad")
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class StatisticAd extends Timestamped{
@Id
@Column(name = "stat_ad_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long statAdId;

@Column(name="daily_view_count", nullable = false)
private long dailyViewCount;

@CreatedDate
@Column(name="created_at", updatable = false) //업데이트를 막음
private LocalDateTime createdAt;

@ManyToOne
@JoinColumn(name = "ad_view_id", nullable = false)
private AdViews adView;

public StatisticAd(Long dailyViewCount, AdViews adView) {
this.dailyViewCount = dailyViewCount;
this.adView = adView;
}
}
52 changes: 52 additions & 0 deletions src/main/java/com/sparta/binplay/entity/StatisticVideo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.sparta.binplay.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;

import java.time.LocalDateTime;

@Entity
@Getter
@Table(name="statistics_video")
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class StatisticVideo extends Timestamped{
@Id
@Column(name = "stat_video_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long statVideoId;

@Column(name="daily_view_count", nullable = false)
private long dailyViewCount;

@Column(name="daily_play_time", nullable = false)
private int dailyPlayTime;

@CreatedDate
@Column(name="created_at", updatable = false) //업데이트를 막음
private LocalDateTime createdAt;

@ManyToOne
@JoinColumn(name = "video_id")
private Videos video;

public StatisticVideo(long dailyViewCount, int dailyPlayTime, Videos video) {
this.dailyViewCount = dailyViewCount;
this.dailyPlayTime = dailyPlayTime;
this.video = video;
}

public StatisticVideo update(Long diailyViewCount, Integer dailyPlayTime) {
return StatisticVideo.builder()
.statVideoId(this.statVideoId) // ID를 유지하여 동일 엔티티로 인식
.dailyViewCount(diailyViewCount)
.dailyPlayTime(dailyPlayTime)
.video(this.video)
.build();
}
}
29 changes: 0 additions & 29 deletions src/main/java/com/sparta/binplay/entity/Statistics.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.sparta.binplay.repository;

import com.sparta.binplay.entity.PaymentVideo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface PaymentAdRepository extends JpaRepository<PaymentVideo, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.sparta.binplay.repository;

import com.sparta.binplay.entity.PaymentVideo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface PaymentVideoRepository extends JpaRepository<PaymentVideo, Long> {
List<PaymentVideo> findAllByCreatedAtBetween(LocalDateTime startDate, LocalDateTime endDate);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.sparta.binplay.repository;

import com.sparta.binplay.entity.StatisticAd;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface StatisticAdRepository extends JpaRepository<StatisticAd, Long> {
}

This file was deleted.

Loading

0 comments on commit 5837b8c

Please sign in to comment.