From e007a95982c0a1269b1c009fa804e3500c963876 Mon Sep 17 00:00:00 2001 From: Klaus <klaus@vividnext.co.kr> Date: Wed, 10 Jan 2024 21:45:44 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A4=EB=94=94=EC=98=A4=20=EC=BD=98?= =?UTF-8?q?=ED=85=90=EC=B8=A0=20=EC=98=88=EC=95=BD=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=20-=20=EC=98=88=EC=95=BD=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=20=ED=95=9C=20=EC=BD=98=ED=85=90=EC=B8=A0=20release?= =?UTF-8?q?=EC=99=80=20=ED=91=B8=EC=8B=9C=EB=B0=9C=EC=86=A1=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../content/AudioContentController.kt | 17 ++++++++- .../content/AudioContentRepository.kt | 14 ++++++++ .../sodalive/content/AudioContentService.kt | 35 ++++++++++++++++++- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentController.kt index 537f560..02e1e2d 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentController.kt @@ -25,7 +25,10 @@ import java.time.temporal.TemporalAdjusters @RestController @RequestMapping("/audio-content") -class AudioContentController(private val service: AudioContentService) { +class AudioContentController( + private val service: AudioContentService, + private val repository: AudioContentRepository +) { @PostMapping @PreAuthorize("hasRole('CREATOR')") 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) + } } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt index 033205b..34923ec 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentRepository.kt @@ -98,6 +98,8 @@ interface AudioContentQueryRepository { ): List<GetAudioContentRankingItem> fun getAudioContentCurationList(isAdult: Boolean, offset: Long, limit: Long): List<AudioContentCuration> + + fun getNotReleaseContentId(): List<Long> } @Repository @@ -581,4 +583,16 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) .orderBy(audioContentCuration.orders.asc()) .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() + } } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt index dc80529..d94a4d9 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt @@ -342,7 +342,6 @@ class AudioContentService( val audioContent = repository.findByIdOrNull(contentId) ?: throw SodaException("잘못된 요청입니다.") - audioContent.isActive = true audioContent.content = content audioContent.duration = duration @@ -358,6 +357,8 @@ class AudioContentService( ) if (audioContent.releaseDate == null) { + audioContent.isActive = true + applicationEventPublisher.publishEvent( FcmEvent( type = FcmEventType.UPLOAD_CONTENT, @@ -384,6 +385,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 { // 묶음 콘텐츠 조회 val bundleAudioContentList = repository.findBundleByContentId(contentId = id)