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