오디션 배역 등 메시지 다국어 처리

This commit is contained in:
2025-12-22 21:49:07 +09:00
parent 8785741855
commit 14d0ae9851
6 changed files with 97 additions and 21 deletions

View File

@@ -31,7 +31,7 @@ class AdminAuditionRoleService(
auditionScriptUrl = request.auditionScriptUrl auditionScriptUrl = request.auditionScriptUrl
) )
val audition = auditionRepository.findByIdOrNull(id = request.auditionId) val audition = auditionRepository.findByIdOrNull(id = request.auditionId)
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.") ?: throw SodaException(messageKey = "admin.audition.invalid_request_retry")
auditionRole.audition = audition auditionRole.audition = audition
repository.save(auditionRole) repository.save(auditionRole)
@@ -48,15 +48,19 @@ class AdminAuditionRoleService(
fun updateAuditionRole(image: MultipartFile?, requestString: String) { fun updateAuditionRole(image: MultipartFile?, requestString: String) {
val request = objectMapper.readValue(requestString, UpdateAuditionRoleRequest::class.java) val request = objectMapper.readValue(requestString, UpdateAuditionRoleRequest::class.java)
val auditionRole = repository.findByIdOrNull(id = request.id) 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.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 auditionRole.name = request.name
} }
if (!request.information.isNullOrBlank()) { 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 auditionRole.information = request.information
} }

View File

@@ -10,19 +10,19 @@ data class CreateAuditionRoleRequest(
) { ) {
init { init {
if (auditionId < 0) { if (auditionId < 0) {
throw SodaException("캐릭터가 등록될 오디션을 선택하세요") throw SodaException(messageKey = "admin.audition.role.audition_required")
} }
if (name.isBlank() || name.length < 2) { if (name.isBlank() || name.length < 2) {
throw SodaException("캐릭터명을 입력하세요") throw SodaException(messageKey = "admin.audition.role.name_required")
} }
if (auditionScriptUrl.isBlank() || auditionScriptUrl.length < 10) { if (auditionScriptUrl.isBlank() || auditionScriptUrl.length < 10) {
throw SodaException("오디션 대본 URL을 입력하세요") throw SodaException(messageKey = "admin.audition.role.script_url_required")
} }
if (information.isBlank() || information.length < 10) { if (information.isBlank() || information.length < 10) {
throw SodaException("오디션 캐릭터 정보는 최소 10글자 입니다") throw SodaException(messageKey = "admin.audition.role.information_required")
} }
} }
} }

View File

@@ -13,7 +13,7 @@ data class UpdateAuditionRoleRequest(
) { ) {
init { init {
if (id < 0) { if (id < 0) {
throw SodaException("잘못된 요청입니다.") throw SodaException(messageKey = "common.error.invalid_request")
} }
} }
} }

View File

@@ -15,10 +15,10 @@ class CreatorSettlementRatioService(
@Transactional @Transactional
fun createCreatorSettlementRatio(request: CreateCreatorSettlementRatioRequest) { fun createCreatorSettlementRatio(request: CreateCreatorSettlementRatioRequest) {
val creator = memberRepository.findByIdOrNull(request.memberId) val creator = memberRepository.findByIdOrNull(request.memberId)
?: throw SodaException("잘못된 크리에이터 입니다.") ?: throw SodaException(messageKey = "admin.settlement_ratio.invalid_creator")
if (creator.role != MemberRole.CREATOR) { if (creator.role != MemberRole.CREATOR) {
throw SodaException("잘못된 크리에이터 입니다.") throw SodaException(messageKey = "admin.settlement_ratio.invalid_creator")
} }
val existing = repository.findByMemberId(request.memberId) val existing = repository.findByMemberId(request.memberId)
@@ -43,12 +43,12 @@ class CreatorSettlementRatioService(
@Transactional @Transactional
fun updateCreatorSettlementRatio(request: CreateCreatorSettlementRatioRequest) { fun updateCreatorSettlementRatio(request: CreateCreatorSettlementRatioRequest) {
val creator = memberRepository.findByIdOrNull(request.memberId) val creator = memberRepository.findByIdOrNull(request.memberId)
?: throw SodaException("잘못된 크리에이터 입니다.") ?: throw SodaException(messageKey = "admin.settlement_ratio.invalid_creator")
if (creator.role != MemberRole.CREATOR) { if (creator.role != MemberRole.CREATOR) {
throw SodaException("잘못된 크리에이터 입니다.") throw SodaException(messageKey = "admin.settlement_ratio.invalid_creator")
} }
val existing = repository.findByMemberId(request.memberId) val existing = repository.findByMemberId(request.memberId)
?: throw SodaException("해당 크리에이터의 정산 비율 설정이 없습니다.") ?: throw SodaException(messageKey = "admin.settlement_ratio.not_found")
existing.restore() existing.restore()
existing.updateValues( existing.updateValues(
request.subsidy, request.subsidy,
@@ -62,7 +62,7 @@ class CreatorSettlementRatioService(
@Transactional @Transactional
fun deleteCreatorSettlementRatio(memberId: Long) { fun deleteCreatorSettlementRatio(memberId: Long) {
val existing = repository.findByMemberId(memberId) val existing = repository.findByMemberId(memberId)
?: throw SodaException("해당 크리에이터의 정산 비율 설정이 없습니다.") ?: throw SodaException(messageKey = "admin.settlement_ratio.not_found")
existing.softDelete() existing.softDelete()
repository.save(existing) repository.save(existing)
} }

View File

@@ -33,21 +33,21 @@ class AdminCanService(
@Transactional @Transactional
fun deleteCan(id: Long) { fun deleteCan(id: Long) {
val can = repository.findByIdOrNull(id) val can = repository.findByIdOrNull(id)
?: throw SodaException("잘못된 요청입니다.") ?: throw SodaException(messageKey = "common.error.invalid_request")
can.status = CanStatus.END_OF_SALE can.status = CanStatus.END_OF_SALE
} }
@Transactional @Transactional
fun charge(request: AdminCanChargeRequest) { fun charge(request: AdminCanChargeRequest) {
if (request.can <= 0) throw SodaException("1 캔 이상 입력하세요.") if (request.can <= 0) throw SodaException(messageKey = "admin.can.min_amount")
if (request.method.isBlank()) throw SodaException("기록내용을 입력하세요.") if (request.method.isBlank()) throw SodaException(messageKey = "admin.can.method_required")
val ids = request.memberIds.distinct() 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() 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 -> members.forEach { member ->
val charge = Charge(0, request.can, status = ChargeStatus.ADMIN) val charge = Charge(0, request.can, status = ChargeStatus.ADMIN)

View File

@@ -81,12 +81,84 @@ class SodaMessageSource {
) )
) )
private val auditionRoleMessages = mapOf(
"admin.audition.role.name_min_length" to mapOf(
Lang.KO to "배역 이름은 최소 2글자 입니다",
Lang.EN to "Role name must be at least 2 characters.",
Lang.JA to "役名は最低2文字です。"
),
"admin.audition.role.information_min_length" to mapOf(
Lang.KO to "오디션 배역 정보는 최소 10글자 입니다",
Lang.EN to "Audition role information must be at least 10 characters.",
Lang.JA to "オーディション役の情報は最低10文字です。"
),
"admin.audition.role.audition_required" to mapOf(
Lang.KO to "캐릭터가 등록될 오디션을 선택하세요",
Lang.EN to "Please select an audition for the character.",
Lang.JA to "キャラクターが登録されるオーディションを選択してください。"
),
"admin.audition.role.name_required" to mapOf(
Lang.KO to "캐릭터명을 입력하세요",
Lang.EN to "Please enter a character name.",
Lang.JA to "キャラクター名を入力してください。"
),
"admin.audition.role.script_url_required" to mapOf(
Lang.KO to "오디션 대본 URL을 입력하세요",
Lang.EN to "Please enter the audition script URL.",
Lang.JA to "オーディション台本のURLを入力してください。"
),
"admin.audition.role.information_required" to mapOf(
Lang.KO to "오디션 캐릭터 정보는 최소 10글자 입니다",
Lang.EN to "Audition character information must be at least 10 characters.",
Lang.JA to "オーディションキャラクター情報は最低10文字です。"
)
)
private val settlementRatioMessages = mapOf(
"admin.settlement_ratio.invalid_creator" to mapOf(
Lang.KO to "잘못된 크리에이터 입니다.",
Lang.EN to "Invalid creator.",
Lang.JA to "不正なクリエイターです。"
),
"admin.settlement_ratio.not_found" to mapOf(
Lang.KO to "해당 크리에이터의 정산 비율 설정이 없습니다.",
Lang.EN to "Settlement ratio settings not found for this creator.",
Lang.JA to "該当クリエイターの精算比率設定がありません。"
)
)
private val adminCanMessages = mapOf(
"admin.can.min_amount" to mapOf(
Lang.KO to "1 캔 이상 입력하세요.",
Lang.EN to "Please enter at least 1 can.",
Lang.JA to "1缶以上入力してください。"
),
"admin.can.method_required" to mapOf(
Lang.KO to "기록내용을 입력하세요.",
Lang.EN to "Please enter the record content.",
Lang.JA to "記録内容を入力してください。"
),
"admin.can.member_ids_required" to mapOf(
Lang.KO to "회원번호를 입력하세요.",
Lang.EN to "Please enter member IDs.",
Lang.JA to "会員番号を入力してください。"
),
"admin.can.invalid_member_ids" to mapOf(
Lang.KO to "잘못된 회원번호 입니다.",
Lang.EN to "Invalid member IDs.",
Lang.JA to "不正な会員番号です。"
)
)
fun getMessage(key: String, lang: Lang): String? { fun getMessage(key: String, lang: Lang): String? {
val messageGroups = listOf( val messageGroups = listOf(
commonMessages, commonMessages,
auditionMessages, auditionMessages,
auditionRequestMessages, auditionRequestMessages,
auditionNotificationMessages auditionNotificationMessages,
auditionRoleMessages,
settlementRatioMessages,
adminCanMessages
) )
for (messages in messageGroups) { for (messages in messageGroups) {
val translations = messages[key] ?: continue val translations = messages[key] ?: continue