generated from pricelees/issue-pr-template
refactor: 테마 / 일정 수정 로직 개선( -> null 필드이면 즉시 중단) 및 로그 메시지 형식 개선
This commit is contained in:
parent
5122194fc6
commit
bf8a005096
@ -86,6 +86,12 @@ class ScheduleService(
|
||||
@Transactional
|
||||
fun updateSchedule(id: Long, request: ScheduleUpdateRequest) {
|
||||
log.info { "[ScheduleService.updateSchedule] 일정 수정 시작: id=$id, request=${request}" }
|
||||
|
||||
if (request.isAllParamsNull()) {
|
||||
log.info { "[ScheduleService.updateSchedule] 일정 변경 사항 없음: id=$id" }
|
||||
return
|
||||
}
|
||||
|
||||
val schedule: ScheduleEntity = findOrThrow(id)
|
||||
|
||||
scheduleValidator.validateCanUpdate(schedule, request)
|
||||
|
||||
@ -48,7 +48,7 @@ class ScheduleValidator(
|
||||
private fun validateAlreadyExists(date: LocalDate, themeId: Long, time: LocalTime) {
|
||||
if (scheduleRepository.existsByDateAndThemeIdAndTime(date, themeId, time)) {
|
||||
log.info {
|
||||
"[ScheduleValidator.validateAlreadyExists] 동일한 날짜, 테마, 시간 존재: date=${date} / themeId=${themeId} / time=${time}"
|
||||
"[ScheduleValidator.validateAlreadyExists] 동일한 날짜, 테마, 시간 존재로 인한 실패: date=${date} / themeId=${themeId} / time=${time}"
|
||||
}
|
||||
throw ScheduleException(ScheduleErrorCode.SCHEDULE_ALREADY_EXISTS)
|
||||
}
|
||||
@ -59,7 +59,7 @@ class ScheduleValidator(
|
||||
|
||||
if (dateTime.isBefore(LocalDateTime.now())) {
|
||||
log.info {
|
||||
"[ScheduleValidator.validateDateTime] 이전 시간 선택: date=${date} / time=${time}"
|
||||
"[ScheduleValidator.validateDateTime] 이전 시간 선택으로 인한 실패: date=${date} / time=${time}"
|
||||
}
|
||||
throw ScheduleException(ScheduleErrorCode.PAST_DATE_TIME)
|
||||
}
|
||||
|
||||
@ -39,7 +39,11 @@ data class ScheduleCreateResponse(
|
||||
data class ScheduleUpdateRequest(
|
||||
val time: LocalTime? = null,
|
||||
val status: ScheduleStatus? = null
|
||||
)
|
||||
) {
|
||||
fun isAllParamsNull(): Boolean {
|
||||
return time == null && status == null
|
||||
}
|
||||
}
|
||||
|
||||
data class ScheduleDetailRetrieveResponse(
|
||||
val id: Long,
|
||||
|
||||
@ -94,6 +94,11 @@ class ThemeServiceV2(
|
||||
fun updateTheme(id: Long, request: ThemeUpdateRequest) {
|
||||
log.info { "[ThemeService.updateTheme] 테마 수정 시작: id=${id}, request=${request}" }
|
||||
|
||||
if (request.isAllParamsNull()) {
|
||||
log.info { "[ThemeService.updateTheme] 테마 변경 사항 없음: id=${id}" }
|
||||
return
|
||||
}
|
||||
|
||||
themeValidator.validateCanUpdate(request)
|
||||
|
||||
val theme: ThemeEntityV2 = findOrThrow(id)
|
||||
|
||||
@ -32,7 +32,7 @@ class ThemeValidatorV2(
|
||||
|
||||
fun validateCanCreate(request: ThemeCreateRequestV2) {
|
||||
if (themeRepository.existsByName(request.name)) {
|
||||
log.info { "[ThemeValidator.validateCanCreate] 이름 중복: name=${request.name}" }
|
||||
log.info { "[ThemeValidator.validateCanCreate] 이름 중복으로 인한 실패: name=${request.name}" }
|
||||
throw ThemeException(ThemeErrorCode.THEME_NAME_DUPLICATED)
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ class ThemeValidatorV2(
|
||||
maxParticipants: Short?,
|
||||
) {
|
||||
if (isNotNullAndBelowThan(price, MIN_PRICE)) {
|
||||
log.info { "[ThemeValidator.validateCanCreate] 최소 가격 미달: price=${price}" }
|
||||
log.info { "[ThemeValidator.validateCanCreate] 최소 가격 미달로 인한 실패로 인한 실패: price=${price}" }
|
||||
throw ThemeException(ThemeErrorCode.PRICE_BELOW_MINIMUM)
|
||||
}
|
||||
validateTimes(availableMinutes, expectedMinutesFrom, expectedMinutesTo)
|
||||
@ -72,18 +72,18 @@ class ThemeValidatorV2(
|
||||
|| isNotNullAndBelowThan(expectedMinutesTo, MIN_DURATION)
|
||||
) {
|
||||
log.info {
|
||||
"[ThemeValidator.validateTimes] 최소 시간 미달: availableMinutes=$availableMinutes" +
|
||||
"[ThemeValidator.validateTimes] 최소 시간 미달로 인한 실패로 인한 실패: availableMinutes=$availableMinutes" +
|
||||
", expectedMinutesFrom=$expectedMinutesFrom, expectedMinutesTo=$expectedMinutesTo"
|
||||
}
|
||||
throw ThemeException(ThemeErrorCode.DURATION_BELOW_MINIMUM)
|
||||
}
|
||||
|
||||
if (expectedMinutesFrom.isNotNullAndGraterThan(expectedMinutesTo)) {
|
||||
log.info { "[ThemeValidator.validateTimes] 최소 예상 시간의 최대 예상 시간 초과: expectedMinutesFrom=$expectedMinutesFrom, expectedMinutesTo=$expectedMinutesTo" }
|
||||
log.info { "[ThemeValidator.validateTimes] 최소 예상 시간의 최대 예상 시간 초과로 인한 실패: expectedMinutesFrom=$expectedMinutesFrom, expectedMinutesTo=$expectedMinutesTo" }
|
||||
throw ThemeException(ThemeErrorCode.MIN_EXPECTED_TIME_EXCEEDS_MAX_EXPECTED_TIME)
|
||||
}
|
||||
if (expectedMinutesTo.isNotNullAndGraterThan(availableMinutes)) {
|
||||
log.info { "[ThemeValidator.validateTimes] 예상 시간의 이용 가능 시간 초과: availableMinutes=$expectedMinutesFrom, expectedMinutesFrom=$expectedMinutesFrom, expectedMinutesTo=$expectedMinutesTo" }
|
||||
log.info { "[ThemeValidator.validateTimes] 예상 시간의 이용 가능 시간 초과로 인한 실패: availableMinutes=$expectedMinutesFrom, expectedMinutesFrom=$expectedMinutesFrom, expectedMinutesTo=$expectedMinutesTo" }
|
||||
throw ThemeException(ThemeErrorCode.EXPECTED_TIME_EXCEEDS_AVAILABLE_TIME)
|
||||
}
|
||||
}
|
||||
@ -95,11 +95,11 @@ class ThemeValidatorV2(
|
||||
if (isNotNullAndBelowThan(minParticipants, MIN_PARTICIPANTS)
|
||||
|| isNotNullAndBelowThan(maxParticipants, MIN_PARTICIPANTS)
|
||||
) {
|
||||
log.info { "[ThemeValidator.validateParticipants] 최소 인원 미달: minParticipants=$minParticipants, maxParticipants=$maxParticipants" }
|
||||
log.info { "[ThemeValidator.validateParticipants] 최소 인원 미달로 인한 실패: minParticipants=$minParticipants, maxParticipants=$maxParticipants" }
|
||||
throw ThemeException(ThemeErrorCode.PARTICIPANT_BELOW_MINIMUM)
|
||||
}
|
||||
if (minParticipants.isNotNullAndGraterThan(maxParticipants)) {
|
||||
log.info { "[ThemeValidator.validateParticipants] 최소 인원의 최대 인원 초과: minParticipants=$minParticipants, maxParticipants=$maxParticipants" }
|
||||
log.info { "[ThemeValidator.validateParticipants] 최소 인원의 최대 인원 초과로 인한 실패: minParticipants=$minParticipants, maxParticipants=$maxParticipants" }
|
||||
throw ThemeException(ThemeErrorCode.MIN_PARTICIPANT_EXCEEDS_MAX_PARTICIPANT)
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,21 @@ data class ThemeUpdateRequest(
|
||||
val expectedMinutesFrom: Short? = null,
|
||||
val expectedMinutesTo: Short? = null,
|
||||
val isOpen: Boolean? = null,
|
||||
)
|
||||
) {
|
||||
fun isAllParamsNull(): Boolean {
|
||||
return name == null &&
|
||||
description == null &&
|
||||
thumbnailUrl == null &&
|
||||
difficulty == null &&
|
||||
price == null &&
|
||||
minParticipants == null &&
|
||||
maxParticipants == null &&
|
||||
availableMinutes == null &&
|
||||
expectedMinutesFrom == null &&
|
||||
expectedMinutesTo == null &&
|
||||
isOpen == null
|
||||
}
|
||||
}
|
||||
|
||||
data class AdminThemeSummaryRetrieveResponse(
|
||||
val id: Long,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user