예약 업로드 배포 로직 위치 이동

This commit is contained in:
Klaus 2024-01-11 12:19:09 +09:00
parent 3e8476431d
commit afe529a116
2 changed files with 30 additions and 35 deletions

View File

@ -25,10 +25,7 @@ import java.time.temporal.TemporalAdjusters
@RestController @RestController
@RequestMapping("/audio-content") @RequestMapping("/audio-content")
class AudioContentController( class AudioContentController(private val service: AudioContentService) {
private val service: AudioContentService,
private val repository: AudioContentRepository
) {
@PostMapping @PostMapping
@PreAuthorize("hasRole('CREATOR')") @PreAuthorize("hasRole('CREATOR')")
fun createAudioContent( fun createAudioContent(
@ -197,12 +194,6 @@ class AudioContentController(
@PostMapping("/release") @PostMapping("/release")
@PreAuthorize("hasRole('BOT')") @PreAuthorize("hasRole('BOT')")
fun releaseContent() = run { fun releaseContent() = run {
val contentIdList = repository.getNotReleaseContentId() ApiResponse.ok(service.releaseContent())
for (contentId in contentIdList) {
service.releaseContent(contentId)
}
ApiResponse.ok(null)
} }
} }

View File

@ -387,35 +387,39 @@ class AudioContentService(
} }
@Transactional @Transactional
fun releaseContent(contentId: Long) { fun releaseContent() {
val audioContent = repository.findByIdOrNull(contentId) val contentIdList = repository.getNotReleaseContentId()
?: throw SodaException("잘못된 요청입니다.")
audioContent.isActive = true for (contentId in contentIdList) {
val audioContent = repository.findByIdOrNull(contentId)
?: throw SodaException("잘못된 요청입니다.")
applicationEventPublisher.publishEvent( audioContent.isActive = true
FcmEvent(
type = FcmEventType.UPLOAD_CONTENT, applicationEventPublisher.publishEvent(
title = audioContent.member!!.nickname, FcmEvent(
message = "콘텐츠를 업로드 하였습니다. - ${audioContent.title}", type = FcmEventType.UPLOAD_CONTENT,
isAuth = audioContent.isAdult, title = audioContent.member!!.nickname,
contentId = contentId, message = "콘텐츠를 업로드 하였습니다. - ${audioContent.title}",
creatorId = audioContent.member!!.id, isAuth = audioContent.isAdult,
container = "ios" contentId = contentId,
creatorId = audioContent.member!!.id,
container = "ios"
)
) )
)
applicationEventPublisher.publishEvent( applicationEventPublisher.publishEvent(
FcmEvent( FcmEvent(
type = FcmEventType.UPLOAD_CONTENT, type = FcmEventType.UPLOAD_CONTENT,
title = audioContent.member!!.nickname, title = audioContent.member!!.nickname,
message = "콘텐츠를 업로드 하였습니다. - ${audioContent.title}", message = "콘텐츠를 업로드 하였습니다. - ${audioContent.title}",
isAuth = audioContent.isAdult, isAuth = audioContent.isAdult,
contentId = contentId, contentId = contentId,
creatorId = audioContent.member!!.id, creatorId = audioContent.member!!.id,
container = "aos" container = "aos"
)
) )
) }
} }
fun getDetail(id: Long, member: Member, timezone: String): GetAudioContentDetailResponse { fun getDetail(id: Long, member: Member, timezone: String): GetAudioContentDetailResponse {