Compare commits
3 Commits
ca2cc7a6b6
...
1a02f2383e
Author | SHA1 | Date |
---|---|---|
|
1a02f2383e | |
|
319893d60f | |
|
e007a95982 |
|
@ -25,7 +25,10 @@ import java.time.temporal.TemporalAdjusters
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/audio-content")
|
@RequestMapping("/audio-content")
|
||||||
class AudioContentController(private val service: AudioContentService) {
|
class AudioContentController(
|
||||||
|
private val service: AudioContentService,
|
||||||
|
private val repository: AudioContentRepository
|
||||||
|
) {
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("hasRole('CREATOR')")
|
@PreAuthorize("hasRole('CREATOR')")
|
||||||
fun createAudioContent(
|
fun createAudioContent(
|
||||||
|
@ -190,4 +193,16 @@ class AudioContentController(private val service: AudioContentService) {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/release")
|
||||||
|
@PreAuthorize("hasRole('BOT')")
|
||||||
|
fun releaseContent() = run {
|
||||||
|
val contentIdList = repository.getNotReleaseContentId()
|
||||||
|
|
||||||
|
contentIdList.forEach {
|
||||||
|
service.releaseContent(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
ApiResponse.ok(null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,8 @@ interface AudioContentQueryRepository {
|
||||||
): List<GetAudioContentRankingItem>
|
): List<GetAudioContentRankingItem>
|
||||||
|
|
||||||
fun getAudioContentCurationList(isAdult: Boolean, offset: Long, limit: Long): List<AudioContentCuration>
|
fun getAudioContentCurationList(isAdult: Boolean, offset: Long, limit: Long): List<AudioContentCuration>
|
||||||
|
|
||||||
|
fun getNotReleaseContentId(): List<Long>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -148,8 +150,11 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
SortType.PRICE_LOW -> audioContent.price.asc()
|
SortType.PRICE_LOW -> audioContent.price.asc()
|
||||||
}
|
}
|
||||||
|
|
||||||
var where = audioContent.isActive.isTrue
|
var where = audioContent.member.id.eq(creatorId)
|
||||||
.and(audioContent.member.id.eq(creatorId))
|
.and(
|
||||||
|
audioContent.isActive.isTrue
|
||||||
|
.or(audioContent.releaseDate.isNotNull)
|
||||||
|
)
|
||||||
|
|
||||||
if (!isAdult) {
|
if (!isAdult) {
|
||||||
where = where.and(audioContent.isAdult.isFalse)
|
where = where.and(audioContent.isAdult.isFalse)
|
||||||
|
@ -168,8 +173,11 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
creatorId: Long,
|
creatorId: Long,
|
||||||
isAdult: Boolean
|
isAdult: Boolean
|
||||||
): Int {
|
): Int {
|
||||||
var where = audioContent.isActive.isTrue
|
var where = audioContent.member.id.eq(creatorId)
|
||||||
.and(audioContent.member.id.eq(creatorId))
|
.and(
|
||||||
|
audioContent.isActive.isTrue
|
||||||
|
.or(audioContent.releaseDate.isNotNull)
|
||||||
|
)
|
||||||
|
|
||||||
if (!isAdult) {
|
if (!isAdult) {
|
||||||
where = where.and(audioContent.isAdult.isFalse)
|
where = where.and(audioContent.isAdult.isFalse)
|
||||||
|
@ -581,4 +589,16 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
.orderBy(audioContentCuration.orders.asc())
|
.orderBy(audioContentCuration.orders.asc())
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getNotReleaseContentId(): List<Long> {
|
||||||
|
val where = audioContent.isActive.isFalse
|
||||||
|
.and(audioContent.releaseDate.isNotNull)
|
||||||
|
.and(audioContent.releaseDate.loe(LocalDateTime.now()))
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(audioContent.id)
|
||||||
|
.from(audioContent)
|
||||||
|
.where(where)
|
||||||
|
.fetch()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,7 @@ class AudioContentService(
|
||||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||||
|
|
||||||
audioContent.isActive = false
|
audioContent.isActive = false
|
||||||
|
audioContent.releaseDate = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -342,7 +343,6 @@ class AudioContentService(
|
||||||
val audioContent = repository.findByIdOrNull(contentId)
|
val audioContent = repository.findByIdOrNull(contentId)
|
||||||
?: throw SodaException("잘못된 요청입니다.")
|
?: throw SodaException("잘못된 요청입니다.")
|
||||||
|
|
||||||
audioContent.isActive = true
|
|
||||||
audioContent.content = content
|
audioContent.content = content
|
||||||
audioContent.duration = duration
|
audioContent.duration = duration
|
||||||
|
|
||||||
|
@ -358,6 +358,8 @@ class AudioContentService(
|
||||||
)
|
)
|
||||||
|
|
||||||
if (audioContent.releaseDate == null) {
|
if (audioContent.releaseDate == null) {
|
||||||
|
audioContent.isActive = true
|
||||||
|
|
||||||
applicationEventPublisher.publishEvent(
|
applicationEventPublisher.publishEvent(
|
||||||
FcmEvent(
|
FcmEvent(
|
||||||
type = FcmEventType.UPLOAD_CONTENT,
|
type = FcmEventType.UPLOAD_CONTENT,
|
||||||
|
@ -384,6 +386,38 @@ class AudioContentService(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
fun releaseContent(contentId: Long) {
|
||||||
|
val audioContent = repository.findByIdOrNull(contentId)
|
||||||
|
?: throw SodaException("잘못된 요청입니다.")
|
||||||
|
|
||||||
|
audioContent.isActive = true
|
||||||
|
|
||||||
|
applicationEventPublisher.publishEvent(
|
||||||
|
FcmEvent(
|
||||||
|
type = FcmEventType.UPLOAD_CONTENT,
|
||||||
|
title = audioContent.member!!.nickname,
|
||||||
|
message = "콘텐츠를 업로드 하였습니다. - ${audioContent.title}",
|
||||||
|
isAuth = audioContent.isAdult,
|
||||||
|
contentId = contentId,
|
||||||
|
creatorId = audioContent.member!!.id,
|
||||||
|
container = "ios"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
applicationEventPublisher.publishEvent(
|
||||||
|
FcmEvent(
|
||||||
|
type = FcmEventType.UPLOAD_CONTENT,
|
||||||
|
title = audioContent.member!!.nickname,
|
||||||
|
message = "콘텐츠를 업로드 하였습니다. - ${audioContent.title}",
|
||||||
|
isAuth = audioContent.isAdult,
|
||||||
|
contentId = contentId,
|
||||||
|
creatorId = audioContent.member!!.id,
|
||||||
|
container = "aos"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun getDetail(id: Long, member: Member, timezone: String): GetAudioContentDetailResponse {
|
fun getDetail(id: Long, member: Member, timezone: String): GetAudioContentDetailResponse {
|
||||||
// 묶음 콘텐츠 조회
|
// 묶음 콘텐츠 조회
|
||||||
val bundleAudioContentList = repository.findBundleByContentId(contentId = id)
|
val bundleAudioContentList = repository.findBundleByContentId(contentId = id)
|
||||||
|
|
Loading…
Reference in New Issue