관리자 메시지 다국어 처리
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user