다국어 메시지 분리 적용
This commit is contained in:
@@ -12,12 +12,12 @@ class FaqService(
|
||||
) {
|
||||
@Transactional
|
||||
fun save(request: CreateFaqRequest): Long {
|
||||
if (request.question.isBlank()) throw SodaException("질문을 입력하세요.")
|
||||
if (request.answer.isBlank()) throw SodaException("답변을 입력하세요.")
|
||||
if (request.category.isBlank()) throw SodaException("카테고리를 선택하세요.")
|
||||
if (request.question.isBlank()) throw SodaException(messageKey = "faq.question_required")
|
||||
if (request.answer.isBlank()) throw SodaException(messageKey = "faq.answer_required")
|
||||
if (request.category.isBlank()) throw SodaException(messageKey = "faq.category_required")
|
||||
|
||||
val category = queryRepository.getCategory(request.category)
|
||||
?: throw SodaException("잘못된 카테고리 입니다.")
|
||||
?: throw SodaException(messageKey = "faq.invalid_category")
|
||||
|
||||
val faq = Faq(request.question, request.answer)
|
||||
faq.category = category
|
||||
@@ -28,30 +28,31 @@ class FaqService(
|
||||
@Transactional
|
||||
fun modify(request: ModifyFaqRequest) {
|
||||
val faq = queryRepository.getFaq(request.id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
if (request.question != null) {
|
||||
if (request.question.isBlank()) throw SodaException("질문을 입력하세요.")
|
||||
if (request.question.isBlank()) throw SodaException(messageKey = "faq.question_required")
|
||||
faq.question = request.question
|
||||
}
|
||||
|
||||
if (request.answer != null) {
|
||||
if (request.answer.isBlank()) throw SodaException("답변을 입력하세요.")
|
||||
if (request.answer.isBlank()) throw SodaException(messageKey = "faq.answer_required")
|
||||
faq.answer = request.answer
|
||||
}
|
||||
|
||||
if (request.category != null) {
|
||||
if (request.category.isBlank()) throw SodaException("카테고리를 선택하세요.")
|
||||
val category = queryRepository.getCategory(request.category) ?: throw SodaException("잘못된 카테고리 입니다.")
|
||||
if (request.category.isBlank()) throw SodaException(messageKey = "faq.category_required")
|
||||
val category = queryRepository.getCategory(request.category)
|
||||
?: throw SodaException(messageKey = "faq.invalid_category")
|
||||
faq.category = category
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun delete(id: Long) {
|
||||
if (id <= 0) throw SodaException("잘못된 요청입니다.")
|
||||
if (id <= 0) throw SodaException(messageKey = "common.error.invalid_request")
|
||||
val faq = repository.findByIdOrNull(id)
|
||||
?: throw SodaException("잘못된 요청입니다.")
|
||||
?: throw SodaException(messageKey = "common.error.invalid_request")
|
||||
|
||||
faq.isActive = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user