test #114

Merged
klaus merged 3 commits from test into main 2024-01-11 03:49:54 +00:00
5 changed files with 42 additions and 45 deletions

View File

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

View File

@ -387,35 +387,39 @@ class AudioContentService(
}
@Transactional
fun releaseContent(contentId: Long) {
val audioContent = repository.findByIdOrNull(contentId)
?: throw SodaException("잘못된 요청입니다.")
fun releaseContent() {
val contentIdList = repository.getNotReleaseContentId()
audioContent.isActive = true
for (contentId in contentIdList) {
val audioContent = repository.findByIdOrNull(contentId)
?: throw SodaException("잘못된 요청입니다.")
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"
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"
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 {

View File

@ -5,7 +5,7 @@ data class CreateAudioContentRequest(
val detail: String,
val tags: String,
val price: Int,
val timezone: String,
val timezone: String = "Asia/Seoul",
val releaseDate: String? = null,
val themeId: Long = 0,
val isAdult: Boolean = false,

View File

@ -186,13 +186,15 @@ class FcmSendListener(
FcmEventType.SEND_MESSAGE -> {
val response = memberRepository.getMessageRecipientPushToken(messageId = fcmEvent.messageId!!)
pushService.send(
tokens = listOf(response.pushToken),
title = fcmEvent.title,
message = fcmEvent.message,
container = response.container,
messageId = fcmEvent.messageId
)
if (response != null) {
pushService.send(
tokens = listOf(response.pushToken),
title = fcmEvent.title,
message = fcmEvent.message,
container = response.container,
messageId = fcmEvent.messageId
)
}
}
FcmEventType.CHANGE_NOTICE -> {

View File

@ -45,7 +45,7 @@ interface MemberQueryRepository {
container: String
): List<List<String>>
fun getMessageRecipientPushToken(messageId: Long): GetMessageRecipientPushTokenResponse
fun getMessageRecipientPushToken(messageId: Long): GetMessageRecipientPushTokenResponse?
fun getIndividualRecipientPushTokens(recipients: List<Long>, isAuth: Boolean?): Map<String, List<List<String>>>
fun getChangeNicknamePrice(memberId: Long): GetChangeNicknamePriceResponse
fun getMemberByEmail(email: String): Member?
@ -259,7 +259,7 @@ class MemberQueryRepositoryImpl(
.chunked(500)
}
override fun getMessageRecipientPushToken(messageId: Long): GetMessageRecipientPushTokenResponse {
override fun getMessageRecipientPushToken(messageId: Long): GetMessageRecipientPushTokenResponse? {
return queryFactory
.select(
QGetMessageRecipientPushTokenResponse(