Compare commits
19 Commits
6fa0667120
...
60e654cda9
| Author | SHA1 | Date | |
|---|---|---|---|
| 60e654cda9 | |||
| e987a56544 | |||
| 9d619450ef | |||
| 6e8a88178c | |||
| 58f7a8654b | |||
| 7ef654e89d | |||
| 291f9a265b | |||
| f38382d2be | |||
| 4087d11420 | |||
| f429ffbbbe | |||
| 39d13ab7c3 | |||
| fd94df338b | |||
| 67b909daed | |||
| 4dcf9f6ed1 | |||
| 93e0411337 | |||
| 280b21c3cb | |||
| 14d0ae9851 | |||
| 8785741855 | |||
| ff1b8aa413 |
@@ -7,6 +7,8 @@ import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEvent
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
@@ -22,6 +24,8 @@ class AdminAuditionService(
|
||||
private val repository: AdminAuditionRepository,
|
||||
private val roleRepository: AdminAuditionRoleRepository,
|
||||
private val applicationEventPublisher: ApplicationEventPublisher,
|
||||
private val langContext: LangContext,
|
||||
private val messageSource: SodaMessageSource,
|
||||
|
||||
@Value("\${cloud.aws.s3.bucket}")
|
||||
private val bucket: String
|
||||
@@ -44,7 +48,7 @@ class AdminAuditionService(
|
||||
fun updateAudition(image: MultipartFile?, requestString: String) {
|
||||
val request = objectMapper.readValue(requestString, UpdateAuditionRequest::class.java)
|
||||
val audition = repository.findByIdOrNull(id = request.id)
|
||||
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "admin.audition.invalid_request_retry")
|
||||
|
||||
if (request.title != null) {
|
||||
audition.title = request.title
|
||||
@@ -63,7 +67,7 @@ class AdminAuditionService(
|
||||
(audition.status == AuditionStatus.COMPLETED || audition.status == AuditionStatus.IN_PROGRESS) &&
|
||||
request.status == AuditionStatus.NOT_STARTED
|
||||
) {
|
||||
throw SodaException("모집전 상태로 변경할 수 없습니다.")
|
||||
throw SodaException(messageKey = "admin.audition.status_cannot_revert")
|
||||
}
|
||||
|
||||
audition.status = request.status
|
||||
@@ -88,11 +92,14 @@ class AdminAuditionService(
|
||||
}
|
||||
|
||||
if (request.status != null && request.status == AuditionStatus.IN_PROGRESS && audition.isActive) {
|
||||
val title = messageSource.getMessage("admin.audition.fcm.title.new", langContext.lang).orEmpty()
|
||||
val messageTemplate = messageSource.getMessage("admin.audition.fcm.message.new", langContext.lang).orEmpty()
|
||||
val message = String.format(messageTemplate, audition.title)
|
||||
applicationEventPublisher.publishEvent(
|
||||
FcmEvent(
|
||||
type = FcmEventType.IN_PROGRESS_AUDITION,
|
||||
title = "새로운 오디션 등록!",
|
||||
message = "'${audition.title}'이 등록되었습니다. 지금 바로 오리지널 오디오 드라마 오디션에 지원해보세요!",
|
||||
title = title,
|
||||
message = message,
|
||||
isAuth = audition.isAdult,
|
||||
auditionId = audition.id ?: -1
|
||||
)
|
||||
|
||||
@@ -11,11 +11,11 @@ data class CreateAuditionRequest(
|
||||
) {
|
||||
init {
|
||||
if (title.isBlank()) {
|
||||
throw SodaException("오디션 제목을 입력하세요")
|
||||
throw SodaException(messageKey = "admin.audition.title_required")
|
||||
}
|
||||
|
||||
if (information.isBlank() || information.length < 10) {
|
||||
throw SodaException("오디션 정보는 최소 10글자 입니다")
|
||||
throw SodaException(messageKey = "admin.audition.information_min_length")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class AdminAuditionApplicantService(private val repository: AdminAuditionApplica
|
||||
@Transactional
|
||||
fun deleteAuditionApplicant(id: Long) {
|
||||
val applicant = repository.findByIdOrNull(id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
applicant.isActive = false
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class AdminAuditionRoleService(
|
||||
auditionScriptUrl = request.auditionScriptUrl
|
||||
)
|
||||
val audition = auditionRepository.findByIdOrNull(id = request.auditionId)
|
||||
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "admin.audition.invalid_request_retry")
|
||||
auditionRole.audition = audition
|
||||
repository.save(auditionRole)
|
||||
|
||||
@@ -48,15 +48,19 @@ class AdminAuditionRoleService(
|
||||
fun updateAuditionRole(image: MultipartFile?, requestString: String) {
|
||||
val request = objectMapper.readValue(requestString, UpdateAuditionRoleRequest::class.java)
|
||||
val auditionRole = repository.findByIdOrNull(id = request.id)
|
||||
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "admin.audition.invalid_request_retry")
|
||||
|
||||
if (!request.name.isNullOrBlank()) {
|
||||
if (request.name.length < 2) throw SodaException("배역 이름은 최소 2글자 입니다")
|
||||
if (request.name.length < 2) {
|
||||
throw SodaException(messageKey = "admin.audition.role.name_min_length")
|
||||
}
|
||||
auditionRole.name = request.name
|
||||
}
|
||||
|
||||
if (!request.information.isNullOrBlank()) {
|
||||
if (request.information.length < 10) throw SodaException("오디션 배역 정보는 최소 10글자 입니다")
|
||||
if (request.information.length < 10) {
|
||||
throw SodaException(messageKey = "admin.audition.role.information_min_length")
|
||||
}
|
||||
auditionRole.information = request.information
|
||||
}
|
||||
|
||||
|
||||
@@ -10,19 +10,19 @@ data class CreateAuditionRoleRequest(
|
||||
) {
|
||||
init {
|
||||
if (auditionId < 0) {
|
||||
throw SodaException("캐릭터가 등록될 오디션을 선택하세요")
|
||||
throw SodaException(messageKey = "admin.audition.role.audition_required")
|
||||
}
|
||||
|
||||
if (name.isBlank() || name.length < 2) {
|
||||
throw SodaException("캐릭터명을 입력하세요")
|
||||
throw SodaException(messageKey = "admin.audition.role.name_required")
|
||||
}
|
||||
|
||||
if (auditionScriptUrl.isBlank() || auditionScriptUrl.length < 10) {
|
||||
throw SodaException("오디션 대본 URL을 입력하세요")
|
||||
throw SodaException(messageKey = "admin.audition.role.script_url_required")
|
||||
}
|
||||
|
||||
if (information.isBlank() || information.length < 10) {
|
||||
throw SodaException("오디션 캐릭터 정보는 최소 10글자 입니다")
|
||||
throw SodaException(messageKey = "admin.audition.role.information_required")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ data class UpdateAuditionRoleRequest(
|
||||
) {
|
||||
init {
|
||||
if (id < 0) {
|
||||
throw SodaException("잘못된 요청입니다.")
|
||||
throw SodaException(messageKey = "common.error.invalid_request")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ class CreatorSettlementRatioService(
|
||||
@Transactional
|
||||
fun createCreatorSettlementRatio(request: CreateCreatorSettlementRatioRequest) {
|
||||
val creator = memberRepository.findByIdOrNull(request.memberId)
|
||||
?: throw SodaException("잘못된 크리에이터 입니다.")
|
||||
?: throw SodaException(messageKey = "admin.settlement_ratio.invalid_creator")
|
||||
|
||||
if (creator.role != MemberRole.CREATOR) {
|
||||
throw SodaException("잘못된 크리에이터 입니다.")
|
||||
throw SodaException(messageKey = "admin.settlement_ratio.invalid_creator")
|
||||
}
|
||||
|
||||
val existing = repository.findByMemberId(request.memberId)
|
||||
@@ -43,12 +43,12 @@ class CreatorSettlementRatioService(
|
||||
@Transactional
|
||||
fun updateCreatorSettlementRatio(request: CreateCreatorSettlementRatioRequest) {
|
||||
val creator = memberRepository.findByIdOrNull(request.memberId)
|
||||
?: throw SodaException("잘못된 크리에이터 입니다.")
|
||||
?: throw SodaException(messageKey = "admin.settlement_ratio.invalid_creator")
|
||||
if (creator.role != MemberRole.CREATOR) {
|
||||
throw SodaException("잘못된 크리에이터 입니다.")
|
||||
throw SodaException(messageKey = "admin.settlement_ratio.invalid_creator")
|
||||
}
|
||||
val existing = repository.findByMemberId(request.memberId)
|
||||
?: throw SodaException("해당 크리에이터의 정산 비율 설정이 없습니다.")
|
||||
?: throw SodaException(messageKey = "admin.settlement_ratio.not_found")
|
||||
existing.restore()
|
||||
existing.updateValues(
|
||||
request.subsidy,
|
||||
@@ -62,7 +62,7 @@ class CreatorSettlementRatioService(
|
||||
@Transactional
|
||||
fun deleteCreatorSettlementRatio(memberId: Long) {
|
||||
val existing = repository.findByMemberId(memberId)
|
||||
?: throw SodaException("해당 크리에이터의 정산 비율 설정이 없습니다.")
|
||||
?: throw SodaException(messageKey = "admin.settlement_ratio.not_found")
|
||||
existing.softDelete()
|
||||
repository.save(existing)
|
||||
}
|
||||
|
||||
@@ -33,21 +33,21 @@ class AdminCanService(
|
||||
@Transactional
|
||||
fun deleteCan(id: Long) {
|
||||
val can = repository.findByIdOrNull(id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
can.status = CanStatus.END_OF_SALE
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun charge(request: AdminCanChargeRequest) {
|
||||
if (request.can <= 0) throw SodaException("1 캔 이상 입력하세요.")
|
||||
if (request.method.isBlank()) throw SodaException("기록내용을 입력하세요.")
|
||||
if (request.can <= 0) throw SodaException(messageKey = "admin.can.min_amount")
|
||||
if (request.method.isBlank()) throw SodaException(messageKey = "admin.can.method_required")
|
||||
|
||||
val ids = request.memberIds.distinct()
|
||||
if (ids.isEmpty()) throw SodaException("회원번호를 입력하세요.")
|
||||
if (ids.isEmpty()) throw SodaException(messageKey = "admin.can.member_ids_required")
|
||||
|
||||
val members = memberRepository.findAllById(ids).toList()
|
||||
if (members.size != ids.size) throw SodaException("잘못된 회원번호 입니다.")
|
||||
if (members.size != ids.size) throw SodaException(messageKey = "admin.can.invalid_member_ids")
|
||||
|
||||
members.forEach { member ->
|
||||
val charge = Charge(0, request.can, status = ChargeStatus.ADMIN)
|
||||
|
||||
@@ -13,6 +13,8 @@ import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
||||
import kr.co.vividnext.sodalive.chat.character.service.ChatCharacterBannerService
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
@@ -35,6 +37,8 @@ class AdminChatBannerController(
|
||||
private val bannerService: ChatCharacterBannerService,
|
||||
private val adminCharacterService: AdminChatCharacterService,
|
||||
private val s3Uploader: S3Uploader,
|
||||
private val langContext: LangContext,
|
||||
private val messageSource: SodaMessageSource,
|
||||
|
||||
@Value("\${cloud.aws.s3.bucket}")
|
||||
private val s3Bucket: String,
|
||||
@@ -158,8 +162,8 @@ class AdminChatBannerController(
|
||||
filePath = "characters/banners/$bannerId/$fileName",
|
||||
metadata = metadata
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
throw SodaException("이미지 저장에 실패했습니다: ${e.message}")
|
||||
} catch (_: Exception) {
|
||||
throw SodaException(messageKey = "admin.chat.banner.image_save_failed")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +212,8 @@ class AdminChatBannerController(
|
||||
fun deleteBanner(@PathVariable bannerId: Long) = run {
|
||||
bannerService.deleteBanner(bannerId)
|
||||
|
||||
ApiResponse.ok("배너가 성공적으로 삭제되었습니다.")
|
||||
val message = messageSource.getMessage("admin.chat.banner.delete_success", langContext.lang)
|
||||
ApiResponse.ok(message)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,6 +229,7 @@ class AdminChatBannerController(
|
||||
) = run {
|
||||
bannerService.updateBannerOrders(request.ids)
|
||||
|
||||
ApiResponse.ok(null, "배너 정렬 순서가 성공적으로 변경되었습니다.")
|
||||
val message = messageSource.getMessage("admin.chat.banner.reorder_success", langContext.lang)
|
||||
ApiResponse.ok(null, message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ class AdminChatCalculateService(
|
||||
val todayKst = LocalDate.now(kstZone)
|
||||
|
||||
if (endDate.isAfter(todayKst)) {
|
||||
throw SodaException("끝 날짜는 오늘 날짜까지만 입력 가능합니다.")
|
||||
throw SodaException(messageKey = "admin.chat.calculate.end_date_max_today")
|
||||
}
|
||||
if (startDate.isAfter(endDate)) {
|
||||
throw SodaException("시작 날짜는 끝 날짜보다 이후일 수 없습니다.")
|
||||
throw SodaException(messageKey = "admin.chat.calculate.start_date_after_end")
|
||||
}
|
||||
if (endDate.isAfter(startDate.plusMonths(6))) {
|
||||
throw SodaException("조회 가능 기간은 최대 6개월입니다.")
|
||||
throw SodaException(messageKey = "admin.chat.calculate.max_period_6_months")
|
||||
}
|
||||
|
||||
val startUtc = startDateStr.convertLocalDateTime()
|
||||
|
||||
@@ -124,7 +124,7 @@ class AdminChatCharacterController(
|
||||
// 외부 API 호출 전 DB에 동일한 이름이 있는지 조회
|
||||
val existingCharacter = service.findByName(request.name)
|
||||
if (existingCharacter != null) {
|
||||
throw SodaException("동일한 이름은 등록이 불가능합니다: ${request.name}")
|
||||
throw SodaException(messageKey = "admin.chat.character.duplicate_name")
|
||||
}
|
||||
|
||||
// 1. 외부 API 호출
|
||||
@@ -233,14 +233,18 @@ class AdminChatCharacterController(
|
||||
|
||||
// success가 false이면 throw
|
||||
if (!apiResponse.success) {
|
||||
throw SodaException(apiResponse.message ?: "등록에 실패했습니다. 다시 시도해 주세요.")
|
||||
val apiMessage = apiResponse.message
|
||||
if (apiMessage.isNullOrBlank()) {
|
||||
throw SodaException(messageKey = "admin.chat.character.register_failed_retry")
|
||||
}
|
||||
throw SodaException(apiMessage)
|
||||
}
|
||||
|
||||
// success가 true이면 data.id 반환
|
||||
return apiResponse.data?.id ?: throw SodaException("등록에 실패했습니다. 응답에 ID가 없습니다.")
|
||||
return apiResponse.data?.id ?: throw SodaException(messageKey = "admin.chat.character.register_failed_no_id")
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
throw SodaException("${e.message}, 등록에 실패했습니다. 다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "admin.chat.character.register_failed_retry")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +261,7 @@ class AdminChatCharacterController(
|
||||
metadata = metadata
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
throw SodaException("이미지 저장에 실패했습니다: ${e.message}")
|
||||
throw SodaException(messageKey = "admin.chat.character.image_save_failed")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,19 +301,19 @@ class AdminChatCharacterController(
|
||||
request.originalWorkId != null
|
||||
|
||||
if (!hasChangedData && !hasImage && !hasDbOnlyChanges) {
|
||||
throw SodaException("변경된 데이터가 없습니다.")
|
||||
throw SodaException(messageKey = "admin.chat.character.no_changes")
|
||||
}
|
||||
|
||||
// 외부 API로 전달할 변경이 있을 때만 외부 API 호출(3가지 필드만 변경된 경우는 호출하지 않음)
|
||||
if (hasChangedData) {
|
||||
val chatCharacter = service.findById(request.id)
|
||||
?: throw SodaException("해당 ID의 캐릭터를 찾을 수 없습니다: ${request.id}")
|
||||
?: throw SodaException(messageKey = "admin.chat.character.not_found")
|
||||
|
||||
// 이름이 수정된 경우 DB에 동일한 이름이 있는지 확인
|
||||
if (request.name != null && request.name != chatCharacter.name) {
|
||||
val existingCharacter = service.findByName(request.name)
|
||||
if (existingCharacter != null) {
|
||||
throw SodaException("동일한 이름은 등록이 불가능합니다: ${request.name}")
|
||||
throw SodaException(messageKey = "admin.chat.character.duplicate_name")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,11 +442,15 @@ class AdminChatCharacterController(
|
||||
|
||||
// success가 false이면 throw
|
||||
if (!apiResponse.success) {
|
||||
throw SodaException(apiResponse.message ?: "수정에 실패했습니다. 다시 시도해 주세요.")
|
||||
val apiMessage = apiResponse.message
|
||||
if (apiMessage.isNullOrBlank()) {
|
||||
throw SodaException(messageKey = "admin.chat.character.update_failed_retry")
|
||||
}
|
||||
throw SodaException(apiMessage)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
throw SodaException("${e.message} 수정에 실패했습니다. 다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "admin.chat.character.update_failed_retry")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class CharacterCurationAdminController(
|
||||
@RequestBody request: CharacterCurationAddCharacterRequest
|
||||
): ApiResponse<Boolean> {
|
||||
val ids = request.characterIds.filter { it > 0 }.distinct()
|
||||
if (ids.isEmpty()) throw SodaException("등록할 캐릭터 ID 리스트가 비어있습니다")
|
||||
if (ids.isEmpty()) throw SodaException(messageKey = "admin.chat.curation.character_ids_empty")
|
||||
service.addCharacters(curationId, ids)
|
||||
return ApiResponse.ok(true)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class CharacterCurationAdminService(
|
||||
@Transactional
|
||||
fun update(request: CharacterCurationUpdateRequest): CharacterCuration {
|
||||
val curation = curationRepository.findById(request.id)
|
||||
.orElseThrow { SodaException("큐레이션을 찾을 수 없습니다: ${request.id}") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.curation.not_found") }
|
||||
|
||||
request.title?.let { curation.title = it }
|
||||
request.isAdult?.let { curation.isAdult = it }
|
||||
@@ -44,7 +44,7 @@ class CharacterCurationAdminService(
|
||||
@Transactional
|
||||
fun softDelete(curationId: Long) {
|
||||
val curation = curationRepository.findById(curationId)
|
||||
.orElseThrow { SodaException("큐레이션을 찾을 수 없습니다: $curationId") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.curation.not_found") }
|
||||
curation.isActive = false
|
||||
curationRepository.save(curation)
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class CharacterCurationAdminService(
|
||||
fun reorder(ids: List<Long>) {
|
||||
ids.forEachIndexed { index, id ->
|
||||
val curation = curationRepository.findById(id)
|
||||
.orElseThrow { SodaException("큐레이션을 찾을 수 없습니다: $id") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.curation.not_found") }
|
||||
curation.sortOrder = index + 1
|
||||
curationRepository.save(curation)
|
||||
}
|
||||
@@ -61,14 +61,14 @@ class CharacterCurationAdminService(
|
||||
|
||||
@Transactional
|
||||
fun addCharacters(curationId: Long, characterIds: List<Long>) {
|
||||
if (characterIds.isEmpty()) throw SodaException("등록할 캐릭터 ID 리스트가 비어있습니다")
|
||||
if (characterIds.isEmpty()) throw SodaException(messageKey = "admin.chat.curation.character_ids_empty")
|
||||
|
||||
val curation = curationRepository.findById(curationId)
|
||||
.orElseThrow { SodaException("큐레이션을 찾을 수 없습니다: $curationId") }
|
||||
if (!curation.isActive) throw SodaException("비활성화된 큐레이션입니다: $curationId")
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.curation.not_found") }
|
||||
if (!curation.isActive) throw SodaException(messageKey = "admin.chat.curation.inactive")
|
||||
|
||||
val uniqueIds = characterIds.filter { it > 0 }.distinct()
|
||||
if (uniqueIds.isEmpty()) throw SodaException("유효한 캐릭터 ID가 없습니다")
|
||||
if (uniqueIds.isEmpty()) throw SodaException(messageKey = "admin.chat.curation.invalid_character_ids")
|
||||
|
||||
// 활성 캐릭터만 조회 (조회 단계에서 검증 포함)
|
||||
val characters = characterRepository.findByIdInAndIsActiveTrue(uniqueIds)
|
||||
@@ -101,23 +101,23 @@ class CharacterCurationAdminService(
|
||||
@Transactional
|
||||
fun removeCharacter(curationId: Long, characterId: Long) {
|
||||
val curation = curationRepository.findById(curationId)
|
||||
.orElseThrow { SodaException("큐레이션을 찾을 수 없습니다: $curationId") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.curation.not_found") }
|
||||
val mappings = mappingRepository.findByCuration(curation)
|
||||
val target = mappings.firstOrNull { it.chatCharacter.id == characterId }
|
||||
?: throw SodaException("매핑을 찾을 수 없습니다: curation=$curationId, character=$characterId")
|
||||
?: throw SodaException(messageKey = "admin.chat.curation.mapping_not_found")
|
||||
mappingRepository.delete(target)
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun reorderCharacters(curationId: Long, characterIds: List<Long>) {
|
||||
val curation = curationRepository.findById(curationId)
|
||||
.orElseThrow { SodaException("큐레이션을 찾을 수 없습니다: $curationId") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.curation.not_found") }
|
||||
val mappings = mappingRepository.findByCuration(curation)
|
||||
val mappingByCharacterId = mappings.associateBy { it.chatCharacter.id }
|
||||
|
||||
characterIds.forEachIndexed { index, cid ->
|
||||
val mapping = mappingByCharacterId[cid]
|
||||
?: throw SodaException("큐레이션에 포함되지 않은 캐릭터입니다: $cid")
|
||||
?: throw SodaException(messageKey = "admin.chat.curation.character_not_in_curation")
|
||||
mapping.sortOrder = index + 1
|
||||
mappingRepository.save(mapping)
|
||||
}
|
||||
@@ -146,7 +146,7 @@ class CharacterCurationAdminService(
|
||||
@Transactional(readOnly = true)
|
||||
fun listCharacters(curationId: Long): List<ChatCharacter> {
|
||||
val curation = curationRepository.findById(curationId)
|
||||
.orElseThrow { SodaException("큐레이션을 찾을 수 없습니다: $curationId") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.curation.not_found") }
|
||||
val mappings = mappingRepository.findByCurationWithCharacterOrderBySortOrderAsc(curation)
|
||||
return mappings.map { it.chatCharacter }
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
||||
import kr.co.vividnext.sodalive.chat.character.image.CharacterImageService
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.utils.ImageBlurUtil
|
||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
@@ -34,6 +36,8 @@ class AdminCharacterImageController(
|
||||
private val imageService: CharacterImageService,
|
||||
private val s3Uploader: S3Uploader,
|
||||
private val imageCloudFront: ImageContentCloudFront,
|
||||
private val langContext: LangContext,
|
||||
private val messageSource: SodaMessageSource,
|
||||
|
||||
@Value("\${cloud.aws.s3.content-bucket}")
|
||||
private val s3Bucket: String,
|
||||
@@ -106,14 +110,18 @@ class AdminCharacterImageController(
|
||||
@DeleteMapping("/{imageId}")
|
||||
fun delete(@PathVariable imageId: Long) = run {
|
||||
imageService.deleteImage(imageId)
|
||||
ApiResponse.ok(null, "이미지가 삭제되었습니다.")
|
||||
val message = messageSource.getMessage("admin.chat.character.image_deleted", langContext.lang)
|
||||
ApiResponse.ok(null, message)
|
||||
}
|
||||
|
||||
@PutMapping("/orders")
|
||||
fun updateOrders(@RequestBody request: UpdateCharacterImageOrdersRequest) = run {
|
||||
if (request.characterId == null) throw SodaException("characterId는 필수입니다")
|
||||
if (request.characterId == null) {
|
||||
throw SodaException(messageKey = "admin.chat.character.character_id_required")
|
||||
}
|
||||
imageService.updateOrders(request.characterId, request.ids)
|
||||
ApiResponse.ok(null, "정렬 순서가 변경되었습니다.")
|
||||
val message = messageSource.getMessage("admin.chat.character.order_updated", langContext.lang)
|
||||
ApiResponse.ok(null, message)
|
||||
}
|
||||
|
||||
private fun buildS3Key(characterId: Long): String {
|
||||
@@ -132,7 +140,7 @@ class AdminCharacterImageController(
|
||||
metadata = metadata
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
throw SodaException("이미지 저장에 실패했습니다: ${e.message}")
|
||||
throw SodaException(messageKey = "admin.chat.character.image_save_failed")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +149,7 @@ class AdminCharacterImageController(
|
||||
// 멀티파트를 BufferedImage로 읽기
|
||||
val bytes = image.bytes
|
||||
val bimg = javax.imageio.ImageIO.read(java.io.ByteArrayInputStream(bytes))
|
||||
?: throw SodaException("이미지 포맷을 인식할 수 없습니다.")
|
||||
?: throw SodaException(messageKey = "admin.chat.character.image_format_invalid")
|
||||
val blurred = ImageBlurUtil.blurFast(bimg)
|
||||
|
||||
// PNG로 저장(알파 유지), JPEG 업로드가 필요하면 포맷 변경 가능
|
||||
@@ -164,7 +172,7 @@ class AdminCharacterImageController(
|
||||
metadata = metadata
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
throw SodaException("블러 이미지 저장에 실패했습니다: ${e.message}")
|
||||
throw SodaException(messageKey = "admin.chat.character.blur_image_save_failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class AdminChatCharacterService(
|
||||
@Transactional(readOnly = true)
|
||||
fun getChatCharacterDetail(characterId: Long, imageHost: String = ""): ChatCharacterDetailResponse {
|
||||
val chatCharacter = chatCharacterRepository.findById(characterId)
|
||||
.orElseThrow { SodaException("해당 ID의 캐릭터를 찾을 수 없습니다: $characterId") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.character.not_found") }
|
||||
|
||||
return ChatCharacterDetailResponse.from(chatCharacter, imageHost)
|
||||
}
|
||||
|
||||
@@ -192,8 +192,8 @@ class AdminOriginalWorkController(
|
||||
filePath = "originals/$originalWorkId/${generateFileName(prefix = "original")}",
|
||||
metadata = metadata
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
throw SodaException("이미지 저장에 실패했습니다: ${e.message}")
|
||||
} catch (_: Exception) {
|
||||
throw SodaException(messageKey = "admin.chat.original.image_save_failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class AdminOriginalWorkService(
|
||||
@Transactional
|
||||
fun createOriginalWork(request: OriginalWorkRegisterRequest): OriginalWork {
|
||||
originalWorkRepository.findByTitleAndIsDeletedFalse(request.title)?.let {
|
||||
throw SodaException("동일한 제목의 원작이 이미 존재합니다: ${request.title}")
|
||||
throw SodaException(messageKey = "admin.chat.original.duplicate_title")
|
||||
}
|
||||
val entity = OriginalWork(
|
||||
title = request.title,
|
||||
@@ -107,7 +107,7 @@ class AdminOriginalWorkService(
|
||||
@Transactional
|
||||
fun updateOriginalWork(request: OriginalWorkUpdateRequest, imagePath: String? = null): OriginalWork {
|
||||
val ow = originalWorkRepository.findByIdAndIsDeletedFalse(request.id)
|
||||
.orElseThrow { SodaException("해당 원작을 찾을 수 없습니다") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.original.not_found") }
|
||||
|
||||
request.title?.let { ow.title = it }
|
||||
request.contentType?.let { ow.contentType = it }
|
||||
@@ -177,7 +177,7 @@ class AdminOriginalWorkService(
|
||||
@Transactional
|
||||
fun updateOriginalWorkImage(originalWorkId: Long, imagePath: String): OriginalWork {
|
||||
val ow = originalWorkRepository.findByIdAndIsDeletedFalse(originalWorkId)
|
||||
.orElseThrow { SodaException("해당 원작을 찾을 수 없습니다") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.original.not_found") }
|
||||
ow.imagePath = imagePath
|
||||
return originalWorkRepository.save(ow)
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class AdminOriginalWorkService(
|
||||
@Transactional
|
||||
fun deleteOriginalWork(id: Long) {
|
||||
val ow = originalWorkRepository.findByIdAndIsDeletedFalse(id)
|
||||
.orElseThrow { SodaException("해당 원작을 찾을 수 없습니다: $id") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.original.not_found") }
|
||||
ow.isDeleted = true
|
||||
originalWorkRepository.save(ow)
|
||||
}
|
||||
@@ -195,7 +195,7 @@ class AdminOriginalWorkService(
|
||||
@Transactional(readOnly = true)
|
||||
fun getOriginalWork(id: Long): OriginalWork {
|
||||
return originalWorkRepository.findByIdAndIsDeletedFalse(id)
|
||||
.orElseThrow { SodaException("해당 원작을 찾을 수 없습니다") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.original.not_found") }
|
||||
}
|
||||
|
||||
/** 원작 페이징 조회 */
|
||||
@@ -216,7 +216,7 @@ class AdminOriginalWorkService(
|
||||
fun getCharactersOfOriginalWorkPage(originalWorkId: Long, page: Int, size: Int): Page<ChatCharacter> {
|
||||
// 원작 존재 및 소프트 삭제 여부 확인
|
||||
originalWorkRepository.findByIdAndIsDeletedFalse(originalWorkId)
|
||||
.orElseThrow { SodaException("해당 원작을 찾을 수 없습니다") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.original.not_found") }
|
||||
|
||||
val safePage = if (page < 0) 0 else page
|
||||
val safeSize = when {
|
||||
@@ -238,7 +238,7 @@ class AdminOriginalWorkService(
|
||||
@Transactional
|
||||
fun assignCharacters(originalWorkId: Long, characterIds: List<Long>) {
|
||||
val ow = originalWorkRepository.findByIdAndIsDeletedFalse(originalWorkId)
|
||||
.orElseThrow { SodaException("해당 원작을 찾을 수 없습니다") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.original.not_found") }
|
||||
if (characterIds.isEmpty()) return
|
||||
val characters = chatCharacterRepository.findByIdInAndIsActiveTrue(characterIds)
|
||||
characters.forEach { it.originalWork = ow }
|
||||
@@ -250,7 +250,7 @@ class AdminOriginalWorkService(
|
||||
fun unassignCharacters(originalWorkId: Long, characterIds: List<Long>) {
|
||||
// 원작 존재 확인 (소프트 삭제 제외)
|
||||
originalWorkRepository.findByIdAndIsDeletedFalse(originalWorkId)
|
||||
.orElseThrow { SodaException("해당 원작을 찾을 수 없습니다") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.original.not_found") }
|
||||
if (characterIds.isEmpty()) return
|
||||
val characters = chatCharacterRepository.findByIdInAndIsActiveTrue(characterIds)
|
||||
characters.forEach { it.originalWork = null }
|
||||
@@ -261,13 +261,13 @@ class AdminOriginalWorkService(
|
||||
@Transactional
|
||||
fun assignOneCharacter(originalWorkId: Long, characterId: Long) {
|
||||
val character = chatCharacterRepository.findById(characterId)
|
||||
.orElseThrow { SodaException("해당 캐릭터를 찾을 수 없습니다") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.character.not_found") }
|
||||
|
||||
if (originalWorkId == 0L) {
|
||||
character.originalWork = null
|
||||
} else {
|
||||
val ow = originalWorkRepository.findByIdAndIsDeletedFalse(originalWorkId)
|
||||
.orElseThrow { SodaException("해당 원작을 찾을 수 없습니다") }
|
||||
.orElseThrow { SodaException(messageKey = "admin.chat.original.not_found") }
|
||||
character.originalWork = ow
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,9 @@ class AdminContentService(
|
||||
searchWord: String,
|
||||
pageable: Pageable
|
||||
): GetAdminContentListResponse {
|
||||
if (searchWord.length < 2) throw SodaException("2글자 이상 입력하세요.")
|
||||
if (searchWord.length < 2) {
|
||||
throw SodaException(messageKey = "admin.content.search_word_min_length")
|
||||
}
|
||||
val totalCount = repository.getAudioContentTotalCount(searchWord, status = status)
|
||||
val audioContentAndThemeList = repository.getAudioContentList(
|
||||
status = status,
|
||||
@@ -82,7 +84,7 @@ class AdminContentService(
|
||||
@Transactional
|
||||
fun updateAudioContent(request: UpdateAdminContentRequest) {
|
||||
val audioContent = repository.findByIdOrNull(id = request.id)
|
||||
?: throw SodaException("없는 콘텐츠 입니다.")
|
||||
?: throw SodaException(messageKey = "admin.content.not_found")
|
||||
|
||||
if (request.isDefaultCoverImage) {
|
||||
audioContent.coverImage = "`profile/default_profile.png`"
|
||||
|
||||
@@ -33,19 +33,19 @@ class AdminContentBannerService(
|
||||
fun createAudioContentMainBanner(image: MultipartFile, requestString: String) {
|
||||
val request = objectMapper.readValue(requestString, CreateContentBannerRequest::class.java)
|
||||
if (request.type == AudioContentBannerType.CREATOR && request.creatorId == null) {
|
||||
throw SodaException("크리에이터를 선택하세요.")
|
||||
throw SodaException(messageKey = "admin.content.banner.creator_required")
|
||||
}
|
||||
|
||||
if (request.type == AudioContentBannerType.SERIES && request.seriesId == null) {
|
||||
throw SodaException("시리즈를 선택하세요.")
|
||||
throw SodaException(messageKey = "admin.content.banner.series_required")
|
||||
}
|
||||
|
||||
if (request.type == AudioContentBannerType.LINK && request.link == null) {
|
||||
throw SodaException("링크 url을 입력하세요.")
|
||||
throw SodaException(messageKey = "admin.content.banner.link_required")
|
||||
}
|
||||
|
||||
if (request.type == AudioContentBannerType.EVENT && request.eventId == null) {
|
||||
throw SodaException("이벤트를 선택하세요.")
|
||||
throw SodaException(messageKey = "admin.content.banner.event_required")
|
||||
}
|
||||
|
||||
val event = if (request.eventId != null && request.eventId > 0) {
|
||||
@@ -94,7 +94,7 @@ class AdminContentBannerService(
|
||||
fun updateAudioContentMainBanner(image: MultipartFile?, requestString: String) {
|
||||
val request = objectMapper.readValue(requestString, UpdateContentBannerRequest::class.java)
|
||||
val audioContentBanner = repository.findByIdOrNull(request.id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (image != null) {
|
||||
val fileName = generateFileName()
|
||||
@@ -124,22 +124,22 @@ class AdminContentBannerService(
|
||||
AudioContentBannerType.EVENT -> {
|
||||
if (request.eventId != null) {
|
||||
val event = eventRepository.findByIdOrNull(request.eventId)
|
||||
?: throw SodaException("이벤트를 선택하세요.")
|
||||
?: throw SodaException(messageKey = "admin.content.banner.event_required")
|
||||
|
||||
audioContentBanner.event = event
|
||||
} else {
|
||||
throw SodaException("이벤트를 선택하세요.")
|
||||
throw SodaException(messageKey = "admin.content.banner.event_required")
|
||||
}
|
||||
}
|
||||
|
||||
AudioContentBannerType.CREATOR -> {
|
||||
if (request.creatorId != null) {
|
||||
val creator = memberRepository.findByIdOrNull(request.creatorId)
|
||||
?: throw SodaException("크리에이터를 선택하세요.")
|
||||
?: throw SodaException(messageKey = "admin.content.banner.creator_required")
|
||||
|
||||
audioContentBanner.creator = creator
|
||||
} else {
|
||||
throw SodaException("크리에이터를 선택하세요.")
|
||||
throw SodaException(messageKey = "admin.content.banner.creator_required")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,18 +147,18 @@ class AdminContentBannerService(
|
||||
if (request.link != null) {
|
||||
audioContentBanner.link = request.link
|
||||
} else {
|
||||
throw SodaException("링크 url을 입력하세요.")
|
||||
throw SodaException(messageKey = "admin.content.banner.link_required")
|
||||
}
|
||||
}
|
||||
|
||||
AudioContentBannerType.SERIES -> {
|
||||
if (request.seriesId != null) {
|
||||
val series = seriesRepository.findByIdOrNull(request.seriesId)
|
||||
?: throw SodaException("시리즈를 선택하세요.")
|
||||
?: throw SodaException(messageKey = "admin.content.banner.series_required")
|
||||
|
||||
audioContentBanner.series = series
|
||||
} else {
|
||||
throw SodaException("시리즈를 선택하세요.")
|
||||
throw SodaException(messageKey = "admin.content.banner.series_required")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class AdminContentCurationService(
|
||||
@Transactional
|
||||
fun createContentCuration(request: CreateContentCurationRequest) {
|
||||
val tab = contentMainTabRepository.findByIdOrNull(request.tabId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
val curation = AudioContentCuration(
|
||||
title = request.title,
|
||||
@@ -37,7 +37,7 @@ class AdminContentCurationService(
|
||||
@Transactional
|
||||
fun updateContentCuration(request: UpdateContentCurationRequest) {
|
||||
val audioContentCuration = repository.findByIdOrNull(id = request.id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (request.title != null) {
|
||||
audioContentCuration.title = request.title
|
||||
@@ -85,7 +85,7 @@ class AdminContentCurationService(
|
||||
|
||||
fun getCurationItem(curationId: Long): List<GetCurationItemResponse> {
|
||||
val curation = repository.findByIdOrNull(curationId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
return if (curation.isSeries) {
|
||||
contentCurationItemRepository.getAudioContentCurationSeriesItemList(curationId)
|
||||
@@ -106,7 +106,7 @@ class AdminContentCurationService(
|
||||
fun addItemToCuration(request: AddItemToCurationRequest) {
|
||||
// 큐레이션 조회
|
||||
val audioContentCuration = repository.findByIdOrNull(id = request.curationId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (audioContentCuration.isSeries) {
|
||||
request.itemIdList.forEach { seriesId ->
|
||||
|
||||
@@ -28,7 +28,7 @@ class AdminHashTagCurationService(
|
||||
val isExists = repository.isExistsTag(tag = tag)
|
||||
|
||||
if (isExists) {
|
||||
throw SodaException("이미 등록된 태그 입니다.")
|
||||
throw SodaException(messageKey = "admin.content.hash_tag.already_registered")
|
||||
}
|
||||
|
||||
repository.save(
|
||||
@@ -42,7 +42,7 @@ class AdminHashTagCurationService(
|
||||
@Transactional
|
||||
fun updateContentHashTagCuration(request: UpdateContentHashTagCurationRequest) {
|
||||
val hashTagCuration = repository.findByIdOrNull(id = request.id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (request.tag != null) {
|
||||
var tag = request.tag.trim()
|
||||
@@ -88,7 +88,7 @@ class AdminHashTagCurationService(
|
||||
@Transactional
|
||||
fun addItemToHashTagCuration(request: AddItemToCurationRequest) {
|
||||
val curation = repository.findByIdOrNull(id = request.curationId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
request.itemIdList.forEach { contentId ->
|
||||
val audioContent = audioContentRepository.findByIdAndActive(contentId)
|
||||
|
||||
@@ -43,12 +43,12 @@ class AdminContentSeriesService(
|
||||
@Transactional
|
||||
fun modifySeries(request: AdminModifySeriesRequest) {
|
||||
val series = repository.findByIdAndActiveTrue(request.seriesId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (request.publishedDaysOfWeek != null) {
|
||||
val days = request.publishedDaysOfWeek
|
||||
if (days.contains(SeriesPublishedDaysOfWeek.RANDOM) && days.size > 1) {
|
||||
throw SodaException("랜덤과 연재요일 동시에 선택할 수 없습니다.")
|
||||
throw SodaException(messageKey = "admin.content.series.random_days_conflict")
|
||||
}
|
||||
series.publishedDaysOfWeek.clear()
|
||||
series.publishedDaysOfWeek.addAll(days)
|
||||
@@ -56,7 +56,7 @@ class AdminContentSeriesService(
|
||||
|
||||
if (request.genreId != null) {
|
||||
val genre = genreRepository.findActiveSeriesGenreById(request.genreId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
series.genre = genre
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.content.series.main.banner.ContentSeriesBannerService
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.data.domain.PageRequest
|
||||
@@ -33,6 +35,8 @@ import org.springframework.web.multipart.MultipartFile
|
||||
class AdminContentSeriesBannerController(
|
||||
private val bannerService: ContentSeriesBannerService,
|
||||
private val s3Uploader: S3Uploader,
|
||||
private val langContext: LangContext,
|
||||
private val messageSource: SodaMessageSource,
|
||||
|
||||
@Value("\${cloud.aws.s3.bucket}")
|
||||
private val s3Bucket: String,
|
||||
@@ -113,7 +117,8 @@ class AdminContentSeriesBannerController(
|
||||
@DeleteMapping("/{bannerId}")
|
||||
fun deleteBanner(@PathVariable bannerId: Long) = run {
|
||||
bannerService.deleteBanner(bannerId)
|
||||
ApiResponse.ok("배너가 성공적으로 삭제되었습니다.")
|
||||
val message = messageSource.getMessage("admin.content.series.banner.delete_success", langContext.lang)
|
||||
ApiResponse.ok(message)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +129,8 @@ class AdminContentSeriesBannerController(
|
||||
@RequestBody request: UpdateBannerOrdersRequest
|
||||
) = run {
|
||||
bannerService.updateBannerOrders(request.ids)
|
||||
ApiResponse.ok(null, "배너 정렬 순서가 성공적으로 변경되었습니다.")
|
||||
val message = messageSource.getMessage("admin.content.series.banner.reorder_success", langContext.lang)
|
||||
ApiResponse.ok(null, message)
|
||||
}
|
||||
|
||||
private fun saveImage(bannerId: Long, image: MultipartFile): String {
|
||||
@@ -139,7 +145,7 @@ class AdminContentSeriesBannerController(
|
||||
metadata = metadata
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
throw SodaException("이미지 저장에 실패했습니다: ${e.message}")
|
||||
throw SodaException(messageKey = "admin.content.series.banner.image_save_failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ class AdminContentSeriesGenreService(private val repository: AdminContentSeriesG
|
||||
@Transactional
|
||||
fun modifySeriesGenre(request: ModifySeriesGenreRequest) {
|
||||
if (request.genre == null && request.isAdult == null && request.isActive == null) {
|
||||
throw SodaException("변경사항이 없습니다.")
|
||||
throw SodaException(messageKey = "admin.content.series.genre.no_changes")
|
||||
}
|
||||
|
||||
val seriesGenre = repository.findByIdOrNull(id = request.id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (request.genre != null) {
|
||||
seriesGenre.genre = request.genre
|
||||
|
||||
@@ -30,7 +30,7 @@ class AdminRecommendSeriesService(
|
||||
fun createRecommendSeries(image: MultipartFile, requestString: String) {
|
||||
val request = objectMapper.readValue(requestString, CreateRecommendSeriesRequest::class.java)
|
||||
val series = seriesRepository.findByIdOrNull(request.seriesId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
val recommendSeries = RecommendSeries(isFree = request.isFree)
|
||||
recommendSeries.series = series
|
||||
@@ -49,7 +49,7 @@ class AdminRecommendSeriesService(
|
||||
fun updateRecommendSeries(image: MultipartFile?, requestString: String) {
|
||||
val request = objectMapper.readValue(requestString, UpdateRecommendSeriesRequest::class.java)
|
||||
val recommendSeries = repository.findByIdOrNull(request.id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (image != null) {
|
||||
val fileName = generateFileName()
|
||||
|
||||
@@ -53,13 +53,15 @@ class AdminContentThemeService(
|
||||
}
|
||||
|
||||
fun themeExistCheck(request: CreateContentThemeRequest) {
|
||||
repository.findIdByTheme(request.theme)?.let { throw SodaException("이미 등록된 테마 입니다.") }
|
||||
repository.findIdByTheme(request.theme)?.let {
|
||||
throw SodaException(messageKey = "admin.content.theme.already_registered")
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun deleteTheme(id: Long) {
|
||||
val theme = repository.findByIdOrNull(id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
theme.theme = "${theme.theme}_deleted"
|
||||
theme.isActive = false
|
||||
|
||||
@@ -34,7 +34,9 @@ class AdminEventBannerService(
|
||||
startDateString: String,
|
||||
endDateString: String
|
||||
): Long {
|
||||
if (detail == null && link.isNullOrBlank()) throw SodaException("상세이미지 혹은 링크를 등록하세요")
|
||||
if (detail == null && link.isNullOrBlank()) {
|
||||
throw SodaException(messageKey = "admin.event.banner.detail_or_link_required")
|
||||
}
|
||||
|
||||
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")
|
||||
val startDate = LocalDateTime.parse(startDateString, dateTimeFormatter)
|
||||
@@ -102,7 +104,7 @@ class AdminEventBannerService(
|
||||
event.detailImage = detailImagePath
|
||||
event.popupImage = popupImagePath
|
||||
|
||||
return event.id ?: throw SodaException("이벤트 등록을 하지 못했습니다.")
|
||||
return event.id ?: throw SodaException(messageKey = "admin.event.banner.create_failed")
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@@ -118,10 +120,10 @@ class AdminEventBannerService(
|
||||
startDateString: String? = null,
|
||||
endDateString: String? = null
|
||||
) {
|
||||
if (id <= 0) throw SodaException("잘못된 요청입니다.")
|
||||
if (id <= 0) throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
val event = repository.findByIdOrNull(id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (thumbnail != null) {
|
||||
val metadata = ObjectMetadata()
|
||||
@@ -190,9 +192,9 @@ class AdminEventBannerService(
|
||||
|
||||
@Transactional
|
||||
fun delete(id: Long) {
|
||||
if (id <= 0) throw SodaException("잘못된 요청입니다.")
|
||||
if (id <= 0) throw SodaException(messageKey = "common.error.invalid_request")
|
||||
val event = repository.findByIdOrNull(id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
event.isActive = false
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class AdminChargeEventService(private val repository: AdminChargeEventRepository
|
||||
@Transactional
|
||||
fun modifyChargeEvent(request: ModifyChargeEventRequest) {
|
||||
val chargeEvent = repository.findByIdOrNull(request.id)
|
||||
?: throw SodaException("해당하는 충전이벤트가 없습니다\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "admin.charge_event.not_found_retry")
|
||||
|
||||
if (request.title != null) {
|
||||
chargeEvent.title = request.title
|
||||
|
||||
@@ -17,10 +17,10 @@ class AdminExplorerService(
|
||||
) {
|
||||
@Transactional
|
||||
fun createExplorerSection(request: CreateExplorerSectionRequest): Long {
|
||||
if (request.title.isBlank()) throw SodaException("제목을 입력하세요.")
|
||||
if (request.title.isBlank()) throw SodaException(messageKey = "admin.explorer.title_required")
|
||||
|
||||
val findExplorerSection = repository.findByTitle(request.title)
|
||||
if (findExplorerSection != null) throw SodaException("동일한 제목이 있습니다.")
|
||||
if (findExplorerSection != null) throw SodaException(messageKey = "admin.explorer.title_duplicate")
|
||||
|
||||
val explorerSection = ExplorerSection(title = request.title, isAdult = request.isAdult)
|
||||
explorerSection.coloredTitle = request.coloredTitle
|
||||
@@ -37,7 +37,7 @@ class AdminExplorerService(
|
||||
}
|
||||
}
|
||||
|
||||
if (tags.size <= 0) throw SodaException("관심사를 선택하세요.")
|
||||
if (tags.size <= 0) throw SodaException(messageKey = "admin.explorer.tags_required")
|
||||
explorerSection.tags = tags
|
||||
|
||||
return repository.save(explorerSection).id!!
|
||||
@@ -53,14 +53,14 @@ class AdminExplorerService(
|
||||
request.coloredTitle == null &&
|
||||
request.isActive == null
|
||||
) {
|
||||
throw SodaException("변경사항이 없습니다.")
|
||||
throw SodaException(messageKey = "admin.explorer.no_changes")
|
||||
}
|
||||
|
||||
val explorerSection = repository.findByIdOrNull(request.id)
|
||||
?: throw SodaException("해당하는 섹션이 없습니다.")
|
||||
?: throw SodaException(messageKey = "admin.explorer.section_not_found")
|
||||
|
||||
if (request.title != null) {
|
||||
if (request.title.isBlank()) throw SodaException("올바른 제목을 입력하세요.")
|
||||
if (request.title.isBlank()) throw SodaException(messageKey = "admin.explorer.valid_title_required")
|
||||
explorerSection.title = request.title
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class AdminExplorerService(
|
||||
}
|
||||
}
|
||||
|
||||
if (tags.size <= 0) throw SodaException("관심사를 입력하세요.")
|
||||
if (tags.size <= 0) throw SodaException(messageKey = "admin.explorer.tags_input_required")
|
||||
if (tags != explorerSection.tags) {
|
||||
explorerSection.tags.clear()
|
||||
explorerSection.tags.addAll(tags)
|
||||
|
||||
@@ -15,6 +15,8 @@ import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEvent
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.live.recommend.RecommendLiveCreatorBanner
|
||||
import kr.co.vividnext.sodalive.live.recommend.RecommendLiveCreatorBannerRepository
|
||||
import kr.co.vividnext.sodalive.live.reservation.LiveReservationRepository
|
||||
@@ -49,6 +51,8 @@ class AdminLiveService(
|
||||
private val canRepository: CanRepository,
|
||||
|
||||
private val applicationEventPublisher: ApplicationEventPublisher,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext,
|
||||
|
||||
@Value("\${cloud.aws.s3.bucket}")
|
||||
private val bucket: String,
|
||||
@@ -118,10 +122,10 @@ class AdminLiveService(
|
||||
endDateString: String,
|
||||
isAdult: Boolean
|
||||
): Long {
|
||||
if (creatorId < 1) throw SodaException("올바른 크리에이터를 선택해 주세요.")
|
||||
if (creatorId < 1) throw SodaException(messageKey = "admin.live.creator_required")
|
||||
|
||||
val creator = memberRepository.findCreatorByIdOrNull(memberId = creatorId)
|
||||
?: throw SodaException("올바른 크리에이터를 선택해 주세요.")
|
||||
?: throw SodaException(messageKey = "admin.live.creator_required")
|
||||
|
||||
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")
|
||||
val startDate = LocalDateTime.parse(startDateString, dateTimeFormatter)
|
||||
@@ -134,15 +138,15 @@ class AdminLiveService(
|
||||
.withZoneSameInstant(ZoneId.of("UTC"))
|
||||
.toLocalDateTime()
|
||||
|
||||
if (startDate < nowDate) throw SodaException("노출 시작일은 현재시간 이후로 설정하셔야 합니다.")
|
||||
if (startDate < nowDate) throw SodaException(messageKey = "admin.live.start_after_now")
|
||||
|
||||
val endDate = LocalDateTime.parse(endDateString, dateTimeFormatter)
|
||||
.atZone(ZoneId.of("Asia/Seoul"))
|
||||
.withZoneSameInstant(ZoneId.of("UTC"))
|
||||
.toLocalDateTime()
|
||||
|
||||
if (endDate < nowDate) throw SodaException("노출 종료일은 현재시간 이후로 설정하셔야 합니다.")
|
||||
if (endDate <= startDate) throw SodaException("노출 시작일은 노출 종료일 이전으로 설정하셔야 합니다.")
|
||||
if (endDate < nowDate) throw SodaException(messageKey = "admin.live.end_after_now")
|
||||
if (endDate <= startDate) throw SodaException(messageKey = "admin.live.start_before_end")
|
||||
|
||||
val recommendCreatorBanner = RecommendLiveCreatorBanner(
|
||||
startDate = startDate,
|
||||
@@ -176,13 +180,13 @@ class AdminLiveService(
|
||||
isAdult: Boolean?
|
||||
) {
|
||||
val recommendCreatorBanner = recommendCreatorBannerRepository.findByIdOrNull(recommendCreatorBannerId)
|
||||
?: throw SodaException("해당하는 추천라이브가 없습니다. 다시 확인해 주세요.")
|
||||
?: throw SodaException(messageKey = "admin.live.recommend_not_found_retry")
|
||||
|
||||
if (creatorId != null) {
|
||||
if (creatorId < 1) throw SodaException("올바른 크리에이터를 선택해 주세요.")
|
||||
if (creatorId < 1) throw SodaException(messageKey = "admin.live.creator_required")
|
||||
|
||||
val creator = memberRepository.findCreatorByIdOrNull(memberId = creatorId)
|
||||
?: throw SodaException("올바른 크리에이터를 선택해 주세요.")
|
||||
?: throw SodaException(messageKey = "admin.live.creator_required")
|
||||
|
||||
recommendCreatorBanner.creator = creator
|
||||
}
|
||||
@@ -218,13 +222,13 @@ class AdminLiveService(
|
||||
|
||||
if (endDate != null) {
|
||||
if (endDate <= startDate) {
|
||||
throw SodaException("노출 시작일은 노출 종료일 이전으로 설정하셔야 합니다.")
|
||||
throw SodaException(messageKey = "admin.live.start_before_end")
|
||||
}
|
||||
|
||||
recommendCreatorBanner.endDate = endDate
|
||||
} else {
|
||||
if (recommendCreatorBanner.endDate <= startDate) {
|
||||
throw SodaException("노출 시작일은 노출 종료일 이전으로 설정하셔야 합니다.")
|
||||
throw SodaException(messageKey = "admin.live.start_before_end")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +241,7 @@ class AdminLiveService(
|
||||
.toLocalDateTime()
|
||||
|
||||
if (endDate <= recommendCreatorBanner.startDate) {
|
||||
throw SodaException("노출 종료일은 노출 시작일 이후로 설정하셔야 합니다.")
|
||||
throw SodaException(messageKey = "admin.live.end_after_start")
|
||||
}
|
||||
|
||||
recommendCreatorBanner.endDate = endDate
|
||||
@@ -266,7 +270,10 @@ class AdminLiveService(
|
||||
for (room in findRoomList) {
|
||||
room.isActive = false
|
||||
|
||||
val roomCancel = LiveRoomCancel("관리자에 의한 취소 - 노쇼")
|
||||
val cancelReason = messageSource
|
||||
.getMessage("admin.live.cancel_reason.no_show", langContext.lang)
|
||||
.orEmpty()
|
||||
val roomCancel = LiveRoomCancel(cancelReason)
|
||||
roomCancel.room = room
|
||||
roomCancelRepository.save(roomCancel)
|
||||
|
||||
@@ -286,7 +293,10 @@ class AdminLiveService(
|
||||
it.status = UseCanCalculateStatus.REFUND
|
||||
|
||||
val charge = Charge(0, it.can, status = ChargeStatus.REFUND_CHARGE)
|
||||
charge.title = "${it.can} 캔"
|
||||
val canTitleTemplate = messageSource
|
||||
.getMessage("live.room.can_title", langContext.lang)
|
||||
.orEmpty()
|
||||
charge.title = String.format(canTitleTemplate, it.can)
|
||||
charge.useCan = useCan
|
||||
|
||||
when (it.paymentGateway) {
|
||||
@@ -300,7 +310,9 @@ class AdminLiveService(
|
||||
status = PaymentStatus.COMPLETE,
|
||||
paymentGateway = it.paymentGateway
|
||||
)
|
||||
payment.method = "환불"
|
||||
payment.method = messageSource
|
||||
.getMessage("live.room.refund_method", langContext.lang)
|
||||
.orEmpty()
|
||||
charge.payment = payment
|
||||
|
||||
chargeRepository.save(charge)
|
||||
@@ -313,11 +325,15 @@ class AdminLiveService(
|
||||
reservationRepository.cancelReservation(roomId = room.id!!)
|
||||
|
||||
// 라이브 취소 푸시 발송
|
||||
val cancelMessageTemplate = messageSource
|
||||
.getMessage("live.room.fcm.message.canceled", langContext.lang)
|
||||
.orEmpty()
|
||||
val cancelMessage = String.format(cancelMessageTemplate, room.title)
|
||||
applicationEventPublisher.publishEvent(
|
||||
FcmEvent(
|
||||
type = FcmEventType.CANCEL_LIVE,
|
||||
title = room.member!!.nickname,
|
||||
message = "라이브 취소 : ${room.title}",
|
||||
message = cancelMessage,
|
||||
recipientsMap = pushTokenListMap
|
||||
)
|
||||
)
|
||||
|
||||
@@ -2,6 +2,8 @@ package kr.co.vividnext.sodalive.admin.live.signature
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.live.signature.SignatureCanSortType
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
@@ -16,7 +18,11 @@ import org.springframework.web.multipart.MultipartFile
|
||||
@RestController
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
@RequestMapping("/admin/live/signature-can")
|
||||
class AdminSignatureCanController(private val service: AdminSignatureCanService) {
|
||||
class AdminSignatureCanController(
|
||||
private val service: AdminSignatureCanService,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext
|
||||
) {
|
||||
@GetMapping
|
||||
fun getSignatureCanList(
|
||||
pageable: Pageable,
|
||||
@@ -32,7 +38,7 @@ class AdminSignatureCanController(private val service: AdminSignatureCanService)
|
||||
@RequestParam("isAdult", required = false) isAdult: Boolean = false
|
||||
) = ApiResponse.ok(
|
||||
service.createSignatureCan(can = can, time = time, creatorId = creatorId, image = image, isAdult = isAdult),
|
||||
"등록되었습니다."
|
||||
messageSource.getMessage("admin.signature_can.created", langContext.lang)
|
||||
)
|
||||
|
||||
@PutMapping
|
||||
@@ -45,7 +51,7 @@ class AdminSignatureCanController(private val service: AdminSignatureCanService)
|
||||
@RequestParam("isAdult", required = false) isAdult: Boolean?
|
||||
) = run {
|
||||
if (can == null && time == null && image == null && isActive == null && isAdult == null) {
|
||||
throw SodaException("변경사항이 없습니다.")
|
||||
throw SodaException(messageKey = "admin.signature_can.no_changes")
|
||||
}
|
||||
|
||||
ApiResponse.ok(
|
||||
@@ -57,7 +63,7 @@ class AdminSignatureCanController(private val service: AdminSignatureCanService)
|
||||
isActive = isActive,
|
||||
isAdult = isAdult
|
||||
),
|
||||
"수정되었습니다."
|
||||
messageSource.getMessage("admin.signature_can.updated", langContext.lang)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ class AdminSignatureCanService(
|
||||
|
||||
@Transactional
|
||||
fun createSignatureCan(can: Int, time: Int, creatorId: Long, image: MultipartFile, isAdult: Boolean) {
|
||||
if (creatorId < 1) throw SodaException("올바른 크리에이터를 선택해 주세요.")
|
||||
if (can <= 0) throw SodaException("1캔 이상 설정할 수 있습니다.")
|
||||
if (time < 3 || time > 20) throw SodaException("시간은 3초 이상 20초 이하로 설정할 수 있습니다.")
|
||||
if (creatorId < 1) throw SodaException(messageKey = "admin.signature_can.creator_required")
|
||||
if (can <= 0) throw SodaException(messageKey = "admin.signature_can.min_can")
|
||||
if (time < 3 || time > 20) throw SodaException(messageKey = "admin.signature_can.time_range")
|
||||
|
||||
val creator = memberRepository.findCreatorByIdOrNull(memberId = creatorId)
|
||||
?: throw SodaException("올바른 크리에이터를 선택해 주세요.")
|
||||
?: throw SodaException(messageKey = "admin.signature_can.creator_required")
|
||||
|
||||
val signatureCan = SignatureCan(can = can, isAdult = isAdult)
|
||||
signatureCan.creator = creator
|
||||
@@ -76,15 +76,15 @@ class AdminSignatureCanService(
|
||||
isAdult: Boolean?
|
||||
) {
|
||||
val signatureCan = repository.findByIdOrNull(id = id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (can != null) {
|
||||
if (can <= 0) throw SodaException("1캔 이상 설정할 수 있습니다.")
|
||||
if (can <= 0) throw SodaException(messageKey = "admin.signature_can.min_can")
|
||||
signatureCan.can = can
|
||||
}
|
||||
|
||||
if (time != null) {
|
||||
if (time < 3 || time > 20) throw SodaException("시간은 3초 이상 20초 이하로 설정할 수 있습니다.")
|
||||
if (time < 3 || time > 20) throw SodaException(messageKey = "admin.signature_can.time_range")
|
||||
signatureCan.time = time
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class AdminAdMediaPartnerService(private val repository: AdMediaPartnerRepositor
|
||||
@Transactional
|
||||
fun updateMediaPartner(request: UpdateAdMediaPartnerRequest) {
|
||||
val entity = repository.findByIdOrNull(request.id)
|
||||
?: throw SodaException("잘못된 접근입니다")
|
||||
?: throw SodaException(messageKey = "admin.media_partner.invalid_access")
|
||||
|
||||
if (request.mediaGroup != null) {
|
||||
entity.mediaGroup = request.mediaGroup
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package kr.co.vividnext.sodalive.admin.member
|
||||
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberProvider
|
||||
import kr.co.vividnext.sodalive.member.MemberRole
|
||||
@@ -17,6 +19,8 @@ import java.time.format.DateTimeFormatter
|
||||
class AdminMemberService(
|
||||
private val repository: AdminMemberRepository,
|
||||
private val passwordEncoder: PasswordEncoder,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val cloudFrontHost: String
|
||||
@@ -24,7 +28,7 @@ class AdminMemberService(
|
||||
@Transactional
|
||||
fun updateMember(request: UpdateMemberRequest) {
|
||||
val member = repository.findByIdOrNull(request.id)
|
||||
?: throw SodaException("해당 유저가 없습니다.")
|
||||
?: throw SodaException(messageKey = "admin.member.not_found")
|
||||
|
||||
if (member.role != request.userType) {
|
||||
member.role = request.userType
|
||||
@@ -44,7 +48,7 @@ class AdminMemberService(
|
||||
}
|
||||
|
||||
fun searchMember(searchWord: String, pageable: Pageable): GetAdminMemberListResponse {
|
||||
if (searchWord.length < 2) throw SodaException("2글자 이상 입력하세요.")
|
||||
if (searchWord.length < 2) throw SodaException(messageKey = "admin.member.search_word_min_length")
|
||||
val totalCount = repository.searchMemberTotalCount(searchWord = searchWord)
|
||||
val memberList = processMemberListToGetAdminMemberListResponseItemList(
|
||||
memberList = repository.searchMember(
|
||||
@@ -71,7 +75,7 @@ class AdminMemberService(
|
||||
}
|
||||
|
||||
fun searchCreator(searchWord: String, pageable: Pageable): GetAdminMemberListResponse {
|
||||
if (searchWord.length < 2) throw SodaException("2글자 이상 입력하세요.")
|
||||
if (searchWord.length < 2) throw SodaException(messageKey = "admin.member.search_word_min_length")
|
||||
val totalCount = repository.searchMemberTotalCount(searchWord = searchWord, role = MemberRole.CREATOR)
|
||||
val creatorList = processMemberListToGetAdminMemberListResponseItemList(
|
||||
memberList = repository.searchMember(
|
||||
@@ -92,18 +96,18 @@ class AdminMemberService(
|
||||
.asSequence()
|
||||
.map {
|
||||
val userType = when (it.role) {
|
||||
MemberRole.ADMIN -> "관리자"
|
||||
MemberRole.USER -> "일반회원"
|
||||
MemberRole.CREATOR -> "크리에이터"
|
||||
MemberRole.AGENT -> "에이전트"
|
||||
MemberRole.BOT -> "봇"
|
||||
MemberRole.ADMIN -> messageSource.getMessage("admin.member.role.admin", langContext.lang).orEmpty()
|
||||
MemberRole.USER -> messageSource.getMessage("admin.member.role.user", langContext.lang).orEmpty()
|
||||
MemberRole.CREATOR -> messageSource.getMessage("admin.member.role.creator", langContext.lang).orEmpty()
|
||||
MemberRole.AGENT -> messageSource.getMessage("admin.member.role.agent", langContext.lang).orEmpty()
|
||||
MemberRole.BOT -> messageSource.getMessage("admin.member.role.bot", langContext.lang).orEmpty()
|
||||
}
|
||||
|
||||
val loginType = when (it.provider) {
|
||||
MemberProvider.EMAIL -> "이메일"
|
||||
MemberProvider.KAKAO -> "카카오"
|
||||
MemberProvider.GOOGLE -> "구글"
|
||||
MemberProvider.APPLE -> "애플"
|
||||
MemberProvider.EMAIL -> messageSource.getMessage("member.provider.email", langContext.lang).orEmpty()
|
||||
MemberProvider.KAKAO -> messageSource.getMessage("member.provider.kakao", langContext.lang).orEmpty()
|
||||
MemberProvider.GOOGLE -> messageSource.getMessage("member.provider.google", langContext.lang).orEmpty()
|
||||
MemberProvider.APPLE -> messageSource.getMessage("member.provider.apple", langContext.lang).orEmpty()
|
||||
}
|
||||
|
||||
val signUpDate = it.createdAt!!
|
||||
@@ -146,7 +150,7 @@ class AdminMemberService(
|
||||
}
|
||||
|
||||
fun searchMemberByNickname(searchWord: String, size: Int = 20): List<AdminSimpleMemberResponse> {
|
||||
if (searchWord.length < 2) throw SodaException("2글자 이상 입력하세요.")
|
||||
if (searchWord.length < 2) throw SodaException(messageKey = "admin.member.search_word_min_length")
|
||||
val limit = if (size <= 0) 20 else size
|
||||
return repository.searchMemberByNickname(searchWord = searchWord, limit = limit.toLong())
|
||||
}
|
||||
@@ -154,7 +158,7 @@ class AdminMemberService(
|
||||
@Transactional
|
||||
fun resetPassword(request: ResetPasswordRequest) {
|
||||
val member = repository.findByIdAndActive(memberId = request.memberId)
|
||||
?: throw SodaException("잘못된 회원정보입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "admin.member.reset_password_invalid")
|
||||
|
||||
member.password = passwordEncoder.encode(member.email.split("@")[0])
|
||||
}
|
||||
|
||||
@@ -35,7 +35,9 @@ class AdminMemberTagService(
|
||||
}
|
||||
|
||||
private fun tagExistCheck(request: CreateMemberTagRequest) {
|
||||
repository.findByTag(request.tag)?.let { throw SodaException("이미 등록된 태그 입니다.") }
|
||||
repository.findByTag(request.tag)?.let {
|
||||
throw SodaException(messageKey = "admin.member.tag.already_registered")
|
||||
}
|
||||
}
|
||||
|
||||
private fun createTag(tag: String, imagePath: String, isAdult: Boolean) {
|
||||
@@ -51,7 +53,7 @@ class AdminMemberTagService(
|
||||
@Transactional
|
||||
fun deleteTag(id: Long) {
|
||||
val creatorTag = repository.findByIdOrNull(id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
creatorTag.tag = "${creatorTag.tag}_deleted"
|
||||
creatorTag.isActive = false
|
||||
@@ -60,7 +62,7 @@ class AdminMemberTagService(
|
||||
@Transactional
|
||||
fun modifyTag(id: Long, image: MultipartFile?, requestString: String) {
|
||||
val creatorTag = repository.findByIdOrNull(id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
val request = objectMapper.readValue(requestString, CreateMemberTagRequest::class.java)
|
||||
creatorTag.tag = request.tag
|
||||
|
||||
@@ -26,7 +26,7 @@ class PointPolicyService(private val repository: PointPolicyRepository) {
|
||||
@Transactional
|
||||
fun update(id: Long, request: ModifyPointRewardPolicyRequest) {
|
||||
val pointPolicy = repository.findByIdOrNull(id)
|
||||
?: throw SodaException("잘못된 접근입니다.")
|
||||
?: throw SodaException(messageKey = "admin.point.policy.invalid_access")
|
||||
|
||||
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class AdminMemberStatisticsService(private val repository: AdminMemberStatistics
|
||||
)
|
||||
|
||||
if (dateRange == null) {
|
||||
throw SodaException("잘못된 접근입니다.")
|
||||
throw SodaException(messageKey = "admin.member.statistics.invalid_access")
|
||||
}
|
||||
|
||||
var startDateTime = startDate.atStartOfDay()
|
||||
|
||||
@@ -17,7 +17,7 @@ class AlarmController(private val service: AlarmService) {
|
||||
fun getSlotQuantityAndPrice(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getSlotQuantityAndPrice(memberId = member.id!!)
|
||||
@@ -29,7 +29,7 @@ class AlarmController(private val service: AlarmService) {
|
||||
@PathVariable("container") container: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.buyExtraSlot(
|
||||
|
||||
@@ -53,7 +53,7 @@ class AlarmService(
|
||||
}
|
||||
|
||||
else -> {
|
||||
throw SodaException("이미 구매하셨습니다")
|
||||
throw SodaException(messageKey = "alarm.error.already_purchased")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class AuditionController(private val service: AuditionService) {
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.getAuditionDetail(auditionId = id))
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class AuditionApplicantController(private val service: AuditionApplicantService)
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getAuditionApplicantList(
|
||||
@@ -42,7 +42,7 @@ class AuditionApplicantController(private val service: AuditionApplicantService)
|
||||
@RequestPart("request") requestString: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.applyAuditionRole(
|
||||
|
||||
@@ -47,11 +47,11 @@ class AuditionApplicantService(
|
||||
|
||||
@Transactional
|
||||
fun applyAuditionRole(contentFile: MultipartFile?, requestString: String, member: Member) {
|
||||
if (contentFile == null) throw SodaException("녹음 파일을 확인해 주세요.")
|
||||
if (contentFile == null) throw SodaException(messageKey = "audition.applicant.content_file_required")
|
||||
val request = objectMapper.readValue(requestString, ApplyAuditionRoleRequest::class.java)
|
||||
|
||||
val auditionRole = roleRepository.findByIdOrNull(id = request.roleId)
|
||||
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "audition.error.invalid_request_retry")
|
||||
|
||||
val existingApplicant = repository.findActiveApplicantByMemberIdAndRoleId(
|
||||
memberId = member.id!!,
|
||||
|
||||
@@ -17,7 +17,7 @@ class AuditionRoleController(private val service: AuditionRoleService) {
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getAuditionRoleDetail(
|
||||
|
||||
@@ -11,7 +11,7 @@ class AuditionRoleService(
|
||||
) {
|
||||
fun getAuditionRoleDetail(auditionRoleId: Long, memberId: Long): GetAuditionRoleDetailResponse {
|
||||
val roleDetailData = repository.getAuditionRoleDetail(auditionRoleId = auditionRoleId)
|
||||
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "audition.error.invalid_request_retry")
|
||||
|
||||
val isAlreadyApplicant = applicantRepository.isAlreadyApplicant(
|
||||
auditionRoleId = auditionRoleId,
|
||||
|
||||
@@ -19,7 +19,7 @@ class AuditionVoteController(
|
||||
@RequestBody request: VoteAuditionApplicantRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.voteAuditionApplicant(
|
||||
|
||||
@@ -20,7 +20,7 @@ class AuditionVoteService(
|
||||
) {
|
||||
fun voteAuditionApplicant(applicantId: Long, timezone: String, container: String, member: Member) {
|
||||
val applicant = applicantRepository.findByIdOrNull(applicantId)
|
||||
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "audition.error.invalid_request_retry")
|
||||
|
||||
val defaultZoneId = ZoneId.of("Asia/Seoul")
|
||||
val clientZoneId = try {
|
||||
@@ -43,7 +43,7 @@ class AuditionVoteService(
|
||||
)
|
||||
|
||||
if (voteCount > 100) {
|
||||
throw SodaException("오늘 응원은 여기까지!\n하루 최대 100회까지 응원이 가능합니다.\n내일 다시 이용해주세요.")
|
||||
throw SodaException(messageKey = "audition.vote.max_daily_reached")
|
||||
}
|
||||
|
||||
if (voteCount > 0) {
|
||||
|
||||
@@ -27,7 +27,7 @@ class CanController(private val service: CanService) {
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
ApiResponse.ok(service.getCanStatus(member, container))
|
||||
@@ -41,7 +41,7 @@ class CanController(private val service: CanService) {
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
ApiResponse.ok(service.getCanUseStatus(member, pageable, timezone, container))
|
||||
@@ -55,7 +55,7 @@ class CanController(private val service: CanService) {
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
ApiResponse.ok(service.getCanChargeStatus(member, pageable, timezone, container))
|
||||
|
||||
@@ -33,7 +33,7 @@ class ChargeController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
ApiResponse.ok(service.payverseCharge(member, request))
|
||||
@@ -45,7 +45,7 @@ class ChargeController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
val response = service.payverseVerify(memberId = member.id!!, verifyRequest)
|
||||
@@ -83,7 +83,7 @@ class ChargeController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
ApiResponse.ok(service.charge(member, chargeRequest))
|
||||
@@ -95,7 +95,7 @@ class ChargeController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
val response = service.verify(memberId = member.id!!, verifyRequest)
|
||||
@@ -109,7 +109,7 @@ class ChargeController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
val response = service.verifyHecto(memberId = member.id!!, verifyRequest)
|
||||
@@ -123,7 +123,7 @@ class ChargeController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
ApiResponse.ok(service.appleCharge(member, chargeRequest))
|
||||
@@ -135,7 +135,7 @@ class ChargeController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
val response = service.appleVerify(memberId = member.id!!, verifyRequest)
|
||||
@@ -149,7 +149,7 @@ class ChargeController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
if (request.paymentGateway == PaymentGateway.GOOGLE_IAP) {
|
||||
@@ -174,7 +174,7 @@ class ChargeController(
|
||||
trackingCharge(member, response)
|
||||
ApiResponse.ok(Unit)
|
||||
} else {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ import kr.co.vividnext.sodalive.can.payment.PaymentGateway
|
||||
import kr.co.vividnext.sodalive.can.payment.PaymentStatus
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.google.GooglePlayService
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRepository
|
||||
import kr.co.vividnext.sodalive.point.MemberPoint
|
||||
@@ -53,6 +55,8 @@ class ChargeService(
|
||||
private val applicationEventPublisher: ApplicationEventPublisher,
|
||||
|
||||
private val googlePlayService: GooglePlayService,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext,
|
||||
|
||||
@Value("\${bootpay.application-id}")
|
||||
private val bootpayApplicationId: String,
|
||||
@@ -174,10 +178,10 @@ class ChargeService(
|
||||
@Transactional
|
||||
fun chargeByCoupon(couponNumber: String, member: Member): String {
|
||||
val canCouponNumber = couponNumberRepository.findByCouponNumber(couponNumber = couponNumber)
|
||||
?: throw SodaException("잘못된 쿠폰번호입니다.\n고객센터로 문의해 주시기 바랍니다.")
|
||||
?: throw SodaException(messageKey = "can.coupon.invalid_number_contact")
|
||||
|
||||
if (canCouponNumber.member != null) {
|
||||
throw SodaException("이미 사용한 쿠폰번호 입니다.")
|
||||
throw SodaException(messageKey = "can.coupon.already_used")
|
||||
}
|
||||
canCouponNumber.member = member
|
||||
|
||||
@@ -186,7 +190,7 @@ class ChargeService(
|
||||
when (coupon.couponType) {
|
||||
CouponType.CAN -> {
|
||||
val couponCharge = Charge(0, coupon.can, status = ChargeStatus.COUPON)
|
||||
couponCharge.title = "${coupon.can} 캔"
|
||||
couponCharge.title = formatMessage("can.charge.title", coupon.can)
|
||||
couponCharge.member = member
|
||||
|
||||
val payment = Payment(
|
||||
@@ -198,7 +202,7 @@ class ChargeService(
|
||||
chargeRepository.save(couponCharge)
|
||||
|
||||
member.charge(0, coupon.can, "pg")
|
||||
return "쿠폰 사용이 완료되었습니다.\n${coupon.can}캔이 지급되었습니다."
|
||||
return formatMessage("can.coupon.use_complete", coupon.can)
|
||||
}
|
||||
|
||||
CouponType.POINT -> {
|
||||
@@ -226,7 +230,7 @@ class ChargeService(
|
||||
)
|
||||
)
|
||||
|
||||
return "쿠폰 사용이 완료되었습니다.\n${coupon.can}포인트가 지급되었습니다."
|
||||
return formatMessage("can.coupon.use_complete_point", coupon.can)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,7 +238,7 @@ class ChargeService(
|
||||
@Transactional
|
||||
fun payverseCharge(member: Member, request: PayverseChargeRequest): PayverseChargeResponse {
|
||||
val can = canRepository.findByIdOrNull(request.canId)
|
||||
?: throw SodaException("잘못된 요청입니다\n앱 종료 후 다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "can.charge.invalid_request_restart")
|
||||
|
||||
val requestCurrency = can.currency
|
||||
val isKrw = requestCurrency == "KRW"
|
||||
@@ -304,9 +308,9 @@ class ChargeService(
|
||||
@Transactional
|
||||
fun payverseVerify(memberId: Long, verifyRequest: PayverseVerifyRequest): ChargeCompleteResponse {
|
||||
val charge = chargeRepository.findByIdOrNull(verifyRequest.orderId.toLong())
|
||||
?: throw SodaException("결제정보에 오류가 있습니다.")
|
||||
?: throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
val member = memberRepository.findByIdOrNull(memberId)
|
||||
?: throw SodaException("로그인 정보를 확인해주세요.")
|
||||
?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
val isKrw = charge.can?.currency == "KRW"
|
||||
val mid = if (isKrw) {
|
||||
@@ -322,7 +326,7 @@ class ChargeService(
|
||||
|
||||
// 결제수단 확인
|
||||
if (charge.payment?.paymentGateway != PaymentGateway.PAYVERSE) {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
|
||||
// 결제 상태에 따른 분기 처리
|
||||
@@ -339,10 +343,11 @@ class ChargeService(
|
||||
|
||||
val response = okHttpClient.newCall(request).execute()
|
||||
if (!response.isSuccessful) {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
|
||||
val body = response.body?.string() ?: throw SodaException("결제정보에 오류가 있습니다.")
|
||||
val body = response.body?.string()
|
||||
?: throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
val verifyResponse = objectMapper.readValue(body, PayverseVerifyResponse::class.java)
|
||||
|
||||
val customerId = "${serverEnv}_user_${member.id!!}"
|
||||
@@ -380,10 +385,10 @@ class ChargeService(
|
||||
isFirstCharged = chargeRepository.isFirstCharged(memberId)
|
||||
)
|
||||
} else {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +402,7 @@ class ChargeService(
|
||||
}
|
||||
|
||||
else -> {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -405,7 +410,7 @@ class ChargeService(
|
||||
@Transactional
|
||||
fun charge(member: Member, request: ChargeRequest): ChargeResponse {
|
||||
val can = canRepository.findByIdOrNull(request.canId)
|
||||
?: throw SodaException("잘못된 요청입니다\n앱 종료 후 다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "can.charge.invalid_request_restart")
|
||||
|
||||
val charge = Charge(can.can, can.rewardCan)
|
||||
charge.title = can.title
|
||||
@@ -424,9 +429,9 @@ class ChargeService(
|
||||
@Transactional
|
||||
fun verify(memberId: Long, verifyRequest: VerifyRequest): ChargeCompleteResponse {
|
||||
val charge = chargeRepository.findByIdOrNull(verifyRequest.orderId.toLong())
|
||||
?: throw SodaException("결제정보에 오류가 있습니다.")
|
||||
?: throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
val member = memberRepository.findByIdOrNull(memberId)
|
||||
?: throw SodaException("로그인 정보를 확인해주세요.")
|
||||
?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
if (charge.payment!!.paymentGateway == PaymentGateway.PG) {
|
||||
val bootpay = Bootpay(bootpayApplicationId, bootpayPrivateKey)
|
||||
@@ -457,22 +462,22 @@ class ChargeService(
|
||||
isFirstCharged = chargeRepository.isFirstCharged(memberId)
|
||||
)
|
||||
} else {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
} else {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun verifyHecto(memberId: Long, verifyRequest: VerifyRequest): ChargeCompleteResponse {
|
||||
val charge = chargeRepository.findByIdOrNull(verifyRequest.orderId.toLong())
|
||||
?: throw SodaException("결제정보에 오류가 있습니다.")
|
||||
?: throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
val member = memberRepository.findByIdOrNull(memberId)
|
||||
?: throw SodaException("로그인 정보를 확인해주세요.")
|
||||
?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
if (charge.payment!!.paymentGateway == PaymentGateway.PG) {
|
||||
val bootpay = Bootpay(bootpayHectoApplicationId, bootpayHectoPrivateKey)
|
||||
@@ -507,13 +512,13 @@ class ChargeService(
|
||||
isFirstCharged = chargeRepository.isFirstCharged(memberId)
|
||||
)
|
||||
} else {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
} else {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,15 +547,17 @@ class ChargeService(
|
||||
@Transactional
|
||||
fun appleVerify(memberId: Long, verifyRequest: AppleVerifyRequest): ChargeCompleteResponse {
|
||||
val charge = chargeRepository.findByIdOrNull(verifyRequest.chargeId)
|
||||
?: throw SodaException("결제정보에 오류가 있습니다.")
|
||||
?: throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
val member = memberRepository.findByIdOrNull(memberId)
|
||||
?: throw SodaException("로그인 정보를 확인해주세요.")
|
||||
?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
if (charge.payment!!.paymentGateway == PaymentGateway.APPLE_IAP) {
|
||||
// 검증로직
|
||||
if (requestRealServerVerify(verifyRequest)) {
|
||||
charge.payment?.receiptId = verifyRequest.receiptString
|
||||
charge.payment?.method = "애플(인 앱 결제)"
|
||||
charge.payment?.method = messageSource
|
||||
.getMessage("can.charge.payment_method.apple_iap", langContext.lang)
|
||||
.orEmpty()
|
||||
charge.payment?.status = PaymentStatus.COMPLETE
|
||||
member.charge(charge.chargeCan, charge.rewardCan, "ios")
|
||||
|
||||
@@ -567,10 +574,10 @@ class ChargeService(
|
||||
isFirstCharged = chargeRepository.isFirstCharged(memberId)
|
||||
)
|
||||
} else {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
} else {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,7 +601,9 @@ class ChargeService(
|
||||
payment.locale = currencyCode
|
||||
payment.price = price
|
||||
payment.receiptId = purchaseToken
|
||||
payment.method = "구글(인 앱 결제)"
|
||||
payment.method = messageSource
|
||||
.getMessage("can.charge.payment_method.google_iap", langContext.lang)
|
||||
.orEmpty()
|
||||
|
||||
charge.payment = payment
|
||||
chargeRepository.save(charge)
|
||||
@@ -610,9 +619,9 @@ class ChargeService(
|
||||
purchaseToken: String
|
||||
): ChargeCompleteResponse {
|
||||
val charge = chargeRepository.findByIdOrNull(id = chargeId)
|
||||
?: throw SodaException("결제정보에 오류가 있습니다.")
|
||||
?: throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
val member = memberRepository.findByIdOrNull(id = memberId)
|
||||
?: throw SodaException("로그인 정보를 확인해주세요.")
|
||||
?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
if (charge.payment!!.status == PaymentStatus.REQUEST) {
|
||||
val orderId = verifyPurchase(purchaseToken, productId)
|
||||
@@ -634,10 +643,10 @@ class ChargeService(
|
||||
isFirstCharged = chargeRepository.isFirstCharged(memberId)
|
||||
)
|
||||
} else {
|
||||
throw SodaException("구매를 하지 못했습니다.\n고객센터로 문의해 주세요")
|
||||
throw SodaException(messageKey = "can.charge.purchase_failed_contact")
|
||||
}
|
||||
} else {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,14 +679,14 @@ class ChargeService(
|
||||
}
|
||||
|
||||
else -> {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw SodaException("결제를 완료하지 못했습니다.")
|
||||
throw SodaException(messageKey = "can.charge.payment_incomplete")
|
||||
}
|
||||
} else {
|
||||
throw SodaException("결제를 완료하지 못했습니다.")
|
||||
throw SodaException(messageKey = "can.charge.payment_incomplete")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,23 +710,31 @@ class ChargeService(
|
||||
}
|
||||
|
||||
else -> {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw SodaException("결제를 완료하지 못했습니다.")
|
||||
throw SodaException(messageKey = "can.charge.payment_incomplete")
|
||||
}
|
||||
} else {
|
||||
throw SodaException("결제를 완료하지 못했습니다.")
|
||||
throw SodaException(messageKey = "can.charge.payment_incomplete")
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatMessage(key: String, vararg args: Any): String {
|
||||
val template = messageSource.getMessage(key, langContext.lang) ?: return ""
|
||||
return String.format(template, *args)
|
||||
}
|
||||
|
||||
// Payverse 결제수단 매핑: 특정 schemeCode는 "카드"로 표기, 아니면 null 반환
|
||||
private fun mapPayverseSchemeToMethodByCode(schemeCode: String?): String? {
|
||||
val cardCodes = setOf(
|
||||
"041", "044", "361", "364", "365", "366", "367", "368", "369", "370", "371", "372", "373", "374", "381",
|
||||
"218", "071", "002", "089", "045", "050", "048", "090", "092"
|
||||
)
|
||||
return if (schemeCode != null && cardCodes.contains(schemeCode)) "카드" else null
|
||||
if (schemeCode == null || !cardCodes.contains(schemeCode)) {
|
||||
return null
|
||||
}
|
||||
return messageSource.getMessage("can.charge.payment_method.card", langContext.lang)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import kr.co.vividnext.sodalive.can.payment.PaymentStatus
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEvent
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRepository
|
||||
import kr.co.vividnext.sodalive.member.auth.AuthRepository
|
||||
@@ -26,15 +28,17 @@ class ChargeEventService(
|
||||
private val memberRepository: MemberRepository,
|
||||
private val chargeRepository: ChargeRepository,
|
||||
private val chargeEventRepository: ChargeEventRepository,
|
||||
private val applicationEventPublisher: ApplicationEventPublisher
|
||||
private val applicationEventPublisher: ApplicationEventPublisher,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext
|
||||
) {
|
||||
@Transactional
|
||||
fun applyChargeEvent(chargeId: Long, memberId: Long) {
|
||||
val charge = chargeRepository.findByIdOrNull(chargeId)
|
||||
?: throw SodaException("이벤트가 적용되지 않았습니다.\n고객센터에 문의해 주세요.")
|
||||
?: throw SodaException(messageKey = "can.charge.event.not_applied_contact")
|
||||
|
||||
val member = memberRepository.findByIdOrNull(memberId)
|
||||
?: throw SodaException("이벤트가 적용되지 않았습니다.\n고객센터에 문의해 주세요.")
|
||||
?: throw SodaException(messageKey = "can.charge.event.not_applied_contact")
|
||||
|
||||
if (member.auth != null) {
|
||||
val authDate = authRepository.getOldestCreatedAtByDi(member.auth!!.di)
|
||||
@@ -79,7 +83,10 @@ class ChargeEventService(
|
||||
FcmEvent(
|
||||
type = FcmEventType.INDIVIDUAL,
|
||||
title = chargeEvent.title,
|
||||
message = "$additionalCan 캔이 추가 지급되었습니다.",
|
||||
message = formatMessage(
|
||||
"can.charge.event.additional_can_paid",
|
||||
additionalCan
|
||||
),
|
||||
recipients = listOf(member.id!!),
|
||||
isAuth = null
|
||||
)
|
||||
@@ -94,14 +101,21 @@ class ChargeEventService(
|
||||
additionalCan = additionalCan,
|
||||
member = member,
|
||||
paymentGateway = charge.payment?.paymentGateway!!,
|
||||
method = "첫 충전 이벤트"
|
||||
method = messageSource
|
||||
.getMessage("can.charge.event.first_title", langContext.lang)
|
||||
.orEmpty()
|
||||
)
|
||||
|
||||
applicationEventPublisher.publishEvent(
|
||||
FcmEvent(
|
||||
type = FcmEventType.INDIVIDUAL,
|
||||
title = "첫 충전 이벤트",
|
||||
message = "$additionalCan 캔이 추가 지급되었습니다.",
|
||||
title = messageSource
|
||||
.getMessage("can.charge.event.first_title", langContext.lang)
|
||||
.orEmpty(),
|
||||
message = formatMessage(
|
||||
"can.charge.event.additional_can_paid",
|
||||
additionalCan
|
||||
),
|
||||
recipients = listOf(member.id!!),
|
||||
isAuth = null
|
||||
)
|
||||
@@ -110,7 +124,7 @@ class ChargeEventService(
|
||||
|
||||
private fun applyEvent(additionalCan: Int, member: Member, paymentGateway: PaymentGateway, method: String) {
|
||||
val eventCharge = Charge(0, additionalCan, status = ChargeStatus.EVENT)
|
||||
eventCharge.title = "$additionalCan 캔"
|
||||
eventCharge.title = formatMessage("can.charge.title", additionalCan)
|
||||
eventCharge.member = member
|
||||
|
||||
val payment = Payment(
|
||||
@@ -127,4 +141,9 @@ class ChargeEventService(
|
||||
else -> member.charge(0, additionalCan, "pg")
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatMessage(key: String, vararg args: Any): String {
|
||||
val template = messageSource.getMessage(key, langContext.lang) ?: return ""
|
||||
return String.format(template, *args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class ChargeTempController(private val service: ChargeTempService) {
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) {
|
||||
throw SodaException("로그인 정보를 확인해주세요.")
|
||||
throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
}
|
||||
|
||||
ApiResponse.ok(service.charge(member, request))
|
||||
|
||||
@@ -12,6 +12,8 @@ import kr.co.vividnext.sodalive.can.payment.PaymentGateway
|
||||
import kr.co.vividnext.sodalive.can.payment.PaymentStatus
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.extensions.moneyFormat
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRepository
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
@@ -27,6 +29,8 @@ class ChargeTempService(
|
||||
private val memberRepository: MemberRepository,
|
||||
|
||||
private val objectMapper: ObjectMapper,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext,
|
||||
|
||||
@Value("\${bootpay.hecto-application-id}")
|
||||
private val bootpayApplicationId: String,
|
||||
@@ -37,7 +41,7 @@ class ChargeTempService(
|
||||
@Transactional
|
||||
fun charge(member: Member, request: ChargeTempRequest): ChargeResponse {
|
||||
val charge = Charge(request.can, 0)
|
||||
charge.title = "${request.can.moneyFormat()} 캔"
|
||||
charge.title = formatMessage("can.charge.title", request.can.moneyFormat())
|
||||
charge.member = member
|
||||
|
||||
val payment = Payment(paymentGateway = request.paymentGateway)
|
||||
@@ -52,9 +56,9 @@ class ChargeTempService(
|
||||
@Transactional
|
||||
fun verify(user: User, verifyRequest: VerifyRequest) {
|
||||
val charge = chargeRepository.findByIdOrNull(verifyRequest.orderId.toLong())
|
||||
?: throw SodaException("결제정보에 오류가 있습니다.")
|
||||
?: throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
val member = memberRepository.findByEmail(user.username)
|
||||
?: throw SodaException("로그인 정보를 확인해주세요.")
|
||||
?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
if (charge.payment!!.paymentGateway == PaymentGateway.PG) {
|
||||
val bootpay = Bootpay(bootpayApplicationId, bootpayPrivateKey)
|
||||
@@ -72,13 +76,18 @@ class ChargeTempService(
|
||||
charge.payment?.status = PaymentStatus.COMPLETE
|
||||
member.charge(charge.chargeCan, charge.rewardCan, "pg")
|
||||
} else {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
} else {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
throw SodaException(messageKey = "can.charge.invalid_payment_info")
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatMessage(key: String, vararg args: Any): String {
|
||||
val template = messageSource.getMessage(key, langContext.lang) ?: return ""
|
||||
return String.format(template, *args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package kr.co.vividnext.sodalive.can.coupon
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import org.springframework.core.io.InputStreamResource
|
||||
import org.springframework.data.domain.Pageable
|
||||
@@ -22,14 +24,18 @@ import java.nio.charset.StandardCharsets
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/can/coupon")
|
||||
class CanCouponController(private val service: CanCouponService) {
|
||||
class CanCouponController(
|
||||
private val service: CanCouponService,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext
|
||||
) {
|
||||
@PostMapping
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
fun generateCoupon(
|
||||
@RequestBody request: GenerateCanCouponRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.generateCoupon(request))
|
||||
}
|
||||
@@ -40,7 +46,7 @@ class CanCouponController(private val service: CanCouponService) {
|
||||
@RequestBody request: ModifyCanCouponRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.modifyCoupon(request))
|
||||
}
|
||||
@@ -51,7 +57,7 @@ class CanCouponController(private val service: CanCouponService) {
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.getCouponList(offset = pageable.offset, limit = pageable.pageSize.toLong()))
|
||||
}
|
||||
@@ -63,7 +69,7 @@ class CanCouponController(private val service: CanCouponService) {
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getCouponNumberList(
|
||||
@@ -80,9 +86,11 @@ class CanCouponController(private val service: CanCouponService) {
|
||||
@RequestParam couponId: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
val fileName = "쿠폰번호리스트.xlsx"
|
||||
val fileName = messageSource
|
||||
.getMessage("can.coupon.download_filename", langContext.lang)
|
||||
.orEmpty()
|
||||
val encodedFileName = URLEncoder.encode(
|
||||
fileName,
|
||||
StandardCharsets.UTF_8.toString()
|
||||
@@ -107,7 +115,7 @@ class CanCouponController(private val service: CanCouponService) {
|
||||
@RequestBody request: UseCanCouponRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
val completeMessage = service.useCanCoupon(
|
||||
couponNumber = request.couponNumber,
|
||||
|
||||
@@ -12,7 +12,7 @@ class CanCouponIssueService(private val couponNumberRepository: CanCouponNumberR
|
||||
if (!isMultipleUse(canCouponNumber)) {
|
||||
val canCouponNumberList = couponNumberRepository.findByMemberId(memberId = memberId)
|
||||
if (canCouponNumberList.isNotEmpty()) {
|
||||
throw SodaException("해당 쿠폰은 1회만 충전이 가능합니다.")
|
||||
throw SodaException(messageKey = "can.coupon.single_use_only")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ class CanCouponIssueService(private val couponNumberRepository: CanCouponNumberR
|
||||
|
||||
private fun checkCanCouponNumber(couponNumber: String): CanCouponNumber {
|
||||
val canCouponNumber = couponNumberRepository.findByCouponNumber(couponNumber = couponNumber)
|
||||
?: throw SodaException("잘못된 쿠폰번호입니다.\n고객센터로 문의해 주시기 바랍니다.")
|
||||
?: throw SodaException(messageKey = "can.coupon.invalid_number_contact")
|
||||
|
||||
if (canCouponNumber.member != null) {
|
||||
throw SodaException("이미 사용한 쿠폰번호 입니다.")
|
||||
throw SodaException(messageKey = "can.coupon.already_used")
|
||||
}
|
||||
|
||||
return canCouponNumber
|
||||
@@ -34,17 +34,17 @@ class CanCouponIssueService(private val couponNumberRepository: CanCouponNumberR
|
||||
|
||||
private fun validateCoupon(canCoupon: CanCoupon) {
|
||||
if (canCoupon.validity < LocalDateTime.now()) {
|
||||
throw SodaException("유효기간이 경과된 쿠폰입니다.")
|
||||
throw SodaException(messageKey = "can.coupon.expired")
|
||||
}
|
||||
|
||||
if (!canCoupon.isActive) {
|
||||
throw SodaException("이용이 불가능한 쿠폰입니다.")
|
||||
throw SodaException(messageKey = "can.coupon.inactive")
|
||||
}
|
||||
}
|
||||
|
||||
fun checkAnyChanges(request: ModifyCanCouponRequest) {
|
||||
if (request.isMultipleUse == null && request.isActive == null && request.validity == null) {
|
||||
throw SodaException("변경사항이 없습니다.")
|
||||
throw SodaException(messageKey = "can.coupon.no_changes")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import kr.co.vividnext.sodalive.aws.sqs.SqsEvent
|
||||
import kr.co.vividnext.sodalive.aws.sqs.SqsEventType
|
||||
import kr.co.vividnext.sodalive.can.charge.ChargeService
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.member.MemberRepository
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
@@ -29,7 +31,9 @@ class CanCouponService(
|
||||
private val memberRepository: MemberRepository,
|
||||
|
||||
private val objectMapper: ObjectMapper,
|
||||
private val applicationEventPublisher: ApplicationEventPublisher
|
||||
private val applicationEventPublisher: ApplicationEventPublisher,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext
|
||||
) {
|
||||
fun generateCoupon(request: GenerateCanCouponRequest) {
|
||||
val message = objectMapper.writeValueAsString(request)
|
||||
@@ -41,7 +45,7 @@ class CanCouponService(
|
||||
issueService.checkAnyChanges(request)
|
||||
|
||||
val canCoupon = repository.findByIdOrNull(id = request.couponId)
|
||||
?: throw SodaException("잘못된 쿠폰번호입니다.\n고객센터로 문의해 주시기 바랍니다.")
|
||||
?: throw SodaException(messageKey = "can.coupon.invalid_number_contact")
|
||||
|
||||
if (request.validity != null) {
|
||||
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
@@ -51,7 +55,7 @@ class CanCouponService(
|
||||
.toLocalDateTime()
|
||||
|
||||
if (validity <= canCoupon.validity) {
|
||||
throw SodaException("유효기간은 기존 유효기간 이후 날짜로 설정하실 수 있습니다.")
|
||||
throw SodaException(messageKey = "can.coupon.validity_after_current")
|
||||
}
|
||||
|
||||
canCoupon.validity = validity
|
||||
@@ -85,7 +89,11 @@ class CanCouponService(
|
||||
}
|
||||
|
||||
fun downloadCouponNumberList(couponId: Long): ByteArrayInputStream {
|
||||
val header = listOf("순번", "쿠폰번호", "사용여부")
|
||||
val header = listOf(
|
||||
messageSource.getMessage("can.coupon.download_header.index", langContext.lang).orEmpty(),
|
||||
messageSource.getMessage("can.coupon.download_header.number", langContext.lang).orEmpty(),
|
||||
messageSource.getMessage("can.coupon.download_header.used", langContext.lang).orEmpty()
|
||||
)
|
||||
val byteArrayOutputStream = ByteArrayOutputStream()
|
||||
val couponNumberList = couponNumberRepository.getAllCouponNumberList(couponId)
|
||||
|
||||
@@ -104,9 +112,9 @@ class CanCouponService(
|
||||
couponNumberRow.createCell(1).setCellValue(insertHyphens(item.couponNumber))
|
||||
couponNumberRow.createCell(2).setCellValue(
|
||||
if (item.isUsed) {
|
||||
"O"
|
||||
messageSource.getMessage("can.coupon.download_used_mark", langContext.lang).orEmpty()
|
||||
} else {
|
||||
"X"
|
||||
messageSource.getMessage("can.coupon.download_unused_mark", langContext.lang).orEmpty()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -114,7 +122,7 @@ class CanCouponService(
|
||||
workbook.write(byteArrayOutputStream)
|
||||
return ByteArrayInputStream(byteArrayOutputStream.toByteArray())
|
||||
} catch (e: IOException) {
|
||||
throw SodaException("다운로드를 하지 못했습니다.\n다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "can.coupon.download_failed_retry")
|
||||
} finally {
|
||||
workbook.close()
|
||||
byteArrayOutputStream.close()
|
||||
@@ -123,9 +131,9 @@ class CanCouponService(
|
||||
|
||||
fun useCanCoupon(couponNumber: String, memberId: Long): String {
|
||||
val member = memberRepository.findByIdOrNull(id = memberId)
|
||||
?: throw SodaException("로그인 정보를 확인해주세요.")
|
||||
?: throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
if (member.auth == null) throw SodaException("쿠폰은 본인인증을 하셔야 사용이 가능합니다.")
|
||||
if (member.auth == null) throw SodaException(messageKey = "can.coupon.auth_required")
|
||||
|
||||
issueService.validateAvailableUseCoupon(couponNumber, memberId)
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.content.AudioContent
|
||||
import kr.co.vividnext.sodalive.content.order.Order
|
||||
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.CreatorCommunity
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.live.room.LiveRoom
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRepository
|
||||
@@ -31,7 +33,9 @@ class CanPaymentService(
|
||||
private val memberRepository: MemberRepository,
|
||||
private val chargeRepository: ChargeRepository,
|
||||
private val useCanRepository: UseCanRepository,
|
||||
private val useCanCalculateRepository: UseCanCalculateRepository
|
||||
private val useCanCalculateRepository: UseCanCalculateRepository,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext
|
||||
) {
|
||||
@Transactional
|
||||
fun spendCan(
|
||||
@@ -49,7 +53,7 @@ class CanPaymentService(
|
||||
container: String
|
||||
) {
|
||||
val member = memberRepository.findByIdOrNull(id = memberId)
|
||||
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "can.payment.invalid_request_retry")
|
||||
val useRewardCan = spendRewardCan(member, needCan, container)
|
||||
val useChargeCan = if (needCan - useRewardCan.total > 0) {
|
||||
spendChargeCan(member, needCan = needCan - useRewardCan.total, container = container)
|
||||
@@ -58,14 +62,14 @@ class CanPaymentService(
|
||||
}
|
||||
|
||||
if (needCan - useRewardCan.total - (useChargeCan?.total ?: 0) > 0) {
|
||||
val shortCan = needCan - useRewardCan.total - (useChargeCan?.total ?: 0)
|
||||
throw SodaException(
|
||||
"${needCan - useRewardCan.total - (useChargeCan?.total ?: 0)} " +
|
||||
"캔이 부족합니다. 충전 후 이용해 주세요."
|
||||
formatMessage("can.payment.insufficient_can", shortCan)
|
||||
)
|
||||
}
|
||||
|
||||
if (!useRewardCan.verify() || useChargeCan?.verify() == false) {
|
||||
throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "can.payment.invalid_request_retry")
|
||||
}
|
||||
|
||||
val useCan = UseCan(
|
||||
@@ -121,7 +125,7 @@ class CanPaymentService(
|
||||
useCan.chatRoomId = chatRoomId
|
||||
useCan.characterId = characterId
|
||||
} else {
|
||||
throw SodaException("잘못된 요청입니다.")
|
||||
throw SodaException(messageKey = "common.error.invalid_request")
|
||||
}
|
||||
|
||||
useCanRepository.save(useCan)
|
||||
@@ -306,20 +310,20 @@ class CanPaymentService(
|
||||
@Transactional
|
||||
fun refund(memberId: Long, roomId: Long) {
|
||||
val member = memberRepository.findByIdOrNull(memberId)
|
||||
?: throw SodaException("잘못된 예약정보 입니다.")
|
||||
?: throw SodaException(messageKey = "can.payment.invalid_reservation")
|
||||
|
||||
val useCan = repository.getCanUsedForLiveRoomNotRefund(
|
||||
memberId = memberId,
|
||||
roomId = roomId,
|
||||
canUsage = CanUsage.LIVE
|
||||
) ?: throw SodaException("잘못된 예약정보 입니다.")
|
||||
) ?: throw SodaException(messageKey = "can.payment.invalid_reservation")
|
||||
useCan.isRefund = true
|
||||
|
||||
val useCanCalculates = useCanCalculateRepository.findByUseCanIdAndStatus(useCan.id!!)
|
||||
useCanCalculates.forEach {
|
||||
it.status = UseCanCalculateStatus.REFUND
|
||||
val charge = Charge(0, it.can, status = ChargeStatus.REFUND_CHARGE)
|
||||
charge.title = "${it.can} 캔"
|
||||
charge.title = formatMessage("can.charge.title", it.can)
|
||||
charge.useCan = useCan
|
||||
|
||||
when (it.paymentGateway) {
|
||||
@@ -333,7 +337,9 @@ class CanPaymentService(
|
||||
status = PaymentStatus.COMPLETE,
|
||||
paymentGateway = it.paymentGateway
|
||||
)
|
||||
payment.method = "환불"
|
||||
payment.method = messageSource
|
||||
.getMessage("can.payment.method.refund", langContext.lang)
|
||||
.orEmpty()
|
||||
charge.payment = payment
|
||||
|
||||
chargeRepository.save(charge)
|
||||
@@ -348,7 +354,7 @@ class CanPaymentService(
|
||||
container: String
|
||||
) {
|
||||
val member = memberRepository.findByIdOrNull(id = memberId)
|
||||
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "can.payment.invalid_request_retry")
|
||||
|
||||
val useRewardCan = spendRewardCan(member, needCan, container)
|
||||
val useChargeCan = if (needCan - useRewardCan.total > 0) {
|
||||
@@ -358,14 +364,14 @@ class CanPaymentService(
|
||||
}
|
||||
|
||||
if (needCan - useRewardCan.total - (useChargeCan?.total ?: 0) > 0) {
|
||||
val shortCan = needCan - useRewardCan.total - (useChargeCan?.total ?: 0)
|
||||
throw SodaException(
|
||||
"${needCan - useRewardCan.total - (useChargeCan?.total ?: 0)} " +
|
||||
"캔이 부족합니다. 충전 후 이용해 주세요."
|
||||
formatMessage("can.payment.insufficient_can", shortCan)
|
||||
)
|
||||
}
|
||||
|
||||
if (!useRewardCan.verify() || useChargeCan?.verify() == false) {
|
||||
throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "can.payment.invalid_request_retry")
|
||||
}
|
||||
|
||||
val useCan = UseCan(
|
||||
@@ -394,7 +400,7 @@ class CanPaymentService(
|
||||
container: String
|
||||
) {
|
||||
val member = memberRepository.findByIdOrNull(id = memberId)
|
||||
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "can.payment.invalid_request_retry")
|
||||
|
||||
val useRewardCan = spendRewardCan(member, needCan, container)
|
||||
val useChargeCan = if (needCan - useRewardCan.total > 0) {
|
||||
@@ -404,14 +410,14 @@ class CanPaymentService(
|
||||
}
|
||||
|
||||
if (needCan - useRewardCan.total - (useChargeCan?.total ?: 0) > 0) {
|
||||
val shortCan = needCan - useRewardCan.total - (useChargeCan?.total ?: 0)
|
||||
throw SodaException(
|
||||
"${needCan - useRewardCan.total - (useChargeCan?.total ?: 0)} " +
|
||||
"캔이 부족합니다. 충전 후 이용해 주세요."
|
||||
formatMessage("can.payment.insufficient_can", shortCan)
|
||||
)
|
||||
}
|
||||
|
||||
if (!useRewardCan.verify() || useChargeCan?.verify() == false) {
|
||||
throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "can.payment.invalid_request_retry")
|
||||
}
|
||||
|
||||
val useCan = UseCan(
|
||||
@@ -435,4 +441,9 @@ class CanPaymentService(
|
||||
setUseCanCalculate(null, useRewardCan, useChargeCan, useCan, paymentGateway = PaymentGateway.GOOGLE_IAP)
|
||||
setUseCanCalculate(null, useRewardCan, useChargeCan, useCan, paymentGateway = PaymentGateway.APPLE_IAP)
|
||||
}
|
||||
|
||||
private fun formatMessage(key: String, vararg args: Any): String {
|
||||
val template = messageSource.getMessage(key, langContext.lang) ?: return ""
|
||||
return String.format(template, *args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package kr.co.vividnext.sodalive.chat.character.comment
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||
@@ -18,6 +20,8 @@ import org.springframework.web.bind.annotation.RestController
|
||||
@RequestMapping("/api/chat/character")
|
||||
class CharacterCommentController(
|
||||
private val service: CharacterCommentService,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext,
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val imageHost: String
|
||||
) {
|
||||
@@ -28,9 +32,9 @@ class CharacterCommentController(
|
||||
@RequestBody request: CreateCharacterCommentRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (request.comment.isBlank()) throw SodaException("댓글 내용을 입력해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
if (request.comment.isBlank()) throw SodaException(messageKey = "chat.character.comment.required")
|
||||
|
||||
val id = service.addComment(characterId, member, request.comment)
|
||||
ApiResponse.ok(id)
|
||||
@@ -43,9 +47,9 @@ class CharacterCommentController(
|
||||
@RequestBody request: CreateCharacterCommentRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (request.comment.isBlank()) throw SodaException("댓글 내용을 입력해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
if (request.comment.isBlank()) throw SodaException(messageKey = "chat.character.comment.required")
|
||||
|
||||
val id = service.addReply(characterId, commentId, member, request.comment, request.languageCode)
|
||||
ApiResponse.ok(id)
|
||||
@@ -58,8 +62,8 @@ class CharacterCommentController(
|
||||
@RequestParam(required = false) cursor: Long?,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val data = service.listComments(imageHost, characterId, cursor, limit)
|
||||
ApiResponse.ok(data)
|
||||
@@ -73,8 +77,8 @@ class CharacterCommentController(
|
||||
@RequestParam(required = false) cursor: Long?,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
// characterId는 서비스 내부 검증(원본 댓글과 캐릭터 일치)에서 검증됨
|
||||
val data = service.getReplies(imageHost, commentId, cursor, limit)
|
||||
@@ -87,10 +91,11 @@ class CharacterCommentController(
|
||||
@PathVariable commentId: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
service.deleteComment(characterId, commentId, member)
|
||||
ApiResponse.ok(true, "댓글이 삭제되었습니다.")
|
||||
val message = messageSource.getMessage("chat.character.comment.deleted", langContext.lang)
|
||||
ApiResponse.ok(true, message)
|
||||
}
|
||||
|
||||
@PostMapping("/{characterId}/comments/{commentId}/reports")
|
||||
@@ -100,9 +105,10 @@ class CharacterCommentController(
|
||||
@RequestBody request: ReportCharacterCommentRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
service.reportComment(characterId, commentId, member, request.content)
|
||||
ApiResponse.ok(true, "신고가 접수되었습니다.")
|
||||
val message = messageSource.getMessage("chat.character.comment.reported", langContext.lang)
|
||||
ApiResponse.ok(true, message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class CharacterCommentService(
|
||||
entity: CharacterComment,
|
||||
replyCountOverride: Int? = null
|
||||
): CharacterCommentResponse {
|
||||
val member = entity.member ?: throw SodaException("유효하지 않은 댓글입니다.")
|
||||
val member = entity.member ?: throw SodaException(messageKey = "chat.character.comment.invalid")
|
||||
return CharacterCommentResponse(
|
||||
commentId = entity.id!!,
|
||||
memberId = member.id!!,
|
||||
@@ -50,7 +50,7 @@ class CharacterCommentService(
|
||||
}
|
||||
|
||||
private fun toReplyResponse(imageHost: String, entity: CharacterComment): CharacterReplyResponse {
|
||||
val member = entity.member ?: throw SodaException("유효하지 않은 댓글입니다.")
|
||||
val member = entity.member ?: throw SodaException(messageKey = "chat.character.comment.invalid")
|
||||
return CharacterReplyResponse(
|
||||
replyId = entity.id!!,
|
||||
memberId = member.id!!,
|
||||
@@ -64,9 +64,10 @@ class CharacterCommentService(
|
||||
|
||||
@Transactional
|
||||
fun addComment(characterId: Long, member: Member, text: String, languageCode: String? = null): Long {
|
||||
val character = chatCharacterRepository.findById(characterId).orElseThrow { SodaException("캐릭터를 찾을 수 없습니다.") }
|
||||
if (!character.isActive) throw SodaException("비활성화된 캐릭터입니다.")
|
||||
if (text.isBlank()) throw SodaException("댓글 내용을 입력해주세요.")
|
||||
val character = chatCharacterRepository.findById(characterId)
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.not_found") }
|
||||
if (!character.isActive) throw SodaException(messageKey = "chat.character.inactive")
|
||||
if (text.isBlank()) throw SodaException(messageKey = "chat.character.comment.required")
|
||||
|
||||
val entity = CharacterComment(comment = text, languageCode = languageCode)
|
||||
entity.chatCharacter = character
|
||||
@@ -95,12 +96,14 @@ class CharacterCommentService(
|
||||
text: String,
|
||||
languageCode: String? = null
|
||||
): Long {
|
||||
val character = chatCharacterRepository.findById(characterId).orElseThrow { SodaException("캐릭터를 찾을 수 없습니다.") }
|
||||
if (!character.isActive) throw SodaException("비활성화된 캐릭터입니다.")
|
||||
val parent = commentRepository.findById(parentCommentId).orElseThrow { SodaException("댓글을 찾을 수 없습니다.") }
|
||||
if (parent.chatCharacter?.id != characterId) throw SodaException("잘못된 요청입니다.")
|
||||
if (!parent.isActive) throw SodaException("비활성화된 댓글입니다.")
|
||||
if (text.isBlank()) throw SodaException("댓글 내용을 입력해주세요.")
|
||||
val character = chatCharacterRepository.findById(characterId)
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.not_found") }
|
||||
if (!character.isActive) throw SodaException(messageKey = "chat.character.inactive")
|
||||
val parent = commentRepository.findById(parentCommentId)
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.comment.not_found") }
|
||||
if (parent.chatCharacter?.id != characterId) throw SodaException(messageKey = "common.error.invalid_request")
|
||||
if (!parent.isActive) throw SodaException(messageKey = "chat.character.comment.inactive")
|
||||
if (text.isBlank()) throw SodaException(messageKey = "chat.character.comment.required")
|
||||
|
||||
val entity = CharacterComment(comment = text, languageCode = languageCode)
|
||||
entity.chatCharacter = character
|
||||
@@ -162,9 +165,9 @@ class CharacterCommentService(
|
||||
limit: Int = 20
|
||||
): CharacterCommentRepliesResponse {
|
||||
val original = commentRepository.findById(commentId).orElseThrow {
|
||||
SodaException("댓글을 찾을 수 없습니다.")
|
||||
SodaException(messageKey = "chat.character.comment.not_found")
|
||||
}
|
||||
if (!original.isActive) throw SodaException("비활성화된 댓글입니다.")
|
||||
if (!original.isActive) throw SodaException(messageKey = "chat.character.comment.inactive")
|
||||
|
||||
val pageable = PageRequest.of(0, limit)
|
||||
val replies = if (cursor == null) {
|
||||
@@ -207,20 +210,22 @@ class CharacterCommentService(
|
||||
|
||||
@Transactional
|
||||
fun deleteComment(characterId: Long, commentId: Long, member: Member) {
|
||||
val comment = commentRepository.findById(commentId).orElseThrow { SodaException("댓글을 찾을 수 없습니다.") }
|
||||
if (comment.chatCharacter?.id != characterId) throw SodaException("잘못된 요청입니다.")
|
||||
val comment = commentRepository.findById(commentId)
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.comment.not_found") }
|
||||
if (comment.chatCharacter?.id != characterId) throw SodaException(messageKey = "common.error.invalid_request")
|
||||
if (!comment.isActive) return
|
||||
val ownerId = comment.member?.id ?: throw SodaException("유효하지 않은 댓글입니다.")
|
||||
if (ownerId != member.id) throw SodaException("삭제 권한이 없습니다.")
|
||||
val ownerId = comment.member?.id ?: throw SodaException(messageKey = "chat.character.comment.invalid")
|
||||
if (ownerId != member.id) throw SodaException(messageKey = "chat.character.comment.delete_forbidden")
|
||||
comment.isActive = false
|
||||
commentRepository.save(comment)
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun reportComment(characterId: Long, commentId: Long, member: Member, content: String) {
|
||||
val comment = commentRepository.findById(commentId).orElseThrow { SodaException("댓글을 찾을 수 없습니다.") }
|
||||
if (comment.chatCharacter?.id != characterId) throw SodaException("잘못된 요청입니다.")
|
||||
if (content.isBlank()) throw SodaException("신고 내용을 입력해주세요.")
|
||||
val comment = commentRepository.findById(commentId)
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.comment.not_found") }
|
||||
if (comment.chatCharacter?.id != characterId) throw SodaException(messageKey = "common.error.invalid_request")
|
||||
if (content.isBlank()) throw SodaException(messageKey = "chat.character.comment.report_content_required")
|
||||
|
||||
val report = CharacterCommentReport(content = content)
|
||||
report.comment = comment
|
||||
|
||||
@@ -155,12 +155,12 @@ class ChatCharacterController(
|
||||
@PathVariable characterId: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
// 캐릭터 상세 정보 조회
|
||||
val character = service.getCharacterDetail(characterId)
|
||||
?: throw SodaException("캐릭터를 찾을 수 없습니다.")
|
||||
?: throw SodaException(messageKey = "chat.character.not_found")
|
||||
|
||||
// 태그 가공: # prefix 규칙 적용 후 공백으로 연결
|
||||
val tags = character.tagMappings
|
||||
|
||||
@@ -36,8 +36,8 @@ class CharacterImageController(
|
||||
@RequestParam(required = false, defaultValue = "20") size: Int,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val pageSize = if (size <= 0) 20 else minOf(size, 20)
|
||||
|
||||
@@ -124,8 +124,8 @@ class CharacterImageController(
|
||||
@RequestParam(required = false, defaultValue = "20") size: Int,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val pageSize = if (size <= 0) 20 else minOf(size, 20)
|
||||
val expiration = 5L * 60L * 1000L // 5분
|
||||
@@ -198,18 +198,18 @@ class CharacterImageController(
|
||||
@RequestBody req: CharacterImagePurchaseRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val image = imageService.getById(req.imageId)
|
||||
if (!image.isActive) throw SodaException("비활성화된 이미지입니다.")
|
||||
if (!image.isActive) throw SodaException(messageKey = "chat.character.image.inactive")
|
||||
|
||||
val isOwned = (image.imagePriceCan == 0L) ||
|
||||
imageService.isOwnedImageByMember(image.id!!, member.id!!)
|
||||
|
||||
if (!isOwned) {
|
||||
val needCan = image.imagePriceCan.toInt()
|
||||
if (needCan <= 0) throw SodaException("구매 가격이 잘못되었습니다.")
|
||||
if (needCan <= 0) throw SodaException(messageKey = "chat.purchase.invalid_price")
|
||||
|
||||
canPaymentService.spendCanForCharacterImage(
|
||||
memberId = member.id!!,
|
||||
|
||||
@@ -64,11 +64,11 @@ class CharacterImageService(
|
||||
}
|
||||
|
||||
fun getById(id: Long): CharacterImage =
|
||||
imageRepository.findById(id).orElseThrow { SodaException("캐릭터 이미지를 찾을 수 없습니다: $id") }
|
||||
imageRepository.findById(id).orElseThrow { SodaException(messageKey = "chat.character.image.not_found") }
|
||||
|
||||
fun getCharacterImagePath(characterId: Long): String? {
|
||||
val character = characterRepository.findById(characterId)
|
||||
.orElseThrow { SodaException("캐릭터를 찾을 수 없습니다: $characterId") }
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.not_found") }
|
||||
return character.imagePath
|
||||
}
|
||||
|
||||
@@ -94,11 +94,13 @@ class CharacterImageService(
|
||||
triggers: List<String>
|
||||
): CharacterImage {
|
||||
val character = characterRepository.findById(characterId)
|
||||
.orElseThrow { SodaException("캐릭터를 찾을 수 없습니다: $characterId") }
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.not_found") }
|
||||
|
||||
if (imagePriceCan < 0 || messagePriceCan < 0) throw SodaException("가격은 0 can 이상이어야 합니다.")
|
||||
if (imagePriceCan < 0 || messagePriceCan < 0) {
|
||||
throw SodaException(messageKey = "chat.character.image.min_price")
|
||||
}
|
||||
|
||||
if (!character.isActive) throw SodaException("비활성화된 캐릭터에는 이미지를 등록할 수 없습니다: $characterId")
|
||||
if (!character.isActive) throw SodaException(messageKey = "chat.character.inactive_image_register")
|
||||
|
||||
val nextOrder = (imageRepository.findMaxSortOrderByCharacterId(characterId)) + 1
|
||||
val entity = CharacterImage(
|
||||
@@ -122,7 +124,7 @@ class CharacterImageService(
|
||||
@Transactional
|
||||
fun updateTriggers(imageId: Long, triggers: List<String>): CharacterImage {
|
||||
val image = getById(imageId)
|
||||
if (!image.isActive) throw SodaException("비활성화된 이미지는 수정할 수 없습니다: $imageId")
|
||||
if (!image.isActive) throw SodaException(messageKey = "chat.character.image.inactive_update")
|
||||
applyTriggers(image, triggers)
|
||||
return image
|
||||
}
|
||||
@@ -159,8 +161,10 @@ class CharacterImageService(
|
||||
val updated = mutableListOf<CharacterImage>()
|
||||
ids.forEachIndexed { idx, id ->
|
||||
val img = getById(id)
|
||||
if (img.chatCharacter.id != characterId) throw SodaException("다른 캐릭터의 이미지가 포함되어 있습니다: $id")
|
||||
if (!img.isActive) throw SodaException("비활성화된 이미지는 순서를 변경할 수 없습니다: $id")
|
||||
if (img.chatCharacter.id != characterId) {
|
||||
throw SodaException(messageKey = "chat.character.image.other_character_included")
|
||||
}
|
||||
if (!img.isActive) throw SodaException(messageKey = "chat.character.image.inactive_order_change")
|
||||
img.sortOrder = idx + 1
|
||||
updated.add(img)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class ChatCharacterBannerService(
|
||||
*/
|
||||
fun getBannerById(bannerId: Long): ChatCharacterBanner {
|
||||
return bannerRepository.findById(bannerId)
|
||||
.orElseThrow { SodaException("배너를 찾을 수 없습니다: $bannerId") }
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.banner.not_found") }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,10 +39,10 @@ class ChatCharacterBannerService(
|
||||
@Transactional
|
||||
fun registerBanner(characterId: Long, imagePath: String): ChatCharacterBanner {
|
||||
val character = characterRepository.findById(characterId)
|
||||
.orElseThrow { SodaException("캐릭터를 찾을 수 없습니다: $characterId") }
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.not_found") }
|
||||
|
||||
if (!character.isActive) {
|
||||
throw SodaException("비활성화된 캐릭터에는 배너를 등록할 수 없습니다: $characterId")
|
||||
throw SodaException(messageKey = "chat.character.inactive_banner_register")
|
||||
}
|
||||
|
||||
// 정렬 순서가 지정되지 않은 경우 가장 마지막 순서로 설정
|
||||
@@ -68,10 +68,10 @@ class ChatCharacterBannerService(
|
||||
@Transactional
|
||||
fun updateBanner(bannerId: Long, imagePath: String? = null, characterId: Long? = null): ChatCharacterBanner {
|
||||
val banner = bannerRepository.findById(bannerId)
|
||||
.orElseThrow { SodaException("배너를 찾을 수 없습니다: $bannerId") }
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.banner.not_found") }
|
||||
|
||||
if (!banner.isActive) {
|
||||
throw SodaException("비활성화된 배너는 수정할 수 없습니다: $bannerId")
|
||||
throw SodaException(messageKey = "chat.character.banner.inactive_update")
|
||||
}
|
||||
|
||||
// 이미지 경로 변경
|
||||
@@ -82,10 +82,10 @@ class ChatCharacterBannerService(
|
||||
// 캐릭터 변경
|
||||
if (characterId != null) {
|
||||
val character = characterRepository.findById(characterId)
|
||||
.orElseThrow { SodaException("캐릭터를 찾을 수 없습니다: $characterId") }
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.not_found") }
|
||||
|
||||
if (!character.isActive) {
|
||||
throw SodaException("비활성화된 캐릭터로는 변경할 수 없습니다: $characterId")
|
||||
throw SodaException(messageKey = "chat.character.inactive_banner_change")
|
||||
}
|
||||
|
||||
banner.chatCharacter = character
|
||||
@@ -100,7 +100,7 @@ class ChatCharacterBannerService(
|
||||
@Transactional
|
||||
fun deleteBanner(bannerId: Long) {
|
||||
val banner = bannerRepository.findById(bannerId)
|
||||
.orElseThrow { SodaException("배너를 찾을 수 없습니다: $bannerId") }
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.banner.not_found") }
|
||||
|
||||
banner.isActive = false
|
||||
bannerRepository.save(banner)
|
||||
@@ -119,10 +119,10 @@ class ChatCharacterBannerService(
|
||||
|
||||
for (index in ids.indices) {
|
||||
val banner = bannerRepository.findById(ids[index])
|
||||
.orElseThrow { SodaException("배너를 찾을 수 없습니다: ${ids[index]}") }
|
||||
.orElseThrow { SodaException(messageKey = "chat.character.banner.not_found") }
|
||||
|
||||
if (!banner.isActive) {
|
||||
throw SodaException("비활성화된 배너는 수정할 수 없습니다: ${ids[index]}")
|
||||
throw SodaException(messageKey = "chat.character.banner.inactive_update")
|
||||
}
|
||||
|
||||
banner.sortOrder = index + 1
|
||||
|
||||
@@ -702,7 +702,7 @@ class ChatCharacterService(
|
||||
): ChatCharacter {
|
||||
// 캐릭터 조회
|
||||
val chatCharacter = findById(request.id)
|
||||
?: throw kr.co.vividnext.sodalive.common.SodaException("해당 ID의 캐릭터를 찾을 수 없습니다: ${request.id}")
|
||||
?: throw kr.co.vividnext.sodalive.common.SodaException(messageKey = "chat.character.not_found")
|
||||
|
||||
// isActive가 false이면 isActive = false, name = "inactive_$name"으로 변경하고 나머지는 반영하지 않는다.
|
||||
if (request.isActive != null && !request.isActive) {
|
||||
|
||||
@@ -126,8 +126,8 @@ class OriginalWorkController(
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val ow = queryService.getOriginalWork(id)
|
||||
val chars = queryService.getActiveCharactersPage(id, page = 0, size = 20).content
|
||||
|
||||
@@ -44,7 +44,7 @@ class OriginalWorkQueryService(
|
||||
@Transactional(readOnly = true)
|
||||
fun getOriginalWork(id: Long): OriginalWork {
|
||||
return originalWorkRepository.findByIdAndIsDeletedFalse(id)
|
||||
.orElseThrow { SodaException("해당 원작을 찾을 수 없습니다") }
|
||||
.orElseThrow { SodaException(messageKey = "chat.original.not_found") }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ class OriginalWorkQueryService(
|
||||
fun getActiveCharactersPage(originalWorkId: Long, page: Int = 0, size: Int = 20): Page<ChatCharacter> {
|
||||
// 원작 존재 및 소프트 삭제 여부 확인
|
||||
originalWorkRepository.findByIdAndIsDeletedFalse(originalWorkId)
|
||||
.orElseThrow { SodaException("해당 원작을 찾을 수 없습니다") }
|
||||
.orElseThrow { SodaException(messageKey = "chat.original.not_found") }
|
||||
|
||||
val safePage = if (page < 0) 0 else page
|
||||
val safeSize = when {
|
||||
|
||||
@@ -32,8 +32,8 @@ class ChatQuotaController(
|
||||
fun getMyQuota(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
): ApiResponse<ChatQuotaStatusResponse> = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val s = chatQuotaService.getStatus(member.id!!)
|
||||
ApiResponse.ok(ChatQuotaStatusResponse(s.totalRemaining, s.nextRechargeAtEpochMillis))
|
||||
@@ -44,9 +44,9 @@ class ChatQuotaController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
@RequestBody request: ChatQuotaPurchaseRequest
|
||||
): ApiResponse<ChatQuotaStatusResponse> = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (request.container.isBlank()) throw SodaException("container를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
if (request.container.isBlank()) throw SodaException(messageKey = "chat.quota.container_required")
|
||||
|
||||
// 30캔 차감 처리 (결제 기록 남김)
|
||||
canPaymentService.spendCan(
|
||||
|
||||
@@ -52,27 +52,27 @@ class ChatRoomQuotaController(
|
||||
@PathVariable chatRoomId: Long,
|
||||
@RequestBody req: PurchaseRoomQuotaRequest
|
||||
): ApiResponse<PurchaseRoomQuotaResponse> = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (req.container.isBlank()) throw SodaException("잘못된 접근입니다")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
if (req.container.isBlank()) throw SodaException(messageKey = "chat.room.quota.invalid_access")
|
||||
|
||||
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
||||
?: throw SodaException("채팅방을 찾을 수 없습니다.")
|
||||
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
||||
|
||||
// 내 참여 여부 확인
|
||||
participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
||||
?: throw SodaException("잘못된 접근입니다")
|
||||
?: throw SodaException(messageKey = "chat.room.quota.invalid_access")
|
||||
|
||||
// 캐릭터 참여자 확인(유효한 AI 캐릭터 방인지 체크 및 characterId 기본값 보조)
|
||||
val characterParticipant = participantRepository
|
||||
.findByChatRoomAndParticipantTypeAndIsActiveTrue(room, ParticipantType.CHARACTER)
|
||||
?: throw SodaException("AI 캐릭터 채팅방이 아닙니다.")
|
||||
?: throw SodaException(messageKey = "chat.room.quota.not_ai_room")
|
||||
|
||||
val character = characterParticipant.character
|
||||
?: throw SodaException("AI 캐릭터 채팅방이 아닙니다.")
|
||||
?: throw SodaException(messageKey = "chat.room.quota.not_ai_room")
|
||||
|
||||
val characterId = character.id
|
||||
?: throw SodaException("잘못된 요청입니다. 캐릭터 정보를 확인해주세요.")
|
||||
?: throw SodaException(messageKey = "chat.room.quota.character_required")
|
||||
|
||||
// 서비스에서 결제 포함하여 처리
|
||||
val status = chatRoomQuotaService.purchase(
|
||||
@@ -98,20 +98,20 @@ class ChatRoomQuotaController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
@PathVariable chatRoomId: Long
|
||||
): ApiResponse<RoomQuotaStatusResponse> = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
||||
?: throw SodaException("채팅방을 찾을 수 없습니다.")
|
||||
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
||||
// 내 참여 여부 확인
|
||||
participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
||||
?: throw SodaException("잘못된 접근입니다")
|
||||
?: throw SodaException(messageKey = "chat.room.quota.invalid_access")
|
||||
// 캐릭터 확인
|
||||
val characterParticipant = participantRepository
|
||||
.findByChatRoomAndParticipantTypeAndIsActiveTrue(room, ParticipantType.CHARACTER)
|
||||
?: throw SodaException("AI 캐릭터 채팅방이 아닙니다.")
|
||||
?: throw SodaException(messageKey = "chat.room.quota.not_ai_room")
|
||||
val character = characterParticipant.character
|
||||
?: throw SodaException("AI 캐릭터 채팅방이 아닙니다.")
|
||||
?: throw SodaException(messageKey = "chat.room.quota.not_ai_room")
|
||||
|
||||
// 글로벌 Lazy refill
|
||||
val globalStatus = chatQuotaService.getStatus(member.id!!)
|
||||
|
||||
@@ -75,7 +75,7 @@ class ChatRoomQuotaService(
|
||||
val now = Instant.now()
|
||||
val nowMillis = now.toEpochMilli()
|
||||
val quota = repo.findForUpdate(memberId, chatRoomId)
|
||||
?: throw SodaException("채팅방을 찾을 수 없습니다.")
|
||||
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
||||
|
||||
// 충전 시간이 지났다면 무료 10으로 리셋하고 next=null
|
||||
if (quota.nextRechargeAt != null && quota.nextRechargeAt!! <= nowMillis) {
|
||||
@@ -98,7 +98,7 @@ class ChatRoomQuotaService(
|
||||
val globalFree = globalFreeProvider()
|
||||
if (globalFree <= 0) {
|
||||
// 전송 차단: 글로벌 무료가 0이며 유료도 0 → 전송 불가
|
||||
throw SodaException("오늘의 무료 채팅이 모두 소진되었습니다. 내일 다시 이용해 주세요.")
|
||||
throw SodaException(messageKey = "chat.room.quota.global_free_exhausted")
|
||||
}
|
||||
if (quota.remainingFree <= 0) {
|
||||
// 전송 차단: 룸 무료가 0이며 유료도 0 → 전송 불가
|
||||
@@ -107,7 +107,7 @@ class ChatRoomQuotaService(
|
||||
quota.nextRechargeAt = now.plus(Duration.ofHours(6)).toEpochMilli()
|
||||
}
|
||||
|
||||
throw SodaException("무료 채팅이 모두 소진되었습니다.")
|
||||
throw SodaException(messageKey = "chat.room.quota.room_free_exhausted")
|
||||
}
|
||||
|
||||
// 둘 다 가능 → 차감
|
||||
|
||||
@@ -42,8 +42,8 @@ class ChatRoomController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
@RequestBody request: CreateChatRoomRequest
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val response = chatRoomService.createOrGetChatRoom(member, request.characterId)
|
||||
ApiResponse.ok(response)
|
||||
@@ -77,8 +77,8 @@ class ChatRoomController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
@PathVariable chatRoomId: Long
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val isActive = chatRoomService.isMyRoomSessionActive(member, chatRoomId)
|
||||
ApiResponse.ok(isActive)
|
||||
@@ -95,8 +95,8 @@ class ChatRoomController(
|
||||
@PathVariable chatRoomId: Long,
|
||||
@RequestParam(required = false) characterImageId: Long?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val response = chatRoomService.enterChatRoom(member, chatRoomId, characterImageId)
|
||||
ApiResponse.ok(response)
|
||||
@@ -114,8 +114,8 @@ class ChatRoomController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
@PathVariable chatRoomId: Long
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
chatRoomService.leaveChatRoom(member, chatRoomId)
|
||||
ApiResponse.ok(true)
|
||||
@@ -134,8 +134,8 @@ class ChatRoomController(
|
||||
@RequestParam(defaultValue = "20") limit: Int,
|
||||
@RequestParam(required = false) cursor: Long?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val response = chatRoomService.getChatMessages(member, chatRoomId, cursor, limit)
|
||||
ApiResponse.ok(response)
|
||||
@@ -153,8 +153,8 @@ class ChatRoomController(
|
||||
@PathVariable chatRoomId: Long,
|
||||
@RequestBody request: SendChatMessageRequest
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
if (request.message.isBlank()) {
|
||||
ApiResponse.error()
|
||||
@@ -176,8 +176,8 @@ class ChatRoomController(
|
||||
@PathVariable messageId: Long,
|
||||
@RequestBody request: ChatMessagePurchaseRequest
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val result = chatRoomService.purchaseMessage(member, chatRoomId, messageId, request.container)
|
||||
ApiResponse.ok(result)
|
||||
@@ -195,8 +195,8 @@ class ChatRoomController(
|
||||
@PathVariable chatRoomId: Long,
|
||||
@RequestBody request: ChatRoomResetRequest
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
if (member.auth == null) throw SodaException(messageKey = "common.error.adult_verification_required")
|
||||
|
||||
val response = chatRoomService.resetChatRoom(member, chatRoomId, request.container)
|
||||
ApiResponse.ok(response)
|
||||
|
||||
@@ -29,6 +29,7 @@ import kr.co.vividnext.sodalive.chat.room.repository.ChatRoomRepository
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.i18n.Lang
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
@@ -54,6 +55,7 @@ class ChatRoomService(
|
||||
private val characterService: ChatCharacterService,
|
||||
private val characterImageService: CharacterImageService,
|
||||
private val langContext: LangContext,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val aiCharacterTranslationRepository: AiCharacterTranslationRepository,
|
||||
private val canPaymentService: kr.co.vividnext.sodalive.can.payment.CanPaymentService,
|
||||
private val imageCloudFront: kr.co.vividnext.sodalive.aws.cloudfront.ImageContentCloudFront,
|
||||
@@ -77,19 +79,19 @@ class ChatRoomService(
|
||||
@Transactional
|
||||
fun purchaseMessage(member: Member, chatRoomId: Long, messageId: Long, container: String): ChatMessageItemDto {
|
||||
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
||||
?: throw SodaException("채팅방을 찾을 수 없습니다.")
|
||||
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
||||
// 참여 여부 검증
|
||||
participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
||||
?: throw SodaException("잘못된 접근입니다")
|
||||
?: throw SodaException(messageKey = "chat.room.invalid_access")
|
||||
|
||||
val message = messageRepository.findById(messageId).orElseThrow {
|
||||
SodaException("메시지를 찾을 수 없습니다.")
|
||||
SodaException(messageKey = "chat.message.not_found")
|
||||
}
|
||||
if (!message.isActive) throw SodaException("비활성화된 메시지입니다.")
|
||||
if (message.chatRoom.id != room.id) throw SodaException("잘못된 접근입니다")
|
||||
if (!message.isActive) throw SodaException(messageKey = "chat.message.inactive")
|
||||
if (message.chatRoom.id != room.id) throw SodaException(messageKey = "chat.room.invalid_access")
|
||||
|
||||
val price = message.price ?: throw SodaException("구매할 수 없는 메시지입니다.")
|
||||
if (price <= 0) throw SodaException("구매 가격이 잘못되었습니다.")
|
||||
val price = message.price ?: throw SodaException(messageKey = "chat.message.not_purchasable")
|
||||
if (price <= 0) throw SodaException(messageKey = "chat.purchase.invalid_price")
|
||||
|
||||
// 이미지 메시지인 경우: 이미 소유했다면 결제 생략하고 DTO 반환
|
||||
if (message.messageType == ChatMessageType.IMAGE) {
|
||||
@@ -124,7 +126,7 @@ class ChatRoomService(
|
||||
fun createOrGetChatRoom(member: Member, characterId: Long): CreateChatRoomResponse {
|
||||
// 1. 캐릭터 조회
|
||||
val character = characterService.findById(characterId)
|
||||
?: throw SodaException("해당 ID의 캐릭터를 찾을 수 없습니다: $characterId")
|
||||
?: throw SodaException(messageKey = "chat.room.character_not_found")
|
||||
|
||||
// 2. 이미 참여 중인 채팅방이 있는지 확인
|
||||
val existingChatRoom = chatRoomRepository.findActiveChatRoomByMemberAndCharacter(member, character)
|
||||
@@ -225,21 +227,21 @@ class ChatRoomService(
|
||||
|
||||
// success가 false이면 throw
|
||||
if (!apiResponse.success) {
|
||||
throw SodaException("채팅방 생성에 실패했습니다. 다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "chat.room.create_failed_retry")
|
||||
}
|
||||
|
||||
// success가 true이면 파라미터로 넘긴 값과 일치하는지 확인
|
||||
val data = apiResponse.data ?: throw SodaException("채팅방 생성에 실패했습니다. 다시 시도해 주세요.")
|
||||
val data = apiResponse.data ?: throw SodaException(messageKey = "chat.room.create_failed_retry")
|
||||
|
||||
if (data.userId != userId && data.character.id != characterUUID && data.status != "active") {
|
||||
throw SodaException("채팅방 생성에 실패했습니다. 다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "chat.room.create_failed_retry")
|
||||
}
|
||||
|
||||
// 세션 ID 반환
|
||||
return data.sessionId
|
||||
} catch (e: Exception) {
|
||||
log.error(e.message)
|
||||
throw SodaException("채팅방 생성에 실패했습니다. 다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "chat.room.create_failed_retry")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +266,7 @@ class ChatRoomService(
|
||||
}
|
||||
} else {
|
||||
if (latest?.message.isNullOrBlank() && latest?.characterImage != null) {
|
||||
"[이미지]"
|
||||
messageSource.getMessage("chat.room.last_message_image", langContext.lang).orEmpty()
|
||||
} else {
|
||||
""
|
||||
}
|
||||
@@ -304,11 +306,19 @@ class ChatRoomService(
|
||||
val now = LocalDateTime.now()
|
||||
val duration = Duration.between(time, now)
|
||||
val seconds = duration.seconds
|
||||
if (seconds <= 60) return "방금"
|
||||
if (seconds <= 60) {
|
||||
return messageSource.getMessage("chat.room.time.just_now", langContext.lang).orEmpty()
|
||||
}
|
||||
val minutes = duration.toMinutes()
|
||||
if (minutes < 60) return "${minutes}분 전"
|
||||
if (minutes < 60) {
|
||||
val template = messageSource.getMessage("chat.room.time.minutes_ago", langContext.lang).orEmpty()
|
||||
return String.format(template, minutes)
|
||||
}
|
||||
val hours = duration.toHours()
|
||||
if (hours < 24) return "${hours}시간 전"
|
||||
if (hours < 24) {
|
||||
val template = messageSource.getMessage("chat.room.time.hours_ago", langContext.lang).orEmpty()
|
||||
return String.format(template, hours)
|
||||
}
|
||||
// 그 외: 날짜 (yyyy-MM-dd)
|
||||
return time.toLocalDate().toString()
|
||||
}
|
||||
@@ -316,11 +326,9 @@ class ChatRoomService(
|
||||
@Transactional(readOnly = true)
|
||||
fun isMyRoomSessionActive(member: Member, chatRoomId: Long): Boolean {
|
||||
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
||||
?: throw SodaException("채팅방을 찾을 수 없습니다.")
|
||||
val participant = participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
||||
if (participant == null) {
|
||||
throw SodaException("잘못된 접근입니다")
|
||||
}
|
||||
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
||||
participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
||||
?: throw SodaException(messageKey = "common.error.access_denied")
|
||||
return fetchSessionActive(room.sessionId)
|
||||
}
|
||||
|
||||
@@ -328,7 +336,7 @@ class ChatRoomService(
|
||||
fun enterChatRoom(member: Member, chatRoomId: Long, characterImageId: Long? = null): ChatRoomEnterResponse {
|
||||
// 1) 활성 여부 무관하게 방 조회
|
||||
val baseRoom = chatRoomRepository.findById(chatRoomId).orElseThrow {
|
||||
SodaException("채팅방을 찾을 수 없습니다.")
|
||||
SodaException(messageKey = "chat.error.room_not_found")
|
||||
}
|
||||
|
||||
// 2) 기본 방 기준 참여/활성 여부 확인
|
||||
@@ -342,10 +350,10 @@ class ChatRoomService(
|
||||
ParticipantType.CHARACTER
|
||||
) ?: baseRoom.participants.firstOrNull {
|
||||
it.participantType == ParticipantType.CHARACTER
|
||||
} ?: throw SodaException("잘못된 접근입니다")
|
||||
} ?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
val baseCharacter = baseCharacterParticipant.character
|
||||
?: throw SodaException("오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "common.error.unknown")
|
||||
|
||||
// 4) 유효한 입장 대상 방 결정
|
||||
val effectiveRoom: ChatRoom = if (isActiveRoom && isMyActiveParticipation) {
|
||||
@@ -355,9 +363,9 @@ class ChatRoomService(
|
||||
val alt = chatRoomRepository.findActiveChatRoomByMemberAndCharacter(member, baseCharacter)
|
||||
alt ?: ( // 대체 방이 없으면 기존과 동일하게 예외 처리
|
||||
if (!isActiveRoom) {
|
||||
throw SodaException("채팅방을 찾을 수 없습니다.")
|
||||
throw SodaException(messageKey = "chat.error.room_not_found")
|
||||
} else {
|
||||
throw SodaException("잘못된 접근입니다")
|
||||
throw SodaException(messageKey = "common.error.invalid_request")
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -368,10 +376,10 @@ class ChatRoomService(
|
||||
ParticipantType.CHARACTER
|
||||
) ?: effectiveRoom.participants.firstOrNull {
|
||||
it.participantType == ParticipantType.CHARACTER
|
||||
} ?: throw SodaException("잘못된 접근입니다")
|
||||
} ?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
val character = characterParticipant.character
|
||||
?: throw SodaException("오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "common.error.unknown")
|
||||
|
||||
val imageUrl = "$imageHost/${character.imagePath ?: "profile/default-profile.png"}"
|
||||
val characterDto = ChatRoomEnterCharacterDto(
|
||||
@@ -512,23 +520,23 @@ class ChatRoomService(
|
||||
|
||||
// success가 false이면 throw
|
||||
if (!apiResponse.success) {
|
||||
throw SodaException("오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "chat.error.retry")
|
||||
}
|
||||
|
||||
val status = apiResponse.data?.status
|
||||
return status == "active"
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
throw SodaException("오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "chat.error.retry")
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun leaveChatRoom(member: Member, chatRoomId: Long, throwOnSessionEndFailure: Boolean = false) {
|
||||
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
||||
?: throw SodaException("채팅방을 찾을 수 없습니다.")
|
||||
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
||||
val participant = participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
||||
?: throw SodaException("잘못된 접근입니다")
|
||||
?: throw SodaException(messageKey = "chat.room.invalid_access")
|
||||
|
||||
// 1) 나가기 처리
|
||||
participant.isActive = false
|
||||
@@ -591,10 +599,9 @@ class ChatRoomService(
|
||||
}
|
||||
}
|
||||
// 최종 실패 처리
|
||||
val message = "채팅방 세션 종료에 실패했습니다. 다시 시도해 주세요."
|
||||
if (throwOnFailure) {
|
||||
log.error("[chat] 외부 세션 종료 최종 실패(예외 전파): sessionId={}, attempts={}", sessionId, maxAttempts)
|
||||
throw SodaException(message)
|
||||
throw SodaException(messageKey = "chat.room.session_end_failed")
|
||||
} else {
|
||||
log.error("[chat] 외부 세션 종료 최종 실패: sessionId={}, attempts={}", sessionId, maxAttempts)
|
||||
}
|
||||
@@ -603,9 +610,9 @@ class ChatRoomService(
|
||||
@Transactional(readOnly = true)
|
||||
fun getChatMessages(member: Member, chatRoomId: Long, cursor: Long?, limit: Int = 20): ChatMessagesPageResponse {
|
||||
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
||||
?: throw SodaException("채팅방을 찾을 수 없습니다.")
|
||||
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
||||
participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
||||
?: throw SodaException("잘못된 접근입니다")
|
||||
?: throw SodaException(messageKey = "chat.room.invalid_access")
|
||||
|
||||
val pageable = PageRequest.of(0, limit)
|
||||
val fetched = if (cursor != null) {
|
||||
@@ -638,18 +645,18 @@ class ChatRoomService(
|
||||
fun sendMessage(member: Member, chatRoomId: Long, message: String): SendChatMessageResponse {
|
||||
// 1) 방 존재 확인
|
||||
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
||||
?: throw SodaException("채팅방을 찾을 수 없습니다.")
|
||||
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
||||
// 2) 참여 여부 확인 (USER)
|
||||
val myParticipant = participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
||||
?: throw SodaException("잘못된 접근입니다")
|
||||
?: throw SodaException(messageKey = "chat.room.invalid_access")
|
||||
// 3) 캐릭터 참여자 조회
|
||||
val characterParticipant = participantRepository.findByChatRoomAndParticipantTypeAndIsActiveTrue(
|
||||
room,
|
||||
ParticipantType.CHARACTER
|
||||
) ?: throw SodaException("잘못된 접근입니다")
|
||||
) ?: throw SodaException(messageKey = "chat.room.invalid_access")
|
||||
|
||||
val character = characterParticipant.character
|
||||
?: throw SodaException("오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "chat.error.retry")
|
||||
|
||||
// 4) 외부 API 호출 준비
|
||||
val userId = generateUserId(member.id!!)
|
||||
@@ -835,7 +842,7 @@ class ChatRoomService(
|
||||
}
|
||||
}
|
||||
log.error("[chat] 외부 채팅 전송 최종 실패 attempts={}", maxAttempts)
|
||||
throw SodaException("메시지 전송을 실패했습니다.")
|
||||
throw SodaException(messageKey = "chat.message.send_failed")
|
||||
}
|
||||
|
||||
private fun callExternalApiForChatSend(
|
||||
@@ -877,12 +884,12 @@ class ChatRoomService(
|
||||
)
|
||||
|
||||
if (!apiResponse.success) {
|
||||
throw SodaException("메시지 전송을 실패했습니다.")
|
||||
throw SodaException(messageKey = "chat.message.send_failed")
|
||||
}
|
||||
val data = apiResponse.data ?: throw SodaException("메시지 전송을 실패했습니다.")
|
||||
val data = apiResponse.data ?: throw SodaException(messageKey = "chat.message.send_failed")
|
||||
val characterContent = data.characterResponse.content
|
||||
if (characterContent.isBlank()) {
|
||||
throw SodaException("메시지 전송을 실패했습니다.")
|
||||
throw SodaException(messageKey = "chat.message.send_failed")
|
||||
}
|
||||
return characterContent
|
||||
}
|
||||
@@ -905,16 +912,16 @@ class ChatRoomService(
|
||||
fun resetChatRoom(member: Member, chatRoomId: Long, container: String): CreateChatRoomResponse {
|
||||
// 0) 방 존재 및 내 참여 여부 확인
|
||||
val room = chatRoomRepository.findByIdAndIsActiveTrue(chatRoomId)
|
||||
?: throw SodaException("채팅방을 찾을 수 없습니다.")
|
||||
?: throw SodaException(messageKey = "chat.error.room_not_found")
|
||||
participantRepository.findByChatRoomAndMemberAndIsActiveTrue(room, member)
|
||||
?: throw SodaException("잘못된 접근입니다")
|
||||
?: throw SodaException(messageKey = "chat.room.invalid_access")
|
||||
|
||||
// 1) AI 캐릭터 채팅방인지 확인 (CHARACTER 타입의 활성 참여자 존재 확인)
|
||||
val characterParticipant = participantRepository
|
||||
.findByChatRoomAndParticipantTypeAndIsActiveTrue(room, ParticipantType.CHARACTER)
|
||||
?: throw SodaException("AI 캐릭터 채팅방이 아닙니다.")
|
||||
?: throw SodaException(messageKey = "chat.room.not_ai_room")
|
||||
val character = characterParticipant.character
|
||||
?: throw SodaException("AI 캐릭터 채팅방이 아닙니다.")
|
||||
?: throw SodaException(messageKey = "chat.room.not_ai_room")
|
||||
|
||||
// 2) 30캔 결제 (채팅방 초기화 전용 CanUsage 사용)
|
||||
canPaymentService.spendCan(
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package kr.co.vividnext.sodalive.common
|
||||
|
||||
class SodaException(message: String, val errorProperty: String? = null) : RuntimeException(message)
|
||||
class SodaException(
|
||||
message: String? = null,
|
||||
val errorProperty: String? = null,
|
||||
val messageKey: String? = null
|
||||
) : RuntimeException(message)
|
||||
|
||||
class AdsChargeException(message: String) : RuntimeException(message)
|
||||
class AdsChargeException(
|
||||
message: String? = null,
|
||||
val messageKey: String? = null
|
||||
) : RuntimeException(message)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package kr.co.vividnext.sodalive.common
|
||||
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.dao.DataIntegrityViolationException
|
||||
import org.springframework.http.HttpStatus
|
||||
@@ -13,14 +15,20 @@ import org.springframework.web.multipart.MaxUploadSizeExceededException
|
||||
import org.springframework.web.server.ResponseStatusException
|
||||
|
||||
@RestControllerAdvice
|
||||
class SodaExceptionHandler {
|
||||
class SodaExceptionHandler(
|
||||
private val langContext: LangContext,
|
||||
private val messageSource: SodaMessageSource
|
||||
) {
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
@ExceptionHandler(SodaException::class)
|
||||
fun handleSodaException(e: SodaException) = run {
|
||||
logger.error("API error", e)
|
||||
val message = e.messageKey?.takeIf { it.isNotBlank() }?.let { messageSource.getMessage(it, langContext.lang) }
|
||||
?: e.message?.takeIf { it.isNotBlank() }
|
||||
?: messageSource.getMessage("common.error.unknown", langContext.lang)
|
||||
ApiResponse.error(
|
||||
message = e.message,
|
||||
message = message,
|
||||
errorProperty = e.errorProperty
|
||||
)
|
||||
}
|
||||
@@ -28,44 +36,53 @@ class SodaExceptionHandler {
|
||||
@ExceptionHandler(MaxUploadSizeExceededException::class)
|
||||
fun handleMaxUploadSizeExceededException(e: MaxUploadSizeExceededException) = run {
|
||||
logger.error("API error", e)
|
||||
ApiResponse.error(message = "파일용량은 최대 1024MB까지 저장할 수 있습니다.")
|
||||
val message = messageSource.getMessage("common.error.max_upload_size", langContext.lang)
|
||||
ApiResponse.error(message = message)
|
||||
}
|
||||
|
||||
@ExceptionHandler(AccessDeniedException::class)
|
||||
fun handleAccessDeniedException(e: AccessDeniedException) = run {
|
||||
logger.error("API error", e)
|
||||
ApiResponse.error(message = "권한이 없습니다.")
|
||||
val message = messageSource.getMessage("common.error.access_denied", langContext.lang)
|
||||
ApiResponse.error(message = message)
|
||||
}
|
||||
|
||||
@ExceptionHandler(InternalAuthenticationServiceException::class)
|
||||
fun handleInternalAuthenticationServiceException(e: InternalAuthenticationServiceException) = run {
|
||||
logger.error("API error", e)
|
||||
ApiResponse.error("로그인 정보를 확인해주세요.")
|
||||
val message = messageSource.getMessage("common.error.bad_credentials", langContext.lang)
|
||||
ApiResponse.error(message)
|
||||
}
|
||||
|
||||
@ExceptionHandler(BadCredentialsException::class)
|
||||
fun handleBadCredentialsException(e: BadCredentialsException) = run {
|
||||
logger.error("API error", e)
|
||||
ApiResponse.error("로그인 정보를 확인해주세요.")
|
||||
val message = messageSource.getMessage("common.error.bad_credentials", langContext.lang)
|
||||
ApiResponse.error(message)
|
||||
}
|
||||
|
||||
@ExceptionHandler(DataIntegrityViolationException::class)
|
||||
fun handleDataIntegrityViolationException(e: DataIntegrityViolationException) = run {
|
||||
logger.error("API error", e)
|
||||
ApiResponse.error("이미 등록되어 있습니다.")
|
||||
val message = messageSource.getMessage("common.error.already_registered", langContext.lang)
|
||||
ApiResponse.error(message)
|
||||
}
|
||||
|
||||
@ResponseStatus(value = HttpStatus.NOT_FOUND)
|
||||
@ExceptionHandler(AdsChargeException::class)
|
||||
fun handleAdsChargeException(e: AdsChargeException) = run {
|
||||
logger.error("API error - AdsChargeException ::: ", e)
|
||||
ApiResponse.error("잘못된 요청입니다.")
|
||||
val message = e.messageKey?.takeIf { it.isNotBlank() }?.let { messageSource.getMessage(it, langContext.lang) }
|
||||
?: e.message?.takeIf { it.isNotBlank() }
|
||||
?: messageSource.getMessage("common.error.invalid_request", langContext.lang)
|
||||
ApiResponse.error(message)
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception::class)
|
||||
fun handleException(e: Exception) = run {
|
||||
if (e is ResponseStatusException) throw e
|
||||
logger.error("API error", e)
|
||||
ApiResponse.error("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
val message = messageSource.getMessage("common.error.unknown", langContext.lang)
|
||||
ApiResponse.error(message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@RequestPart("request") requestString: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.createAudioContent(
|
||||
@@ -57,7 +57,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@RequestPart("request") requestString: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.modifyAudioContent(
|
||||
@@ -74,7 +74,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@RequestBody request: UploadCompleteRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.uploadComplete(
|
||||
@@ -91,7 +91,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.deleteAudioContent(
|
||||
@@ -111,7 +111,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getAudioContentList(
|
||||
@@ -134,7 +134,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getDetail(
|
||||
@@ -151,7 +151,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
ApiResponse.ok(service.generateUrl(contentId = id, member = member))
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@RequestBody request: AddAllPlaybackTrackingRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.addAllPlaybackTracking(request, member))
|
||||
}
|
||||
@@ -170,7 +170,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@RequestBody request: PutAudioContentLikeRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.audioContentLike(request, member))
|
||||
}
|
||||
@@ -179,7 +179,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
fun getAudioContentRankingSort(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.getContentRankingSortTypeList())
|
||||
}
|
||||
@@ -221,7 +221,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.pinToTheTop(contentId = id, member = member))
|
||||
}
|
||||
@@ -232,7 +232,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.unpinAtTheTop(contentId = id, member = member))
|
||||
}
|
||||
@@ -248,7 +248,7 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getLatestContentByTheme(
|
||||
|
||||
@@ -31,6 +31,7 @@ import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEvent
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.i18n.translation.LanguageTranslationEvent
|
||||
import kr.co.vividnext.sodalive.i18n.translation.LanguageTranslationTargetType
|
||||
import kr.co.vividnext.sodalive.i18n.translation.PapagoTranslationService
|
||||
@@ -74,6 +75,7 @@ class AudioContentService(
|
||||
private val audioContentCloudFront: AudioContentCloudFront,
|
||||
private val applicationEventPublisher: ApplicationEventPublisher,
|
||||
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext,
|
||||
|
||||
private val contentThemeTranslationRepository: ContentThemeTranslationRepository,
|
||||
@@ -117,7 +119,7 @@ class AudioContentService(
|
||||
val request = objectMapper.readValue(requestString, ModifyAudioContentRequest::class.java)
|
||||
|
||||
val audioContent = repository.findByIdAndCreatorId(request.contentId, member.id!!)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "content.error.invalid_content_retry")
|
||||
|
||||
if (request.title != null) audioContent.title = request.title
|
||||
if (request.detail != null) audioContent.detail = request.detail
|
||||
@@ -189,7 +191,7 @@ class AudioContentService(
|
||||
@Transactional
|
||||
fun deleteAudioContent(audioContentId: Long, member: Member) {
|
||||
val audioContent = repository.findByIdAndCreatorId(audioContentId, member.id!!)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "content.error.invalid_content_retry")
|
||||
|
||||
audioContent.isActive = false
|
||||
audioContent.releaseDate = null
|
||||
@@ -203,7 +205,7 @@ class AudioContentService(
|
||||
member: Member
|
||||
): CreateAudioContentResponse {
|
||||
// coverImage 체크
|
||||
if (coverImage == null) throw SodaException("커버이미지를 선택해 주세요.")
|
||||
if (coverImage == null) throw SodaException(messageKey = "content.error.cover_image_required")
|
||||
|
||||
// request 내용 파싱
|
||||
val request = objectMapper.readValue(requestString, CreateAudioContentRequest::class.java)
|
||||
@@ -222,18 +224,18 @@ class AudioContentService(
|
||||
|
||||
// contentFile 체크
|
||||
if (contentFile == null) {
|
||||
throw SodaException("콘텐츠를 선택해 주세요.")
|
||||
throw SodaException(messageKey = "content.error.content_required")
|
||||
}
|
||||
|
||||
// 테마 체크
|
||||
val theme = themeQueryRepository.findThemeByIdAndActive(id = request.themeId)
|
||||
?: throw SodaException("잘못된 테마입니다. 다시 선택해 주세요.")
|
||||
?: throw SodaException(messageKey = "content.error.invalid_theme")
|
||||
|
||||
if ((request.themeId == 12L || request.themeId == 13L || request.themeId == 14L) && request.price < 5) {
|
||||
throw SodaException("알람, 모닝콜, 슬립콜 테마의 콘텐츠는 5캔 이상의 유료콘텐츠로 등록이 가능합니다.")
|
||||
throw SodaException(messageKey = "content.error.alarm_theme_price_min")
|
||||
}
|
||||
|
||||
if (request.price in 1..4) throw SodaException("콘텐츠의 최소금액은 5캔 입니다.")
|
||||
if (request.price in 1..4) throw SodaException(messageKey = "content.error.minimum_price")
|
||||
|
||||
val isFullDetailVisible = if (request.price >= 50) {
|
||||
request.isFullDetailVisible
|
||||
@@ -388,34 +390,34 @@ class AudioContentService(
|
||||
if (previewStartTime != null && previewEndTime != null) {
|
||||
val startTimeArray = previewStartTime.split(":")
|
||||
if (startTimeArray.size != 3) {
|
||||
throw SodaException("미리 듣기 시간 형식은 00:30:00 과 같아야 합니다")
|
||||
throw SodaException(messageKey = "content.error.preview_time_format")
|
||||
}
|
||||
|
||||
for (time in startTimeArray) {
|
||||
if (time.length != 2) {
|
||||
throw SodaException("미리 듣기 시간 형식은 00:30:00 과 같아야 합니다")
|
||||
throw SodaException(messageKey = "content.error.preview_time_format")
|
||||
}
|
||||
}
|
||||
|
||||
val endTimeArray = previewEndTime.split(":")
|
||||
if (endTimeArray.size != 3) {
|
||||
throw SodaException("미리 듣기 시간 형식은 00:30:00 과 같아야 합니다")
|
||||
throw SodaException(messageKey = "content.error.preview_time_format")
|
||||
}
|
||||
|
||||
for (time in endTimeArray) {
|
||||
if (time.length != 2) {
|
||||
throw SodaException("미리 듣기 시간 형식은 00:30:00 과 같아야 합니다")
|
||||
throw SodaException(messageKey = "content.error.preview_time_format")
|
||||
}
|
||||
}
|
||||
|
||||
val timeDifference = timeDifference(previewStartTime, previewEndTime)
|
||||
|
||||
if (timeDifference < 15000) {
|
||||
throw SodaException("미리 듣기의 최소 시간은 15초 입니다.")
|
||||
throw SodaException(messageKey = "content.error.preview_time_minimum")
|
||||
}
|
||||
} else {
|
||||
if (previewStartTime != null || previewEndTime != null) {
|
||||
throw SodaException("미리 듣기 시작 시간과 종료 시간 둘 다 입력을 하거나 둘 다 입력 하지 않아야 합니다.")
|
||||
throw SodaException(messageKey = "content.error.preview_time_both_required")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -445,10 +447,10 @@ class AudioContentService(
|
||||
@Transactional
|
||||
fun uploadComplete(contentId: Long, content: String, duration: String) {
|
||||
val keyFileName = content.split("/").last()
|
||||
if (!keyFileName.startsWith(contentId.toString())) throw SodaException("잘못된 요청입니다.")
|
||||
if (!keyFileName.startsWith(contentId.toString())) throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
val audioContent = repository.findByIdOrNull(contentId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
audioContent.content = content
|
||||
audioContent.duration = duration
|
||||
@@ -456,7 +458,7 @@ class AudioContentService(
|
||||
applicationEventPublisher.publishEvent(
|
||||
FcmEvent(
|
||||
type = FcmEventType.INDIVIDUAL,
|
||||
title = "콘텐츠 등록완료",
|
||||
title = formatMessage("content.notification.upload_complete_title"),
|
||||
message = audioContent.title,
|
||||
recipients = listOf(audioContent.member!!.id!!),
|
||||
isAuth = null,
|
||||
@@ -471,7 +473,7 @@ class AudioContentService(
|
||||
FcmEvent(
|
||||
type = FcmEventType.UPLOAD_CONTENT,
|
||||
title = audioContent.member!!.nickname,
|
||||
message = "콘텐츠를 업로드 하였습니다. - ${audioContent.title}",
|
||||
message = formatMessage("content.notification.uploaded_message", audioContent.title),
|
||||
isAuth = audioContent.isAdult,
|
||||
contentId = contentId,
|
||||
creatorId = audioContent.member!!.id,
|
||||
@@ -483,7 +485,7 @@ class AudioContentService(
|
||||
FcmEvent(
|
||||
type = FcmEventType.UPLOAD_CONTENT,
|
||||
title = audioContent.member!!.nickname,
|
||||
message = "콘텐츠를 업로드 하였습니다. - ${audioContent.title}",
|
||||
message = formatMessage("content.notification.uploaded_message", audioContent.title),
|
||||
isAuth = audioContent.isAdult,
|
||||
contentId = contentId,
|
||||
creatorId = audioContent.member!!.id,
|
||||
@@ -505,7 +507,7 @@ class AudioContentService(
|
||||
FcmEvent(
|
||||
type = FcmEventType.UPLOAD_CONTENT,
|
||||
title = audioContent.member!!.nickname,
|
||||
message = "콘텐츠를 업로드 하였습니다. - ${audioContent.title}",
|
||||
message = formatMessage("content.notification.uploaded_message", audioContent.title),
|
||||
isAuth = audioContent.isAdult,
|
||||
contentId = audioContent.id!!,
|
||||
creatorId = audioContent.member!!.id,
|
||||
@@ -517,7 +519,7 @@ class AudioContentService(
|
||||
FcmEvent(
|
||||
type = FcmEventType.UPLOAD_CONTENT,
|
||||
title = audioContent.member!!.nickname,
|
||||
message = "콘텐츠를 업로드 하였습니다. - ${audioContent.title}",
|
||||
message = formatMessage("content.notification.uploaded_message", audioContent.title),
|
||||
isAuth = audioContent.isAdult,
|
||||
contentId = audioContent.id!!,
|
||||
creatorId = audioContent.member!!.id,
|
||||
@@ -538,12 +540,12 @@ class AudioContentService(
|
||||
|
||||
// 오디오 콘텐츠 조회 (content_id, 제목, 내용, 테마, 태그, 19여부, 이미지, 콘텐츠 PATH)
|
||||
val audioContent = repository.findByIdOrNull(id)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "content.error.invalid_content_retry")
|
||||
|
||||
// 크리에이터(유저) 정보
|
||||
val creatorId = audioContent.member!!.id!!
|
||||
val creator = explorerQueryRepository.getMember(creatorId)
|
||||
?: throw SodaException("없는 사용자 입니다.")
|
||||
?: throw SodaException(messageKey = "content.error.user_not_found")
|
||||
|
||||
val creatorFollowing = explorerQueryRepository.getCreatorFollowing(
|
||||
creatorId = creatorId,
|
||||
@@ -557,7 +559,9 @@ class AudioContentService(
|
||||
|
||||
// 차단된 사용자 체크
|
||||
val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = creatorId)
|
||||
if (isBlocked && !isExistsAudioContent) throw SodaException("${creator.nickname}님의 요청으로 콘텐츠 접근이 제한됩니다.")
|
||||
if (isBlocked && !isExistsAudioContent) {
|
||||
throw SodaException(formatMessage("content.error.access_restricted_by_creator", creator.nickname))
|
||||
}
|
||||
|
||||
val orderSequence = if (isExistsAudioContent) {
|
||||
limitedEditionOrderRepository.getOrderSequence(
|
||||
@@ -595,7 +599,7 @@ class AudioContentService(
|
||||
audioContent.releaseDate != null &&
|
||||
audioContent.releaseDate!! < LocalDateTime.now()
|
||||
) {
|
||||
throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||
throw SodaException(messageKey = "content.error.invalid_content_retry")
|
||||
}
|
||||
|
||||
// 댓글
|
||||
@@ -628,11 +632,13 @@ class AudioContentService(
|
||||
audioContent.releaseDate != null &&
|
||||
audioContent.releaseDate!! >= LocalDateTime.now()
|
||||
) {
|
||||
val releaseDatePattern = messageSource.getMessage("content.release_date.format", langContext.lang)
|
||||
?: "yyyy년 MM월 dd일 HH시 mm분 오픈예정"
|
||||
audioContent.releaseDate!!
|
||||
.atZone(ZoneId.of("UTC"))
|
||||
.withZoneSameInstant(ZoneId.of("Asia/Seoul"))
|
||||
.toLocalDateTime()
|
||||
.format(DateTimeFormatter.ofPattern("yyyy년 MM월 dd일 HH시 mm분 오픈예정"))
|
||||
.format(DateTimeFormatter.ofPattern(releaseDatePattern, langContext.lang.locale))
|
||||
} else {
|
||||
null
|
||||
}
|
||||
@@ -1114,8 +1120,13 @@ class AudioContentService(
|
||||
limit: Long,
|
||||
sortType: String = "매출"
|
||||
): GetAudioContentRanking {
|
||||
val startDateFormatter = DateTimeFormatter.ofPattern("yyyy년 MM월 dd일")
|
||||
val endDateFormatter = DateTimeFormatter.ofPattern("MM월 dd일")
|
||||
val normalizedSortType = normalizeRankingSortType(sortType)
|
||||
val startDatePattern = messageSource.getMessage("content.ranking.date.start_format", langContext.lang)
|
||||
?: "yyyy년 MM월 dd일"
|
||||
val endDatePattern = messageSource.getMessage("content.ranking.date.end_format", langContext.lang)
|
||||
?: "MM월 dd일"
|
||||
val startDateFormatter = DateTimeFormatter.ofPattern(startDatePattern, langContext.lang.locale)
|
||||
val endDateFormatter = DateTimeFormatter.ofPattern(endDatePattern, langContext.lang.locale)
|
||||
|
||||
val contentRankingItemList = repository
|
||||
.getAudioContentRanking(
|
||||
@@ -1126,7 +1137,7 @@ class AudioContentService(
|
||||
contentType = contentType,
|
||||
offset = offset,
|
||||
limit = limit,
|
||||
sortType = sortType
|
||||
sortType = normalizedSortType
|
||||
)
|
||||
|
||||
return GetAudioContentRanking(
|
||||
@@ -1137,16 +1148,19 @@ class AudioContentService(
|
||||
}
|
||||
|
||||
fun getContentRankingSortTypeList(): List<String> {
|
||||
return listOf("매출", "댓글", "좋아요")
|
||||
val salesLabel = messageSource.getMessage("content.ranking.sort_type.sales", langContext.lang) ?: "매출"
|
||||
val commentLabel = messageSource.getMessage("content.ranking.sort_type.comment", langContext.lang) ?: "댓글"
|
||||
val likeLabel = messageSource.getMessage("content.ranking.sort_type.like", langContext.lang) ?: "좋아요"
|
||||
return listOf(salesLabel, commentLabel, likeLabel)
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun pinToTheTop(contentId: Long, member: Member) {
|
||||
val audioContent = repository.findByIdAndCreatorId(contentId = contentId, creatorId = member.id!!)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "content.error.invalid_content_retry")
|
||||
|
||||
if (audioContent.releaseDate != null && audioContent.releaseDate!! >= LocalDateTime.now()) {
|
||||
throw SodaException("콘텐츠 오픈 후 채널에 고정이 가능합니다.")
|
||||
throw SodaException(messageKey = "content.error.pin_available_after_open")
|
||||
}
|
||||
|
||||
var pinContent = pinContentRepository.findByContentIdAndMemberId(
|
||||
@@ -1176,14 +1190,14 @@ class AudioContentService(
|
||||
val pinContent = pinContentRepository.findByContentIdAndMemberId(
|
||||
contentId = contentId,
|
||||
memberId = member.id!!
|
||||
) ?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||
) ?: throw SodaException(messageKey = "content.error.invalid_content_retry")
|
||||
|
||||
pinContent.isActive = false
|
||||
}
|
||||
|
||||
fun generateUrl(contentId: Long, member: Member): GenerateUrlResponse {
|
||||
val audioContent = repository.findByIdOrNull(contentId)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "content.error.invalid_content_retry")
|
||||
|
||||
val isExistsAudioContent = orderRepository.isExistOrdered(
|
||||
memberId = member.id!!,
|
||||
@@ -1312,4 +1326,28 @@ class AudioContentService(
|
||||
.distinct()
|
||||
.toList()
|
||||
}
|
||||
|
||||
private fun normalizeRankingSortType(sortType: String?): String {
|
||||
val trimmed = sortType?.trim().orEmpty()
|
||||
val internalTypes = setOf("매출", "댓글", "좋아요", "후원")
|
||||
if (trimmed in internalTypes) return trimmed
|
||||
|
||||
val salesLabel = messageSource.getMessage("content.ranking.sort_type.sales", langContext.lang)
|
||||
val commentLabel = messageSource.getMessage("content.ranking.sort_type.comment", langContext.lang)
|
||||
val likeLabel = messageSource.getMessage("content.ranking.sort_type.like", langContext.lang)
|
||||
val donationLabel = messageSource.getMessage("content.ranking.sort_type.donation", langContext.lang)
|
||||
|
||||
return when (trimmed) {
|
||||
salesLabel -> "매출"
|
||||
commentLabel -> "댓글"
|
||||
likeLabel -> "좋아요"
|
||||
donationLabel -> "후원"
|
||||
else -> "매출"
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatMessage(key: String, vararg args: Any): String {
|
||||
val template = messageSource.getMessage(key, langContext.lang) ?: return ""
|
||||
return String.format(template, *args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CategoryController(private val service: CategoryService) {
|
||||
@RequestBody request: CreateCategoryRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.createCategory(request = request, member = member))
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class CategoryController(private val service: CategoryService) {
|
||||
@RequestBody request: ModifyCategoryRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.modifyCategory(request = request, member = member))
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class CategoryController(private val service: CategoryService) {
|
||||
@RequestBody request: UpdateCategoryOrdersRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.updateCategoryOrders(request = request, member = member))
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class CategoryController(private val service: CategoryService) {
|
||||
@PathVariable("id") categoryId: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.deleteCategory(categoryId = categoryId, member = member))
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class CategoryController(private val service: CategoryService) {
|
||||
@RequestParam creatorId: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.getCategoryList(creatorId = creatorId, memberId = member.id!!))
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class CategoryService(
|
||||
@Transactional
|
||||
fun modifyCategory(request: ModifyCategoryRequest, member: Member) {
|
||||
val category = repository.findByIdAndMemberId(categoryId = request.categoryId, memberId = member.id!!)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (!request.title.isNullOrBlank()) {
|
||||
validateTitle(title = request.title)
|
||||
@@ -108,7 +108,7 @@ class CategoryService(
|
||||
@Transactional
|
||||
fun deleteCategory(categoryId: Long, member: Member) {
|
||||
val category = repository.findByIdAndMemberId(categoryId = categoryId, memberId = member.id!!)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
category.isActive = false
|
||||
|
||||
categoryContentRepository.deleteByCategoryId(categoryId = categoryId)
|
||||
@@ -128,7 +128,7 @@ class CategoryService(
|
||||
@Transactional
|
||||
fun getCategoryList(creatorId: Long, memberId: Long): List<GetCategoryListResponse> {
|
||||
val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = creatorId)
|
||||
if (isBlocked) throw SodaException("잘못된 접근입니다.")
|
||||
if (isBlocked) throw SodaException(messageKey = "category.error.invalid_access")
|
||||
|
||||
// 기본 카테고리 목록 조회 (원본 언어 기준)
|
||||
val baseList = repository.findByCreatorId(creatorId = creatorId)
|
||||
@@ -205,6 +205,6 @@ class CategoryService(
|
||||
}
|
||||
|
||||
private fun validateTitle(title: String) {
|
||||
if (title.length < 2) throw SodaException("카테고리명은 2글자 이상 입력하세요")
|
||||
if (title.length < 2) throw SodaException(messageKey = "category.error.title_min_length")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class AudioContentCommentController(
|
||||
@RequestBody request: RegisterCommentRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
val commentId = service.registerComment(
|
||||
comment = request.comment,
|
||||
@@ -62,7 +62,7 @@ class AudioContentCommentController(
|
||||
@RequestBody request: ModifyCommentRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.modifyComment(request = request, member = member))
|
||||
}
|
||||
@@ -74,7 +74,7 @@ class AudioContentCommentController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getCommentList(
|
||||
@@ -93,7 +93,7 @@ class AudioContentCommentController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
): ApiResponse<GetAudioContentCommentListResponse> {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
return ApiResponse.ok(
|
||||
service.getCommentReplyList(
|
||||
|
||||
@@ -7,6 +7,8 @@ import kr.co.vividnext.sodalive.content.LanguageDetectTargetType
|
||||
import kr.co.vividnext.sodalive.content.order.OrderRepository
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEvent
|
||||
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
@@ -24,6 +26,8 @@ class AudioContentCommentService(
|
||||
private val audioContentRepository: AudioContentRepository,
|
||||
private val applicationEventPublisher: ApplicationEventPublisher,
|
||||
private val orderRepository: OrderRepository,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val cloudFrontHost: String
|
||||
@@ -38,11 +42,13 @@ class AudioContentCommentService(
|
||||
languageCode: String?
|
||||
): Long {
|
||||
val audioContent = audioContentRepository.findByIdOrNull(id = audioContentId)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "content.error.invalid_content_retry")
|
||||
|
||||
val creator = audioContent.member!!
|
||||
val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = creator.id!!)
|
||||
if (isBlocked) throw SodaException("${creator.nickname}님의 요청으로 댓글쓰기가 제한됩니다.")
|
||||
if (isBlocked) {
|
||||
throw SodaException(formatMessage("content.comment.error.blocked_by_creator", creator.nickname))
|
||||
}
|
||||
|
||||
val (isExistsAudioContent, _) = orderRepository.isExistOrderedAndOrderType(
|
||||
memberId = member.id!!,
|
||||
@@ -50,7 +56,7 @@ class AudioContentCommentService(
|
||||
)
|
||||
|
||||
if (isSecret && !isExistsAudioContent) {
|
||||
throw SodaException("콘텐츠 구매 후 비밀댓글을 등록할 수 있습니다.")
|
||||
throw SodaException(messageKey = "content.comment.error.secret_requires_purchase")
|
||||
}
|
||||
|
||||
val audioContentComment = AudioContentComment(comment = comment, languageCode = languageCode, isSecret = isSecret)
|
||||
@@ -78,9 +84,9 @@ class AudioContentCommentService(
|
||||
member.nickname
|
||||
},
|
||||
message = if (parent != null) {
|
||||
"댓글에 답글을 달았습니다.: ${audioContent.title}"
|
||||
formatMessage("content.comment.notification.reply", audioContent.title)
|
||||
} else {
|
||||
"콘텐츠에 댓글을 달았습니다.: ${audioContent.title}"
|
||||
formatMessage("content.comment.notification.new", audioContent.title)
|
||||
},
|
||||
contentId = audioContentId,
|
||||
commentParentId = parentId,
|
||||
@@ -105,7 +111,7 @@ class AudioContentCommentService(
|
||||
@Transactional
|
||||
fun modifyComment(request: ModifyCommentRequest, member: Member) {
|
||||
val audioContentComment = repository.findByIdOrNull(request.commentId)
|
||||
?: throw SodaException("잘못된 접근 입니다.\n확인 후 다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "content.comment.error.invalid_access_retry")
|
||||
|
||||
if (audioContentComment.member!!.id!! == member.id!!) {
|
||||
if (request.comment != null) {
|
||||
@@ -164,4 +170,9 @@ class AudioContentCommentService(
|
||||
|
||||
return GetAudioContentCommentListResponse(totalCount, commentList)
|
||||
}
|
||||
|
||||
private fun formatMessage(key: String, vararg args: Any): String {
|
||||
val template = messageSource.getMessage(key, langContext.lang) ?: return ""
|
||||
return String.format(template, *args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class AudioContentDonationController(private val service: AudioContentDonationSe
|
||||
@RequestBody request: AudioContentDonationRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.donation(request = request, member = member))
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ class AudioContentDonationService(
|
||||
) {
|
||||
@Transactional
|
||||
fun donation(request: AudioContentDonationRequest, member: Member) {
|
||||
if (request.donationCan < 1) throw SodaException("1캔 이상 후원하실 수 있습니다.")
|
||||
if (request.comment.isBlank()) throw SodaException("함께 보낼 메시지를 입력하세요.")
|
||||
if (request.donationCan < 1) throw SodaException(messageKey = "content.donation.error.minimum_can")
|
||||
if (request.comment.isBlank()) throw SodaException(messageKey = "content.donation.error.comment_required")
|
||||
|
||||
val audioContent = queryRepository.findByIdAndActive(request.contentId)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "content.error.invalid_content_retry")
|
||||
|
||||
canPaymentService.spendCan(
|
||||
memberId = member.id!!,
|
||||
|
||||
@@ -22,7 +22,7 @@ class AudioContentMainController(
|
||||
fun newContentUploadCreatorList(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getNewContentUploadCreatorList(
|
||||
@@ -36,7 +36,7 @@ class AudioContentMainController(
|
||||
fun getMainBannerList(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getAudioContentMainBannerList(
|
||||
@@ -50,7 +50,7 @@ class AudioContentMainController(
|
||||
fun getMainOrderList(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
orderService.getAudioContentMainOrderList(
|
||||
@@ -68,7 +68,7 @@ class AudioContentMainController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getNewContentByTheme(
|
||||
@@ -87,7 +87,7 @@ class AudioContentMainController(
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getThemeList(
|
||||
@@ -105,7 +105,7 @@ class AudioContentMainController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getNewContentFor2WeeksByTheme(
|
||||
@@ -125,7 +125,7 @@ class AudioContentMainController(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getAudioContentCurationListWithPaging(
|
||||
|
||||
@@ -19,7 +19,7 @@ class OrderController(private val service: OrderService) {
|
||||
@RequestBody request: OrderRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.order(
|
||||
@@ -36,7 +36,7 @@ class OrderController(private val service: OrderService) {
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getAudioContentOrderList(
|
||||
|
||||
@@ -33,11 +33,11 @@ class OrderService(
|
||||
@Transactional
|
||||
fun order(contentId: Long, orderType: OrderType, container: String, member: Member) {
|
||||
val content = audioContentRepository.findByIdAndActive(contentId)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다\n다시 시도해 주세요.")
|
||||
?: throw SodaException(messageKey = "content.error.invalid_content_retry")
|
||||
validateOrder(memberId = member.id!!, content = content, orderType = orderType)
|
||||
|
||||
val order = if (content.limited != null && content.remaining != null) {
|
||||
if (content.remaining!! <= 0) throw SodaException("해당 콘텐츠가 매진되었습니다.")
|
||||
if (content.remaining!! <= 0) throw SodaException(messageKey = "order.error.content_sold_out")
|
||||
orderLimitedEditionContent(content, member)
|
||||
} else {
|
||||
orderContent(orderType, content, member)
|
||||
@@ -93,16 +93,20 @@ class OrderService(
|
||||
}
|
||||
|
||||
private fun validateOrder(memberId: Long, content: AudioContent, orderType: OrderType) {
|
||||
if (memberId == content.member!!.id!!) throw SodaException("자신이 올린 콘텐츠는 구매할 수 없습니다.")
|
||||
if (memberId == content.member!!.id!!) {
|
||||
throw SodaException(messageKey = "order.error.cannot_purchase_own_content")
|
||||
}
|
||||
|
||||
val existOrdered = repository.isExistOrdered(memberId = memberId, contentId = content.id!!)
|
||||
if (existOrdered) throw SodaException("이미 구매한 콘텐츠 입니다.")
|
||||
if (existOrdered) throw SodaException(messageKey = "order.error.already_purchased")
|
||||
|
||||
val isOnlyRental = content.purchaseOption == PurchaseOption.RENT_ONLY || content.isOnlyRental
|
||||
if (isOnlyRental && orderType == OrderType.KEEP) throw SodaException("대여만 가능한 콘텐츠 입니다.")
|
||||
if (isOnlyRental && orderType == OrderType.KEEP) {
|
||||
throw SodaException(messageKey = "order.error.rental_only")
|
||||
}
|
||||
|
||||
val isOnlyBuy = content.purchaseOption == PurchaseOption.BUY_ONLY && orderType == OrderType.RENTAL
|
||||
if (isOnlyBuy) throw SodaException("소장만 가능한 콘텐츠 입니다.\n앱 업데이트 후 구매해 주세요.")
|
||||
if (isOnlyBuy) throw SodaException(messageKey = "order.error.keep_only_update_required")
|
||||
}
|
||||
|
||||
fun getAudioContentOrderList(
|
||||
|
||||
@@ -21,7 +21,7 @@ class AudioContentPlaylistController(private val service: AudioContentPlaylistSe
|
||||
@RequestBody request: CreatePlaylistRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.createPlaylist(request, member))
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class AudioContentPlaylistController(private val service: AudioContentPlaylistSe
|
||||
@RequestBody request: UpdatePlaylistRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.updatePlaylist(playlistId = id, request = request, member = member))
|
||||
}
|
||||
@@ -42,7 +42,7 @@ class AudioContentPlaylistController(private val service: AudioContentPlaylistSe
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.deletePlaylist(playlistId = id, member))
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class AudioContentPlaylistController(private val service: AudioContentPlaylistSe
|
||||
fun getPlaylists(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.getPlaylists(member))
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class AudioContentPlaylistController(private val service: AudioContentPlaylistSe
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.getPlaylistDetail(playlistId = id, member = member))
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ class AudioContentPlaylistService(
|
||||
) {
|
||||
fun createPlaylist(request: CreatePlaylistRequest, member: Member) {
|
||||
if (request.contentIdAndOrderList.size >= 30) {
|
||||
throw SodaException("플레이 리스트에는 최대 30개의 콘텐츠를 저장할 수 있습니다.")
|
||||
throw SodaException(messageKey = "playlist.error.max_content_limit")
|
||||
}
|
||||
|
||||
val playlistCount = redisRepository.findByMemberId(member.id!!).size
|
||||
if (playlistCount >= 10) {
|
||||
throw SodaException("플레이 리스트는 최대 10개까지 생성할 수 있습니다.")
|
||||
throw SodaException(messageKey = "playlist.error.max_playlist_limit")
|
||||
}
|
||||
|
||||
val contentIdAndOrderList = validateAndGetContentIdAndOrderList(
|
||||
@@ -68,7 +68,7 @@ class AudioContentPlaylistService(
|
||||
|
||||
private fun validateContent(contentIdList: List<Long>, memberId: Long) {
|
||||
if (contentIdList.isEmpty()) {
|
||||
throw SodaException("콘텐츠를 1개 이상 추가하세요")
|
||||
throw SodaException(messageKey = "playlist.error.content_required")
|
||||
}
|
||||
|
||||
checkOrderedContent(
|
||||
@@ -83,20 +83,20 @@ class AudioContentPlaylistService(
|
||||
val notOrderedContentList = orderedContentMap.filterValues { !it }.keys
|
||||
|
||||
if (notOrderedContentList.isNotEmpty()) {
|
||||
throw SodaException("대여/소장하지 않은 콘텐츠는 재생목록에 추가할 수 없습니다.")
|
||||
throw SodaException(messageKey = "playlist.error.not_purchased_content")
|
||||
}
|
||||
}
|
||||
|
||||
fun updatePlaylist(playlistId: Long, request: UpdatePlaylistRequest, member: Member) {
|
||||
if (request.contentIdAndOrderList.size >= 30) {
|
||||
throw SodaException("플레이 리스트에는 최대 30개의 콘텐츠를 저장할 수 있습니다.")
|
||||
throw SodaException(messageKey = "playlist.error.max_content_limit")
|
||||
}
|
||||
|
||||
val playlist = redisRepository.findByIdOrNull(id = playlistId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (playlist.memberId != member.id) {
|
||||
throw SodaException("잘못된 요청입니다.")
|
||||
throw SodaException(messageKey = "common.error.invalid_request")
|
||||
}
|
||||
|
||||
val contentIdAndOrderList = validateAndGetContentIdAndOrderList(
|
||||
@@ -145,10 +145,10 @@ class AudioContentPlaylistService(
|
||||
|
||||
fun deletePlaylist(playlistId: Long, member: Member) {
|
||||
val playlist = redisRepository.findByIdOrNull(id = playlistId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (playlist.memberId != member.id) {
|
||||
throw SodaException("잘못된 요청입니다.")
|
||||
throw SodaException(messageKey = "common.error.invalid_request")
|
||||
}
|
||||
|
||||
redisRepository.delete(playlist)
|
||||
@@ -156,10 +156,10 @@ class AudioContentPlaylistService(
|
||||
|
||||
fun getPlaylistDetail(playlistId: Long, member: Member): GetPlaylistDetailResponse {
|
||||
val playlist = redisRepository.findByIdOrNull(id = playlistId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (playlist.memberId != member.id) {
|
||||
throw SodaException("잘못된 요청입니다.")
|
||||
throw SodaException(messageKey = "common.error.invalid_request")
|
||||
}
|
||||
|
||||
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy.MM.dd")
|
||||
|
||||
@@ -26,7 +26,7 @@ class ContentSeriesController(private val service: ContentSeriesService) {
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getSeriesList(
|
||||
@@ -49,7 +49,7 @@ class ContentSeriesController(private val service: ContentSeriesService) {
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getSeriesDetail(
|
||||
@@ -70,7 +70,7 @@ class ContentSeriesController(private val service: ContentSeriesService) {
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getSeriesContentList(
|
||||
@@ -91,7 +91,7 @@ class ContentSeriesController(private val service: ContentSeriesService) {
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getRecommendSeriesList(
|
||||
|
||||
@@ -210,11 +210,11 @@ class ContentSeriesService(
|
||||
seriesId = seriesId,
|
||||
isAuth = member.auth != null && isAdultContentVisible,
|
||||
contentType = contentType
|
||||
) ?: throw SodaException("잘못된 시리즈 입니다.\n다시 시도해 주세요")
|
||||
) ?: throw SodaException(messageKey = "series.error.invalid_series_retry")
|
||||
|
||||
val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = series.member!!.id!!)
|
||||
if (isBlocked) {
|
||||
throw SodaException("잘못된 시리즈 입니다.\n다시 시도해 주세요")
|
||||
throw SodaException(messageKey = "series.error.invalid_series_retry")
|
||||
}
|
||||
|
||||
val creatorFollowing = explorerQueryRepository.getCreatorFollowing(
|
||||
|
||||
@@ -31,7 +31,7 @@ class SeriesMainController(
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
val banners = bannerService.getActiveBanners(PageRequest.of(0, 10))
|
||||
.content
|
||||
@@ -70,7 +70,7 @@ class SeriesMainController(
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
contentSeriesService.getRecommendSeriesList(
|
||||
@@ -90,7 +90,7 @@ class SeriesMainController(
|
||||
@RequestParam(defaultValue = "20") size: Int,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
val pageable = PageRequest.of(page, size)
|
||||
|
||||
ApiResponse.ok(
|
||||
@@ -111,7 +111,7 @@ class SeriesMainController(
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
val memberId = member.id!!
|
||||
val isAdult = member.auth != null && (isAdultContentVisible ?: true)
|
||||
@@ -134,7 +134,7 @@ class SeriesMainController(
|
||||
@RequestParam(defaultValue = "20") size: Int,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
val pageable = PageRequest.of(page, size)
|
||||
|
||||
ApiResponse.ok(
|
||||
|
||||
@@ -18,13 +18,13 @@ class ContentSeriesBannerService(
|
||||
|
||||
fun getBannerById(bannerId: Long): SeriesBanner {
|
||||
return bannerRepository.findById(bannerId)
|
||||
.orElseThrow { SodaException("배너를 찾을 수 없습니다: $bannerId") }
|
||||
.orElseThrow { SodaException(messageKey = "series.banner.error.not_found") }
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun registerBanner(seriesId: Long, imagePath: String): SeriesBanner {
|
||||
val series = seriesRepository.findByIdAndActiveTrue(seriesId)
|
||||
?: throw SodaException("시리즈를 찾을 수 없습니다: $seriesId")
|
||||
?: throw SodaException(messageKey = "series.banner.error.series_not_found")
|
||||
|
||||
val finalSortOrder = (bannerRepository.findMaxSortOrder() ?: 0) + 1
|
||||
|
||||
@@ -43,14 +43,14 @@ class ContentSeriesBannerService(
|
||||
seriesId: Long? = null
|
||||
): SeriesBanner {
|
||||
val banner = bannerRepository.findById(bannerId)
|
||||
.orElseThrow { SodaException("배너를 찾을 수 없습니다: $bannerId") }
|
||||
if (!banner.isActive) throw SodaException("비활성화된 배너는 수정할 수 없습니다: $bannerId")
|
||||
.orElseThrow { SodaException(messageKey = "series.banner.error.not_found") }
|
||||
if (!banner.isActive) throw SodaException(messageKey = "series.banner.error.inactive_cannot_update")
|
||||
|
||||
if (imagePath != null) banner.imagePath = imagePath
|
||||
|
||||
if (seriesId != null) {
|
||||
val series = seriesRepository.findByIdAndActiveTrue(seriesId)
|
||||
?: throw SodaException("시리즈를 찾을 수 없습니다: $seriesId")
|
||||
?: throw SodaException(messageKey = "series.banner.error.series_not_found")
|
||||
banner.series = series
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class ContentSeriesBannerService(
|
||||
@Transactional
|
||||
fun deleteBanner(bannerId: Long) {
|
||||
val banner = bannerRepository.findById(bannerId)
|
||||
.orElseThrow { SodaException("배너를 찾을 수 없습니다: $bannerId") }
|
||||
.orElseThrow { SodaException(messageKey = "series.banner.error.not_found") }
|
||||
banner.isActive = false
|
||||
bannerRepository.save(banner)
|
||||
}
|
||||
@@ -70,8 +70,8 @@ class ContentSeriesBannerService(
|
||||
val updated = mutableListOf<SeriesBanner>()
|
||||
for (index in ids.indices) {
|
||||
val banner = bannerRepository.findById(ids[index])
|
||||
.orElseThrow { SodaException("배너를 찾을 수 없습니다: ${ids[index]}") }
|
||||
if (!banner.isActive) throw SodaException("비활성화된 배너는 수정할 수 없습니다: ${ids[index]}")
|
||||
.orElseThrow { SodaException(messageKey = "series.banner.error.not_found") }
|
||||
if (!banner.isActive) throw SodaException(messageKey = "series.banner.error.inactive_cannot_update")
|
||||
banner.sortOrder = index + 1
|
||||
updated.add(bannerRepository.save(banner))
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class AudioContentThemeController(private val service: AudioContentThemeService)
|
||||
fun getThemes(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.getThemes())
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class AudioContentThemeController(private val service: AudioContentThemeService)
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getActiveThemeOfContent(
|
||||
@@ -56,7 +56,7 @@ class AudioContentThemeController(private val service: AudioContentThemeService)
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getContentByTheme(
|
||||
|
||||
@@ -119,7 +119,7 @@ class AudioContentThemeService(
|
||||
limit: Long
|
||||
): GetContentByThemeResponse {
|
||||
val theme = queryRepository.findThemeByIdAndActive(themeId)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
val totalCount = contentRepository.totalCountByTheme(
|
||||
memberId = member.id!!,
|
||||
|
||||
@@ -21,7 +21,7 @@ class CreatorAdminCalculateController(private val service: CreatorAdminCalculate
|
||||
@RequestParam endDateStr: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
ApiResponse.ok(service.getCalculateLive(startDateStr, endDateStr, member))
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class CreatorAdminCalculateController(private val service: CreatorAdminCalculate
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
ApiResponse.ok(
|
||||
service.getCalculateContentList(
|
||||
startDateStr,
|
||||
@@ -49,7 +49,7 @@ class CreatorAdminCalculateController(private val service: CreatorAdminCalculate
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.getCumulativeSalesByContent(member.id!!, pageable.offset, pageable.pageSize.toLong()))
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class CreatorAdminCalculateController(private val service: CreatorAdminCalculate
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
ApiResponse.ok(
|
||||
service.getCalculateContentDonationList(
|
||||
startDateStr,
|
||||
@@ -80,7 +80,7 @@ class CreatorAdminCalculateController(private val service: CreatorAdminCalculate
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getCalculateCommunityPost(
|
||||
|
||||
@@ -23,7 +23,7 @@ class CreatorAdminContentController(private val service: CreatorAdminContentServ
|
||||
pageable: Pageable,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.getAudioContentList(pageable, member))
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class CreatorAdminContentController(private val service: CreatorAdminContentServ
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.searchAudioContent(searchWord, member, pageable))
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class CreatorAdminContentController(private val service: CreatorAdminContentServ
|
||||
@RequestPart("request") requestString: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.updateAudioContent(coverImage, requestString, member))
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class CreatorAdminContentService(
|
||||
}
|
||||
|
||||
fun searchAudioContent(searchWord: String, member: Member, pageable: Pageable): GetCreatorAdminContentListResponse {
|
||||
if (searchWord.length < 2) throw SodaException("2글자 이상 입력하세요.")
|
||||
if (searchWord.length < 2) throw SodaException(messageKey = "creator.admin.content.search_word_min_length")
|
||||
val totalCount = repository.getAudioContentTotalCount(
|
||||
memberId = member.id!!,
|
||||
searchWord
|
||||
@@ -113,7 +113,7 @@ class CreatorAdminContentService(
|
||||
fun updateAudioContent(coverImage: MultipartFile?, requestString: String, member: Member) {
|
||||
val request = objectMapper.readValue(requestString, UpdateCreatorAdminContentRequest::class.java)
|
||||
val audioContent = repository.getAudioContent(memberId = member.id!!, audioContentId = request.id)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다.")
|
||||
?: throw SodaException(messageKey = "creator.admin.content.invalid_content")
|
||||
|
||||
if (coverImage != null) {
|
||||
val metadata = ObjectMetadata()
|
||||
@@ -157,7 +157,7 @@ class CreatorAdminContentService(
|
||||
}
|
||||
|
||||
if (request.price != null) {
|
||||
if (request.price < 5) throw SodaException("콘텐츠의 최소금액은 5캔 입니다.")
|
||||
if (request.price < 5) throw SodaException(messageKey = "creator.admin.content.min_price")
|
||||
|
||||
val contentPriceChangeLog = ContentPriceChangeLog(prevPrice = audioContent.price)
|
||||
contentPriceChangeLog.audioContent = audioContent
|
||||
|
||||
@@ -21,7 +21,7 @@ class CreatorAdminCategoryController(private val service: CreatorAdminCategorySe
|
||||
@RequestParam(value = "search_word") searchWord: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.searchContentNotInCategory(
|
||||
@@ -38,7 +38,7 @@ class CreatorAdminCategoryController(private val service: CreatorAdminCategorySe
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getContentInCategory(
|
||||
|
||||
@@ -26,13 +26,13 @@ data class CreateSeriesRequest(
|
||||
}
|
||||
|
||||
private fun validate() {
|
||||
if (title.isBlank()) throw SodaException("시리즈 제목을 입력하세요")
|
||||
if (introduction.isBlank()) throw SodaException("시리즈 소개를 입력하세요")
|
||||
if (keyword.isBlank()) throw SodaException("시리즈를 설명할 수 있는 키워드를 입력하세요")
|
||||
if (genreId <= 0) throw SodaException("올바른 장르를 선택하세요")
|
||||
if (publishedDaysOfWeek.isEmpty()) throw SodaException("시리즈 연재요일을 선택하세요")
|
||||
if (title.isBlank()) throw SodaException(messageKey = "creator.admin.series.title_required")
|
||||
if (introduction.isBlank()) throw SodaException(messageKey = "creator.admin.series.introduction_required")
|
||||
if (keyword.isBlank()) throw SodaException(messageKey = "creator.admin.series.keyword_required")
|
||||
if (genreId <= 0) throw SodaException(messageKey = "creator.admin.series.genre_required")
|
||||
if (publishedDaysOfWeek.isEmpty()) throw SodaException(messageKey = "creator.admin.series.published_days_required")
|
||||
if (publishedDaysOfWeek.contains(SeriesPublishedDaysOfWeek.RANDOM) && publishedDaysOfWeek.size > 1) {
|
||||
throw SodaException("랜덤과 연재요일 동시에 선택할 수 없습니다.")
|
||||
throw SodaException(messageKey = "creator.admin.series.published_days_random_exclusive")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.creator.admin.content.series.content.AddingContentToTheSeriesRequest
|
||||
import kr.co.vividnext.sodalive.creator.admin.content.series.content.RemoveContentToTheSeriesRequest
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.lang.Nullable
|
||||
@@ -23,16 +25,23 @@ import org.springframework.web.multipart.MultipartFile
|
||||
@RestController
|
||||
@PreAuthorize("hasRole('CREATOR')")
|
||||
@RequestMapping("/creator-admin/audio-content/series")
|
||||
class CreatorAdminContentSeriesController(private val service: CreatorAdminContentSeriesService) {
|
||||
class CreatorAdminContentSeriesController(
|
||||
private val service: CreatorAdminContentSeriesService,
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val langContext: LangContext
|
||||
) {
|
||||
@PostMapping
|
||||
fun createSeries(
|
||||
@RequestPart("image") image: MultipartFile?,
|
||||
@RequestPart("request") requestString: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.createSeries(image, requestString, member), "시리즈가 생성되었습니다.")
|
||||
ApiResponse.ok(
|
||||
service.createSeries(image, requestString, member),
|
||||
messageSource.getMessage("creator.admin.series.created", langContext.lang)
|
||||
)
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@@ -43,9 +52,12 @@ class CreatorAdminContentSeriesController(private val service: CreatorAdminConte
|
||||
@RequestPart("request") requestString: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.modifySeries(image, requestString, member), "시리즈가 수정되었습니다.")
|
||||
ApiResponse.ok(
|
||||
service.modifySeries(image, requestString, member),
|
||||
messageSource.getMessage("creator.admin.series.updated", langContext.lang)
|
||||
)
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@@ -53,7 +65,7 @@ class CreatorAdminContentSeriesController(private val service: CreatorAdminConte
|
||||
pageable: Pageable,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getSeriesList(
|
||||
@@ -69,7 +81,7 @@ class CreatorAdminContentSeriesController(private val service: CreatorAdminConte
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.getDetail(id = id, memberId = member.id!!))
|
||||
}
|
||||
@@ -80,7 +92,7 @@ class CreatorAdminContentSeriesController(private val service: CreatorAdminConte
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getSeriesContent(
|
||||
@@ -97,11 +109,11 @@ class CreatorAdminContentSeriesController(private val service: CreatorAdminConte
|
||||
@RequestBody request: AddingContentToTheSeriesRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.addingContentToTheSeries(request, memberId = member.id!!),
|
||||
"콘텐츠가 추가되었습니다."
|
||||
messageSource.getMessage("creator.admin.series.content_added", langContext.lang)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -110,11 +122,11 @@ class CreatorAdminContentSeriesController(private val service: CreatorAdminConte
|
||||
@RequestBody request: RemoveContentToTheSeriesRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.removeContentInTheSeries(request, memberId = member.id!!),
|
||||
"콘텐츠를 삭제하였습니다."
|
||||
messageSource.getMessage("creator.admin.series.content_removed", langContext.lang)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -124,7 +136,7 @@ class CreatorAdminContentSeriesController(private val service: CreatorAdminConte
|
||||
@RequestParam(value = "search_word") searchWord: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.searchContentNotInSeries(
|
||||
@@ -138,5 +150,8 @@ class CreatorAdminContentSeriesController(private val service: CreatorAdminConte
|
||||
@PutMapping("/orders")
|
||||
fun updateSeriesOrders(
|
||||
@RequestBody request: UpdateOrdersRequest
|
||||
) = ApiResponse.ok(service.updateSeriesOrders(ids = request.ids), "수정되었습니다.")
|
||||
) = ApiResponse.ok(
|
||||
service.updateSeriesOrders(ids = request.ids),
|
||||
messageSource.getMessage("creator.admin.series.orders_updated", langContext.lang)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class CreatorAdminContentSeriesService(
|
||||
) {
|
||||
@Transactional
|
||||
fun createSeries(coverImage: MultipartFile?, requestString: String, member: Member) {
|
||||
if (coverImage == null) throw SodaException("커버이미지를 선택해 주세요.")
|
||||
if (coverImage == null) throw SodaException(messageKey = "creator.admin.series.cover_image_required")
|
||||
|
||||
val request = objectMapper.readValue(requestString, CreateSeriesRequest::class.java)
|
||||
val series = request.toSeries()
|
||||
@@ -139,11 +139,11 @@ class CreatorAdminContentSeriesService(
|
||||
request.studio == null &&
|
||||
request.isActive == null
|
||||
) {
|
||||
throw SodaException("변경사항이 없습니다.")
|
||||
throw SodaException(messageKey = "creator.admin.series.no_changes")
|
||||
}
|
||||
|
||||
val series = repository.findByIdAndCreatorId(id = request.seriesId, creatorId = member.id!!)
|
||||
?: throw SodaException("잘못된 접근입니다.")
|
||||
?: throw SodaException(messageKey = "creator.admin.series.invalid_access")
|
||||
|
||||
if (coverImage != null) {
|
||||
val metadata = ObjectMetadata()
|
||||
@@ -175,7 +175,7 @@ class CreatorAdminContentSeriesService(
|
||||
request.publishedDaysOfWeek.contains(SeriesPublishedDaysOfWeek.RANDOM) &&
|
||||
request.publishedDaysOfWeek.size > 1
|
||||
) {
|
||||
throw SodaException("랜덤과 연재요일 동시에 선택할 수 없습니다.")
|
||||
throw SodaException(messageKey = "creator.admin.series.published_days_random_exclusive")
|
||||
}
|
||||
|
||||
series.publishedDaysOfWeek.clear()
|
||||
@@ -245,7 +245,7 @@ class CreatorAdminContentSeriesService(
|
||||
|
||||
fun getDetail(id: Long, memberId: Long): GetCreatorAdminContentSeriesDetailResponse {
|
||||
val series = repository.findByIdAndCreatorId(id = id, creatorId = memberId)
|
||||
?: throw SodaException("잘못된 접근입니다.")
|
||||
?: throw SodaException(messageKey = "creator.admin.series.invalid_access")
|
||||
|
||||
return series.toDetailResponse(imageHost = coverImageHost)
|
||||
}
|
||||
@@ -271,7 +271,7 @@ class CreatorAdminContentSeriesService(
|
||||
@Transactional
|
||||
fun addingContentToTheSeries(request: AddingContentToTheSeriesRequest, memberId: Long) {
|
||||
val series = repository.findByIdAndCreatorId(id = request.seriesId, creatorId = memberId)
|
||||
?: throw SodaException("잘못된 접근입니다.")
|
||||
?: throw SodaException(messageKey = "creator.admin.series.invalid_access")
|
||||
|
||||
val seriesContentList = mutableListOf<SeriesContent>()
|
||||
|
||||
@@ -288,14 +288,14 @@ class CreatorAdminContentSeriesService(
|
||||
if (seriesContentList.size > 0) {
|
||||
series.contentList.addAll(seriesContentList.toSet())
|
||||
} else {
|
||||
throw SodaException("추가된 콘텐츠가 없습니다.")
|
||||
throw SodaException(messageKey = "creator.admin.series.no_content_added")
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun removeContentInTheSeries(request: RemoveContentToTheSeriesRequest, memberId: Long) {
|
||||
val series = repository.findByIdAndCreatorId(id = request.seriesId, creatorId = memberId)
|
||||
?: throw SodaException("잘못된 접근입니다.")
|
||||
?: throw SodaException(messageKey = "creator.admin.series.invalid_access")
|
||||
|
||||
series.contentList.removeIf { it.content!!.id == request.contentId }
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreatorAdminContentSeriesGenreController(private val service: CreatorAdmin
|
||||
fun getGenreList(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.getGenreList(isAdult = member.auth != null))
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CreatorAdminMemberController(private val service: CreatorAdminMemberServic
|
||||
@RequestHeader("Authorization") token: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
|
||||
ApiResponse.ok(service.logout(token.removePrefix("Bearer "), member.id!!))
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user