parent
f0aa0bc021
commit
e3f65c8941
|
@ -0,0 +1,29 @@
|
|||
package kr.co.vividnext.sodalive.content
|
||||
|
||||
import java.time.LocalDateTime
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.FetchType
|
||||
import javax.persistence.GeneratedValue
|
||||
import javax.persistence.GenerationType
|
||||
import javax.persistence.Id
|
||||
import javax.persistence.JoinColumn
|
||||
import javax.persistence.ManyToOne
|
||||
import javax.persistence.PrePersist
|
||||
|
||||
@Entity
|
||||
data class ContentPriceChangeLog(
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
var id: Long? = null,
|
||||
val prevPrice: Int,
|
||||
var createdAt: LocalDateTime? = null
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "content_id", nullable = false)
|
||||
var audioContent: AudioContent? = null
|
||||
|
||||
@PrePersist
|
||||
fun prePersist() {
|
||||
createdAt = LocalDateTime.now()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package kr.co.vividnext.sodalive.content
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
|
||||
interface ContentPriceChangeLogRepository : JpaRepository<ContentPriceChangeLog, Long>
|
|
@ -5,6 +5,8 @@ import com.fasterxml.jackson.databind.ObjectMapper
|
|||
import kr.co.vividnext.sodalive.aws.cloudfront.AudioContentCloudFront
|
||||
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.content.ContentPriceChangeLog
|
||||
import kr.co.vividnext.sodalive.content.ContentPriceChangeLogRepository
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
|
@ -16,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile
|
|||
@Service
|
||||
class CreatorAdminContentService(
|
||||
private val repository: CreatorAdminContentRepository,
|
||||
private val contentPriceChangeLogRepository: ContentPriceChangeLogRepository,
|
||||
private val audioContentCloudFront: AudioContentCloudFront,
|
||||
private val objectMapper: ObjectMapper,
|
||||
private val s3Uploader: S3Uploader,
|
||||
|
@ -142,6 +145,11 @@ class CreatorAdminContentService(
|
|||
|
||||
if (request.price != null) {
|
||||
if (request.price < 5) throw SodaException("콘텐츠의 최소금액은 5캔 입니다.")
|
||||
|
||||
val contentPriceChangeLog = ContentPriceChangeLog(prevPrice = audioContent.price)
|
||||
contentPriceChangeLog.audioContent = audioContent
|
||||
contentPriceChangeLogRepository.save(contentPriceChangeLog)
|
||||
|
||||
audioContent.price = request.price
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue