BundleAudioContent 제거
This commit is contained in:
parent
efdf1d3eed
commit
eee59855cc
|
@ -9,8 +9,6 @@ import java.time.LocalDateTime
|
|||
import javax.persistence.CascadeType
|
||||
import javax.persistence.Column
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.EnumType
|
||||
import javax.persistence.Enumerated
|
||||
import javax.persistence.FetchType
|
||||
import javax.persistence.JoinColumn
|
||||
import javax.persistence.ManyToOne
|
||||
|
@ -18,10 +16,6 @@ import javax.persistence.OneToMany
|
|||
import javax.persistence.OneToOne
|
||||
import javax.persistence.Table
|
||||
|
||||
enum class AudioContentType {
|
||||
INDIVIDUAL, BUNDLE
|
||||
}
|
||||
|
||||
enum class SortType {
|
||||
NEWEST, PRICE_HIGH, PRICE_LOW
|
||||
}
|
||||
|
@ -36,8 +30,6 @@ data class AudioContent(
|
|||
var releaseDate: LocalDateTime? = null,
|
||||
val limited: Int? = null,
|
||||
var remaining: Int? = null,
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
val type: AudioContentType = AudioContentType.INDIVIDUAL,
|
||||
val isGeneratePreview: Boolean = true,
|
||||
var isOnlyRental: Boolean = false,
|
||||
var isAdult: Boolean = false,
|
||||
|
@ -63,7 +55,4 @@ data class AudioContent(
|
|||
|
||||
@OneToMany(mappedBy = "audioContent", cascade = [CascadeType.ALL])
|
||||
val audioContentHashTags: MutableList<AudioContentHashTag> = mutableListOf()
|
||||
|
||||
@OneToMany(mappedBy = "child", cascade = [CascadeType.ALL])
|
||||
var children: MutableList<BundleAudioContent> = mutableListOf()
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package kr.co.vividnext.sodalive.content
|
|||
import com.querydsl.core.types.dsl.Expressions
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||
import kr.co.vividnext.sodalive.content.QBundleAudioContent.bundleAudioContent
|
||||
import kr.co.vividnext.sodalive.content.category.QCategoryContent.categoryContent
|
||||
import kr.co.vividnext.sodalive.content.comment.QAudioContentComment.audioContentComment
|
||||
import kr.co.vividnext.sodalive.content.like.QAudioContentLike.audioContentLike
|
||||
|
@ -32,7 +31,6 @@ interface AudioContentRepository : JpaRepository<AudioContent, Long>, AudioConte
|
|||
interface AudioContentQueryRepository {
|
||||
fun findByIdAndActive(contentId: Long): AudioContent?
|
||||
fun findByIdAndCreatorId(contentId: Long, creatorId: Long): AudioContent?
|
||||
fun findBundleByContentId(contentId: Long): List<AudioContent>
|
||||
fun findByCreatorId(
|
||||
creatorId: Long,
|
||||
coverImageHost: String,
|
||||
|
@ -147,18 +145,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
|||
.fetchOne()
|
||||
}
|
||||
|
||||
// 해당 컨텐츠가 속한 묶음(번들) 상품 리스트 검색
|
||||
override fun findBundleByContentId(contentId: Long): List<AudioContent> {
|
||||
return queryFactory
|
||||
.select(bundleAudioContent.parent)
|
||||
.from(bundleAudioContent)
|
||||
.where(
|
||||
bundleAudioContent.child.id.eq(contentId)
|
||||
.and(bundleAudioContent.child.isActive.isTrue)
|
||||
)
|
||||
.fetch()
|
||||
}
|
||||
|
||||
override fun findByCreatorId(
|
||||
creatorId: Long,
|
||||
coverImageHost: String,
|
||||
|
|
|
@ -160,14 +160,10 @@ class AudioContentService(
|
|||
}
|
||||
|
||||
// contentFile 체크
|
||||
if (contentFile == null && request.type == AudioContentType.INDIVIDUAL) {
|
||||
if (contentFile == null) {
|
||||
throw SodaException("콘텐츠를 선택해 주세요.")
|
||||
}
|
||||
|
||||
if (request.type == AudioContentType.BUNDLE && request.childIds == null) {
|
||||
throw SodaException("묶음상품의 하위상품을 선택해 주세요.")
|
||||
}
|
||||
|
||||
// 테마 체크
|
||||
val theme = themeQueryRepository.findThemeByIdAndActive(id = request.themeId)
|
||||
?: throw SodaException("잘못된 테마입니다. 다시 선택해 주세요.")
|
||||
|
@ -178,7 +174,6 @@ class AudioContentService(
|
|||
val audioContent = AudioContent(
|
||||
title = request.title,
|
||||
detail = request.detail,
|
||||
type = request.type,
|
||||
price = if (request.price > 0) {
|
||||
request.price
|
||||
} else {
|
||||
|
@ -188,18 +183,12 @@ class AudioContentService(
|
|||
limited = request.limited,
|
||||
remaining = request.limited,
|
||||
isAdult = request.isAdult,
|
||||
isGeneratePreview = if (request.type == AudioContentType.INDIVIDUAL) {
|
||||
request.isGeneratePreview
|
||||
} else {
|
||||
false
|
||||
},
|
||||
isGeneratePreview = request.isGeneratePreview,
|
||||
isOnlyRental = if (request.limited != null && request.limited > 0) false else request.isOnlyRental,
|
||||
isCommentAvailable = request.isCommentAvailable
|
||||
)
|
||||
audioContent.theme = theme
|
||||
audioContent.member = member
|
||||
audioContent.isActive = request.type == AudioContentType.BUNDLE
|
||||
|
||||
repository.save(audioContent)
|
||||
|
||||
// 태그 분리, #추가, 등록
|
||||
|
@ -246,48 +235,34 @@ class AudioContentService(
|
|||
|
||||
audioContent.coverImage = coverImagePath
|
||||
|
||||
if (contentFile != null && request.type == AudioContentType.INDIVIDUAL) {
|
||||
// 콘텐츠 파일명 생성
|
||||
val contentFileName = generateFileName(prefix = "${audioContent.id}-content")
|
||||
// 콘텐츠 파일명 생성
|
||||
val contentFileName = generateFileName(prefix = "${audioContent.id}-content")
|
||||
|
||||
// 콘텐츠 파일 업로드
|
||||
metadata = ObjectMetadata()
|
||||
metadata.contentLength = contentFile.size
|
||||
metadata.addUserMetadata(
|
||||
"generate_preview",
|
||||
if (request.price > 0) {
|
||||
request.isGeneratePreview.toString()
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
)
|
||||
|
||||
if (request.previewStartTime != null && request.previewEndTime != null) {
|
||||
metadata.addUserMetadata("preview_start_time", request.previewStartTime)
|
||||
metadata.addUserMetadata("preview_end_time", request.previewEndTime)
|
||||
// 콘텐츠 파일 업로드
|
||||
metadata = ObjectMetadata()
|
||||
metadata.contentLength = contentFile.size
|
||||
metadata.addUserMetadata(
|
||||
"generate_preview",
|
||||
if (request.price > 0) {
|
||||
request.isGeneratePreview.toString()
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
)
|
||||
|
||||
val contentPath = s3Uploader.upload(
|
||||
inputStream = contentFile.inputStream,
|
||||
bucket = audioContentBucket,
|
||||
filePath = "input/${audioContent.id}/$contentFileName",
|
||||
metadata = metadata
|
||||
)
|
||||
|
||||
audioContent.content = contentPath
|
||||
if (request.previewStartTime != null && request.previewEndTime != null) {
|
||||
metadata.addUserMetadata("preview_start_time", request.previewStartTime)
|
||||
metadata.addUserMetadata("preview_end_time", request.previewEndTime)
|
||||
}
|
||||
|
||||
if (request.childIds != null && request.type == AudioContentType.BUNDLE) {
|
||||
for (childId in request.childIds) {
|
||||
val childContent = repository.findByIdAndActive(childId)
|
||||
?: continue
|
||||
val contentPath = s3Uploader.upload(
|
||||
inputStream = contentFile.inputStream,
|
||||
bucket = audioContentBucket,
|
||||
filePath = "input/${audioContent.id}/$contentFileName",
|
||||
metadata = metadata
|
||||
)
|
||||
|
||||
val bundleAudioContent = BundleAudioContent()
|
||||
bundleAudioContent.parent = audioContent
|
||||
bundleAudioContent.child = childContent
|
||||
audioContent.children.add(bundleAudioContent)
|
||||
}
|
||||
}
|
||||
audioContent.content = contentPath
|
||||
|
||||
return CreateAudioContentResponse(contentId = audioContent.id!!)
|
||||
}
|
||||
|
@ -438,9 +413,6 @@ class AudioContentService(
|
|||
}
|
||||
|
||||
fun getDetail(id: Long, member: Member, timezone: String): GetAudioContentDetailResponse {
|
||||
// 묶음 콘텐츠 조회
|
||||
val bundleAudioContentList = repository.findBundleByContentId(contentId = id)
|
||||
|
||||
// 오디오 콘텐츠 조회 (content_id, 제목, 내용, 테마, 태그, 19여부, 이미지, 콘텐츠 PATH)
|
||||
val audioContent = repository.findByIdOrNull(id)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||
|
@ -455,23 +427,16 @@ class AudioContentService(
|
|||
memberId = member.id!!
|
||||
)
|
||||
|
||||
// 구매 여부 확인
|
||||
val isExistsBundleAudioContent = bundleAudioContentList
|
||||
.map { orderRepository.isExistOrdered(memberId = member.id!!, contentId = it.id!!) }
|
||||
.contains(true)
|
||||
|
||||
val (isExistsAudioContent, orderType) = orderRepository.isExistOrderedAndOrderType(
|
||||
memberId = member.id!!,
|
||||
contentId = audioContent.id!!
|
||||
)
|
||||
|
||||
val existOrdered = isExistsBundleAudioContent || isExistsAudioContent
|
||||
|
||||
// 차단된 사용자 체크
|
||||
val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = creatorId)
|
||||
if (isBlocked && !existOrdered) throw SodaException("${creator.nickname}님의 요청으로 콘텐츠 접근이 제한됩니다.")
|
||||
if (isBlocked && !isExistsAudioContent) throw SodaException("${creator.nickname}님의 요청으로 콘텐츠 접근이 제한됩니다.")
|
||||
|
||||
val orderSequence = if (existOrdered) {
|
||||
val orderSequence = if (isExistsAudioContent) {
|
||||
limitedEditionOrderRepository.getOrderSequence(
|
||||
contentId = audioContent.id!!,
|
||||
memberId = member.id!!
|
||||
|
@ -481,7 +446,7 @@ class AudioContentService(
|
|||
}
|
||||
|
||||
if (
|
||||
!existOrdered &&
|
||||
!isExistsAudioContent &&
|
||||
!audioContent.isActive &&
|
||||
audioContent.releaseDate != null &&
|
||||
audioContent.releaseDate!! < LocalDateTime.now()
|
||||
|
@ -536,7 +501,6 @@ class AudioContentService(
|
|||
audioContentCloudFront.generateSignedURL(
|
||||
resourcePath = if (
|
||||
isExistsAudioContent ||
|
||||
isExistsBundleAudioContent ||
|
||||
audioContent.member!!.id!! == member.id!! ||
|
||||
audioContent.price <= 0
|
||||
) {
|
||||
|
@ -622,7 +586,7 @@ class AudioContentService(
|
|||
isAdult = audioContent.isAdult,
|
||||
isMosaic = audioContent.isAdult && member.auth == null,
|
||||
isOnlyRental = audioContent.isOnlyRental,
|
||||
existOrdered = existOrdered,
|
||||
existOrdered = isExistsAudioContent,
|
||||
orderType = orderType,
|
||||
remainingTime = remainingTime,
|
||||
creatorOtherContentList = creatorOtherContentList,
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package kr.co.vividnext.sodalive.content
|
||||
|
||||
import kr.co.vividnext.sodalive.common.BaseEntity
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.FetchType
|
||||
import javax.persistence.JoinColumn
|
||||
import javax.persistence.ManyToOne
|
||||
import javax.persistence.Table
|
||||
|
||||
@Entity
|
||||
@Table(name = "bundle_content")
|
||||
data class BundleAudioContent(
|
||||
var isActive: Boolean = true
|
||||
) : BaseEntity() {
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "parent_content_id", nullable = false)
|
||||
var parent: AudioContent? = null
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "child_content_id", nullable = false)
|
||||
var child: AudioContent? = null
|
||||
}
|
|
@ -13,8 +13,6 @@ data class CreateAudioContentRequest(
|
|||
val isGeneratePreview: Boolean = false,
|
||||
val isOnlyRental: Boolean = false,
|
||||
val isCommentAvailable: Boolean = false,
|
||||
val type: AudioContentType = AudioContentType.INDIVIDUAL,
|
||||
val childIds: List<Long>? = null,
|
||||
val previewStartTime: String? = null,
|
||||
val previewEndTime: String? = null
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue