diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCase.kt index a9a66dcd..957ce293 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCase.kt @@ -1,6 +1,6 @@ package team.comit.simtong.domain.auth.usecase -import team.comit.simtong.domain.auth.exception.AuthCodeMismatchException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.auth.model.AuthCodeLimit import team.comit.simtong.domain.auth.spi.CommandAuthCodeLimitPort import team.comit.simtong.domain.auth.spi.QueryAuthCodePort @@ -11,6 +11,7 @@ import team.comit.simtong.global.annotation.UseCase * 이메일 인증 코드 확인을 담당하는 CheckAuthCodeUseCase * * @author Chokyunghyeon + * @author kimbeomjin * @date 2022/09/24 * @version 1.0.0 **/ @@ -21,10 +22,10 @@ class CheckAuthCodeUseCase( ) { fun execute(email: String, code: String) { - val authCode = queryAuthCodePort.queryAuthCodeByEmail(email) + val authCode = queryAuthCodePort.queryAuthCodeByEmail(email) ?: throw AuthExceptions.RequiredNewEmailAuthentication() - if (authCode?.code != code) { - throw AuthCodeMismatchException.EXCEPTION + if (authCode.code != code) { + throw AuthExceptions.DifferentAuthCode() } commandAuthCodeLimitPort.save( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/ReissueTokenUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/ReissueTokenUseCase.kt index 59243690..c66f9c65 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/ReissueTokenUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/ReissueTokenUseCase.kt @@ -1,9 +1,9 @@ package team.comit.simtong.domain.auth.usecase -import team.comit.simtong.domain.auth.exception.RefreshTokenNotFoundException +import team.comit.simtong.domain.auth.dto.TokenResponse +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.auth.spi.JwtPort import team.comit.simtong.domain.auth.spi.QueryRefreshTokenPort -import team.comit.simtong.domain.auth.dto.TokenResponse import team.comit.simtong.global.annotation.UseCase /** @@ -23,7 +23,7 @@ class ReissueTokenUseCase( fun execute(request: String): TokenResponse { val token = queryRefreshTokenPort.queryRefreshTokenByToken(request) - ?: throw RefreshTokenNotFoundException.EXCEPTION + ?: throw AuthExceptions.RefreshTokenNotFound() return jwtPort.receiveToken( userId = token.userId, diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCase.kt index ae7761cb..3373244b 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCase.kt @@ -1,6 +1,6 @@ package team.comit.simtong.domain.auth.usecase -import team.comit.simtong.domain.auth.exception.CertifiedEmailException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.auth.model.AuthCode import team.comit.simtong.domain.auth.model.AuthCodeLimit import team.comit.simtong.domain.auth.spi.CommandAuthCodeLimitPort @@ -29,8 +29,8 @@ class SendAuthCodeUseCase( val authCodeLimit = queryAuthCodeLimitPort.queryAuthCodeLimitByEmail(email) ?: AuthCodeLimit(email) - if(authCodeLimit.verified) { - throw CertifiedEmailException.EXCEPTION + if (authCodeLimit.verified) { + throw AuthExceptions.AlreadyCertifiedEmail() } commandAuthCodeLimitPort.save(authCodeLimit.increaseCount()) diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/file/usecase/CheckEmployeeUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/file/usecase/CheckEmployeeUseCase.kt index a83ddc71..6bd3ac42 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/file/usecase/CheckEmployeeUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/file/usecase/CheckEmployeeUseCase.kt @@ -1,6 +1,6 @@ package team.comit.simtong.domain.file.usecase -import team.comit.simtong.domain.file.exception.InvalidEmployeeException +import team.comit.simtong.domain.file.exception.FileExceptions import team.comit.simtong.domain.file.spi.QueryEmployeeCertificatePort import team.comit.simtong.global.annotation.ReadOnlyUseCase @@ -23,7 +23,7 @@ class CheckEmployeeUseCase( ) if (!isEmployee) { - throw InvalidEmployeeException.EXCEPTION + throw FileExceptions.NotExistsEmployee() } } } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCase.kt index dd2f2335..7ea5f525 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCase.kt @@ -1,13 +1,13 @@ package team.comit.simtong.domain.holiday.usecase -import team.comit.simtong.domain.holiday.exception.WeekHolidayLimitExcessException +import team.comit.simtong.domain.holiday.exception.HolidayExceptions import team.comit.simtong.domain.holiday.model.Holiday import team.comit.simtong.domain.holiday.model.HolidayType import team.comit.simtong.domain.holiday.spi.CommandHolidayPort import team.comit.simtong.domain.holiday.spi.HolidayQueryUserPort import team.comit.simtong.domain.holiday.spi.HolidaySecurityPort import team.comit.simtong.domain.holiday.spi.QueryHolidayPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.global.annotation.UseCase import java.time.LocalDate @@ -29,12 +29,12 @@ class AppointHolidayUseCase( fun execute(date: LocalDate) { val user = queryUserPort.queryUserById(securityPort.getCurrentUserId()) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() val countHoliday = queryHolidayPort.countHolidayByWeekAndUserIdAndType(date, user.id, HolidayType.HOLIDAY) if (countHoliday >= Holiday.WEEK_HOLIDAY_LIMIT) { - throw WeekHolidayLimitExcessException.EXCEPTION + throw HolidayExceptions.WeekHolidayLimitExcess() } commandHolidayPort.save( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/CancelHolidayUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/CancelHolidayUseCase.kt index 86e83df4..42d4b158 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/CancelHolidayUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/CancelHolidayUseCase.kt @@ -1,6 +1,6 @@ package team.comit.simtong.domain.holiday.usecase -import team.comit.simtong.domain.holiday.exception.HolidayNotFoundException +import team.comit.simtong.domain.holiday.exception.HolidayExceptions import team.comit.simtong.domain.holiday.spi.CommandHolidayPort import team.comit.simtong.domain.holiday.spi.HolidaySecurityPort import team.comit.simtong.domain.holiday.spi.QueryHolidayPort @@ -26,7 +26,7 @@ class CancelHolidayUseCase( val currentUserId = securityPort.getCurrentUserId() val holiday = queryHolidayPort.queryHolidayByDateAndUserId(date, currentUserId) - ?: throw HolidayNotFoundException.EXCEPTION + ?: throw HolidayExceptions.NotFound() commandHolidayPort.delete(holiday) } diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCase.kt index f9c5f8d4..9968ed24 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCase.kt @@ -4,7 +4,7 @@ import team.comit.simtong.domain.menu.dto.MenuResponse import team.comit.simtong.domain.menu.spi.MenuQueryUserPort import team.comit.simtong.domain.menu.spi.MenuSecurityPort import team.comit.simtong.domain.menu.spi.QueryMenuPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.global.annotation.ReadOnlyUseCase import java.time.LocalDate @@ -25,7 +25,7 @@ class QueryMenuByMonthUseCase( fun execute(date: LocalDate): MenuResponse { val currentUserId = menuSecurityPort.getCurrentUserId() - val user = queryUserPort.queryUserById(currentUserId) ?: throw UserNotFoundException.EXCEPTION + val user = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() val menu = queryMenuPort.queryMenusByMonthAndSpotId(date, user.spotId) val result = menu.map { MenuResponse.MenuElement(it.date, it.meal) } diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/SaveMenuUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/SaveMenuUseCase.kt index 214aba9e..f895a1c7 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/SaveMenuUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/SaveMenuUseCase.kt @@ -1,6 +1,6 @@ package team.comit.simtong.domain.menu.usecase -import team.comit.simtong.domain.menu.exception.MenuAlreadyExistsSameMonthException +import team.comit.simtong.domain.menu.exception.MenuExceptions import team.comit.simtong.domain.menu.spi.CommandMenuPort import team.comit.simtong.domain.menu.spi.ParseMenuFilePort import team.comit.simtong.domain.menu.spi.QueryMenuPort @@ -28,7 +28,7 @@ class SaveMenuUseCase( val menu = parseMenuFilePort.importMenu(file, year, month, spotId) if (queryMenuPort.queryMenusByMonthAndSpotId(LocalDate.of(year, month, 1), spotId).isNotEmpty()) { - throw MenuAlreadyExistsSameMonthException.EXCEPTION + throw MenuExceptions.AlreadyExistsSameMonth("${year}년 ${month}월 메뉴가 이미 존재합니다.") } commandMenuPort.saveAll(menu) diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCase.kt index e003c47b..b3974065 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCase.kt @@ -6,7 +6,7 @@ import team.comit.simtong.domain.schedule.model.Scope import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.global.annotation.UseCase /** @@ -29,7 +29,7 @@ class AddIndividualScheduleUseCase( val (title, startAt, endAt, alarm) = request val user = queryUserPort.queryUserById(currentUserId) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() commandSchedulePort.save( Schedule( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCase.kt index a76f5018..4413ff97 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCase.kt @@ -6,8 +6,7 @@ import team.comit.simtong.domain.schedule.model.Scope import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.NotEnoughPermissionException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.global.annotation.UseCase @@ -31,10 +30,10 @@ class AddSpotScheduleUseCase( val (spotId, title, startAt, endAt) = request val user = queryUserPort.queryUserById(currentUserId) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() if (user.spotId != spotId && user.authority != Authority.ROLE_SUPER) { - throw NotEnoughPermissionException.EXCEPTION + throw UserExceptions.NotEnoughPermission("같은 지점 관리자이거나 최고 관리자이어야 합니다.") } commandSchedulePort.save( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCase.kt index c9219019..c4ee4491 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCase.kt @@ -1,13 +1,12 @@ package team.comit.simtong.domain.schedule.usecase import team.comit.simtong.domain.schedule.dto.ChangeIndividualScheduleRequest -import team.comit.simtong.domain.schedule.exception.NotScheduleOwnerException -import team.comit.simtong.domain.schedule.exception.ScheduleNotFoundException +import team.comit.simtong.domain.schedule.exception.ScheduleExceptions import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.QuerySchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.global.annotation.UseCase /** @@ -31,13 +30,13 @@ class ChangeIndividualScheduleUseCase( val (scheduleId, title, startAt, endAt, alarm) = request val schedule = querySchedulePort.queryScheduleById(scheduleId) - ?: throw ScheduleNotFoundException.EXCEPTION + ?: throw ScheduleExceptions.NotFound() val user = queryUserPort.queryUserById(currentUserId) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() if (user.id != schedule.userId) { - throw NotScheduleOwnerException.EXCEPTION + throw ScheduleExceptions.NotScheduleOwner() } commandSchedulePort.save( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCase.kt index 65ea49bc..584076cc 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCase.kt @@ -1,15 +1,13 @@ package team.comit.simtong.domain.schedule.usecase import team.comit.simtong.domain.schedule.dto.ChangeSpotScheduleRequest -import team.comit.simtong.domain.schedule.exception.NotScheduleOwnerException -import team.comit.simtong.domain.schedule.exception.ScheduleNotFoundException +import team.comit.simtong.domain.schedule.exception.ScheduleExceptions import team.comit.simtong.domain.schedule.model.Scope import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.QuerySchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.NotEnoughPermissionException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.global.annotation.UseCase @@ -33,16 +31,16 @@ class ChangeSpotScheduleUseCase( val currentUserId = securityPort.getCurrentUserId() val user = queryUserPort.queryUserById(currentUserId) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() val schedule = querySchedulePort.queryScheduleById(request.scheduleId) - ?: throw ScheduleNotFoundException.EXCEPTION + ?: throw ScheduleExceptions.NotFound() when { - Scope.ENTIRE != schedule.scope -> throw NotScheduleOwnerException.EXCEPTION + Scope.ENTIRE != schedule.scope -> throw ScheduleExceptions.NotScheduleOwner() - user.spotId != schedule.spotId && - Authority.ROLE_SUPER != user.authority -> throw NotEnoughPermissionException.EXCEPTION + user.spotId != schedule.spotId && Authority.ROLE_SUPER != user.authority -> + throw UserExceptions.NotEnoughPermission("같은 지점 관리자이거나 최고 관리자이어야 합니다.") } commandSchedulePort.save( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCase.kt index 1072c3c4..5987e211 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCase.kt @@ -6,7 +6,7 @@ import team.comit.simtong.domain.schedule.model.Scope import team.comit.simtong.domain.schedule.spi.QuerySchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.global.annotation.ReadOnlyUseCase import java.time.LocalDate @@ -27,7 +27,7 @@ class QueryIndividualSpotScheduleUseCase( fun execute(date: LocalDate): QueryIndividualSpotScheduleResponse { val user = queryUserPort.queryUserById(securityPort.getCurrentUserId()) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() val individualSchedules = querySchedulePort.querySchedulesByMonthAndUserIdAndScope( date, user.id, Scope.INDIVIDUAL diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCase.kt index 58c8867f..7cd050b7 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCase.kt @@ -1,14 +1,12 @@ package team.comit.simtong.domain.schedule.usecase -import team.comit.simtong.domain.schedule.exception.DifferentScopeException -import team.comit.simtong.domain.schedule.exception.NotScheduleOwnerException -import team.comit.simtong.domain.schedule.exception.ScheduleNotFoundException +import team.comit.simtong.domain.schedule.exception.ScheduleExceptions import team.comit.simtong.domain.schedule.model.Scope import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.QuerySchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.global.annotation.UseCase import java.util.UUID @@ -32,17 +30,17 @@ class RemoveIndividualScheduleUseCase( val currentUserId = securityPort.getCurrentUserId() val user = queryUserPort.queryUserById(currentUserId) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() val schedule = querySchedulePort.queryScheduleById(scheduleId) - ?: throw ScheduleNotFoundException.EXCEPTION + ?: throw ScheduleExceptions.NotFound() if (user.id != schedule.userId) { - throw NotScheduleOwnerException.EXCEPTION + throw ScheduleExceptions.NotScheduleOwner() } if (Scope.INDIVIDUAL != schedule.scope) { - throw DifferentScopeException.EXCEPTION + throw ScheduleExceptions.DifferentScope("개인 일정이 아닙니다.") } commandSchedulePort.delete(schedule) diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCase.kt index 4eaa66f8..210cdddd 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCase.kt @@ -1,14 +1,12 @@ package team.comit.simtong.domain.schedule.usecase -import team.comit.simtong.domain.schedule.exception.DifferentScopeException -import team.comit.simtong.domain.schedule.exception.ScheduleNotFoundException +import team.comit.simtong.domain.schedule.exception.ScheduleExceptions import team.comit.simtong.domain.schedule.model.Scope import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.QuerySchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.NotEnoughPermissionException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.global.annotation.UseCase import java.util.UUID @@ -33,17 +31,17 @@ class RemoveSpotScheduleUseCase( val currentUserId = securityPort.getCurrentUserId() val user = queryUserPort.queryUserById(currentUserId) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() val schedule = querySchedulePort.queryScheduleById(scheduleId) - ?: throw ScheduleNotFoundException.EXCEPTION + ?: throw ScheduleExceptions.NotFound() if (user.spotId != schedule.spotId && user.authority != Authority.ROLE_SUPER) { - throw NotEnoughPermissionException.EXCEPTION + throw UserExceptions.NotEnoughPermission("같은 지점 관리자이거나 최고 관리자이어야 합니다.") } if (Scope.ENTIRE != schedule.scope) { - throw DifferentScopeException.EXCEPTION + throw ScheduleExceptions.DifferentScope("지점 일정이 아닙니다.") } commandSchedulePort.delete(schedule) diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCase.kt index a26bad3f..94052289 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCase.kt @@ -2,9 +2,7 @@ package team.comit.simtong.domain.user.usecase import team.comit.simtong.domain.auth.dto.TokenResponse import team.comit.simtong.domain.user.dto.SignInRequest -import team.comit.simtong.domain.user.exception.DifferentPasswordException -import team.comit.simtong.domain.user.exception.DifferentPermissionAccountException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserJwtPort @@ -22,23 +20,23 @@ import team.comit.simtong.global.annotation.UseCase @UseCase class AdminSignInUseCase( private val queryUserPort: QueryUserPort, - private val userJwtPort: UserJwtPort, - private val userSecurityPort: UserSecurityPort + private val jwtPort: UserJwtPort, + private val securityPort: UserSecurityPort ) { fun execute(request: SignInRequest): TokenResponse { val admin = queryUserPort.queryUserByEmployeeNumber(request.employeeNumber) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound("관리자가 존재하지 않습니다.") if (Authority.ROLE_COMMON == admin.authority) { - throw DifferentPermissionAccountException.EXCEPTION + throw UserExceptions.DifferentPermissionAccount("관리자 계정이 아닙니다.") } - if (!userSecurityPort.compare(request.password, admin.password)) { - throw DifferentPasswordException.EXCEPTION + if (!securityPort.compare(request.password, admin.password)) { + throw UserExceptions.DifferentPassword() } - return userJwtPort.receiveToken( + return jwtPort.receiveToken( userId = admin.id, authority = admin.authority ) diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCase.kt index b1bba5d4..768a6815 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCase.kt @@ -1,11 +1,9 @@ package team.comit.simtong.domain.user.usecase -import team.comit.simtong.domain.auth.exception.RequiredNewEmailAuthenticationException -import team.comit.simtong.domain.auth.exception.UncertifiedEmailException -import team.comit.simtong.domain.auth.exception.UsedEmailException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.auth.spi.QueryAuthCodeLimitPort import team.comit.simtong.domain.user.dto.ChangeEmailRequest -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.CommandUserPort import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserSecurityPort @@ -22,25 +20,25 @@ import team.comit.simtong.global.annotation.UseCase @UseCase class ChangeEmailUseCase( private val queryUserPort: QueryUserPort, - private val userSecurityPort: UserSecurityPort, + private val securityPort: UserSecurityPort, private val queryAuthCodeLimitPort: QueryAuthCodeLimitPort, private val commandUserPort: CommandUserPort ) { fun execute(request: ChangeEmailRequest) { if (queryUserPort.existsUserByEmail(request.email)) { - throw UsedEmailException.EXCEPTION + throw AuthExceptions.AlreadyUsedEmail() } val authCodeLimit = queryAuthCodeLimitPort.queryAuthCodeLimitByEmail(request.email) - ?: throw RequiredNewEmailAuthenticationException.EXCEPTION + ?: throw AuthExceptions.RequiredNewEmailAuthentication() if (!authCodeLimit.verified) { - throw UncertifiedEmailException.EXCEPTION + throw AuthExceptions.UncertifiedEmail() } - val currentUserId = userSecurityPort.getCurrentUserId() - val user = queryUserPort.queryUserById(currentUserId) ?: throw UserNotFoundException.EXCEPTION + val currentUserId = securityPort.getCurrentUserId() + val user = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() commandUserPort.save( user.copy( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCase.kt index a2508015..7dade2d5 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCase.kt @@ -1,8 +1,7 @@ package team.comit.simtong.domain.user.usecase -import team.comit.simtong.domain.auth.exception.UsedNicknameException import team.comit.simtong.domain.user.dto.ChangeNicknameRequest -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.CommandUserPort import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserSecurityPort @@ -19,17 +18,17 @@ import team.comit.simtong.global.annotation.UseCase @UseCase class ChangeNicknameUseCase( private val queryUserPort: QueryUserPort, - private val userSecurityPort: UserSecurityPort, + private val securityPort: UserSecurityPort, private val commandUserPort: CommandUserPort ) { fun execute(request: ChangeNicknameRequest) { if (queryUserPort.existsUserByNickname(request.nickname)) { - throw UsedNicknameException.EXCEPTION + throw UserExceptions.AlreadyUsedNickname() } - val currentUserId = userSecurityPort.getCurrentUserId() - val user = queryUserPort.queryUserById(currentUserId) ?: throw UserNotFoundException.EXCEPTION + val currentUserId = securityPort.getCurrentUserId() + val user = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() commandUserPort.save( user.copy( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCase.kt index 0a86d4f3..ff2ebb58 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCase.kt @@ -1,8 +1,7 @@ package team.comit.simtong.domain.user.usecase import team.comit.simtong.domain.user.dto.ChangePasswordRequest -import team.comit.simtong.domain.user.exception.DifferentPasswordException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.CommandUserPort import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserSecurityPort @@ -25,10 +24,10 @@ class ChangePasswordUseCase( fun execute(request: ChangePasswordRequest) { val currentUserId = userSecurityPort.getCurrentUserId() - val user = queryUserPort.queryUserById(currentUserId) ?: throw UserNotFoundException.EXCEPTION + val user = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() if (!userSecurityPort.compare(request.password, user.password)) { - throw DifferentPasswordException.EXCEPTION + throw UserExceptions.DifferentPassword() } commandUserPort.save( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCase.kt index ec241558..2b174310 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCase.kt @@ -1,9 +1,9 @@ package team.comit.simtong.domain.user.usecase -import team.comit.simtong.domain.file.exception.NotFoundFilePathException +import team.comit.simtong.domain.file.exception.FileExceptions import team.comit.simtong.domain.file.spi.CheckFilePort import team.comit.simtong.domain.user.dto.ChangeProfileImageRequest -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.CommandUserPort import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserSecurityPort @@ -20,18 +20,18 @@ import team.comit.simtong.global.annotation.UseCase @UseCase class ChangeProfileImageUseCase( private val queryUserPort: QueryUserPort, - private val userSecurityPort: UserSecurityPort, + private val securityPort: UserSecurityPort, private val commandUserPort: CommandUserPort, private val checkFilePort: CheckFilePort ) { fun execute(request: ChangeProfileImageRequest) { if (!checkFilePort.existsPath(request.profileImagePath)) { - throw NotFoundFilePathException.EXCEPTION + throw FileExceptions.PathNotFound() } - val currentUserId = userSecurityPort.getCurrentUserId() - val user = queryUserPort.queryUserById(currentUserId) ?: throw UserNotFoundException.EXCEPTION + val currentUserId = securityPort.getCurrentUserId() + val user = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() commandUserPort.save( user.copy( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCase.kt index b57bdbec..2336c910 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCase.kt @@ -1,13 +1,13 @@ package team.comit.simtong.domain.user.usecase -import team.comit.simtong.domain.spot.exception.SpotNotFoundException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.spot.exception.SpotExceptions +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.CommandUserPort import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserQuerySpotPort import team.comit.simtong.domain.user.spi.UserSecurityPort import team.comit.simtong.global.annotation.UseCase -import java.util.* +import java.util.UUID /** * @@ -27,10 +27,10 @@ class ChangeSpotUseCase( fun execute(newSpotId: UUID) { val user = queryUserPort.queryUserById(securityPort.getCurrentUserId()) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() if (!querySpotPort.existsSpotById(newSpotId)) { - throw SpotNotFoundException.EXCEPTION + throw SpotExceptions.NotFound() } commandUserPort.save( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCase.kt index af827180..ed84637a 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCase.kt @@ -1,6 +1,6 @@ package team.comit.simtong.domain.user.usecase -import team.comit.simtong.domain.auth.exception.UsedEmailException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.global.annotation.ReadOnlyUseCase @@ -19,7 +19,7 @@ class CheckEmailDuplicationUseCase( fun execute(email: String) { if (queryUserPort.existsUserByEmail(email)) { - throw UsedEmailException.EXCEPTION + throw AuthExceptions.AlreadyUsedEmail() } } diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCase.kt index ca8f8be3..3d7c296c 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCase.kt @@ -1,7 +1,7 @@ package team.comit.simtong.domain.user.usecase import team.comit.simtong.domain.user.dto.CheckMatchedAccountRequest -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.global.annotation.ReadOnlyUseCase @@ -21,7 +21,7 @@ class CheckMatchedAccountUseCase( fun execute(request: CheckMatchedAccountRequest) { if (!queryUserPort.existsUserByEmployeeNumberAndEmail(request.employeeNumber, request.email)) { - throw UserNotFoundException.EXCEPTION + throw UserExceptions.NotFound() } } diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCase.kt index 3eef7e11..9f53e311 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCase.kt @@ -1,6 +1,6 @@ package team.comit.simtong.domain.user.usecase -import team.comit.simtong.domain.auth.exception.UsedNicknameException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.global.annotation.ReadOnlyUseCase @@ -19,7 +19,7 @@ class CheckNicknameDuplicationUseCase( fun execute(nickname: String) { if (queryUserPort.existsUserByNickname(nickname)) { - throw UsedNicknameException.EXCEPTION + throw UserExceptions.AlreadyUsedNickname() } } diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCase.kt index 03a7bf26..41108351 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCase.kt @@ -1,7 +1,6 @@ package team.comit.simtong.domain.user.usecase -import team.comit.simtong.domain.user.exception.DifferentPasswordException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserSecurityPort import team.comit.simtong.global.annotation.ReadOnlyUseCase @@ -22,10 +21,10 @@ class ComparePasswordUseCase( fun execute(password: String) { val user = queryUserPort.queryUserById(securityPort.getCurrentUserId()) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() if (!securityPort.compare(password, user.password)) { - throw DifferentPasswordException.EXCEPTION + throw UserExceptions.DifferentPassword() } } diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCase.kt index 6b2a9f99..de06dcd6 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCase.kt @@ -1,8 +1,8 @@ package team.comit.simtong.domain.user.usecase -import team.comit.simtong.domain.user.exception.UserNotFoundException -import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.dto.FindEmployeeNumberRequest +import team.comit.simtong.domain.user.exception.UserExceptions +import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.global.annotation.UseCase /** @@ -20,7 +20,7 @@ class FindEmployeeNumberUseCase( fun execute(request: FindEmployeeNumberRequest): Int { val user = queryUserPort.queryUserByNameAndSpotAndEmail(request.name, request.spotId, request.email) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() return user.employeeNumber } diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCase.kt index 312a13b2..ecdf4797 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCase.kt @@ -1,8 +1,8 @@ package team.comit.simtong.domain.user.usecase -import team.comit.simtong.domain.spot.exception.SpotNotFoundException +import team.comit.simtong.domain.spot.exception.SpotExceptions import team.comit.simtong.domain.user.dto.QueryAdminInfoResponse -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserQuerySpotPort import team.comit.simtong.domain.user.spi.UserSecurityPort @@ -25,10 +25,10 @@ class QueryAdminInfoUseCase( fun execute(): QueryAdminInfoResponse { val user = queryUserPort.queryUserById(securityPort.getCurrentUserId()) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() val spot = querySpotPort.querySpotById(user.spotId) - ?: throw SpotNotFoundException.EXCEPTION + ?: throw SpotExceptions.NotFound() return QueryAdminInfoResponse( name = user.name, diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCase.kt index 98bb212e..0f935a4b 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCase.kt @@ -1,8 +1,8 @@ package team.comit.simtong.domain.user.usecase -import team.comit.simtong.domain.spot.exception.SpotNotFoundException +import team.comit.simtong.domain.spot.exception.SpotExceptions import team.comit.simtong.domain.user.dto.QueryUserInfoResponse -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserQuerySpotPort import team.comit.simtong.domain.user.spi.UserSecurityPort @@ -26,8 +26,8 @@ class QueryUserInfoUseCase( fun execute(): QueryUserInfoResponse { val currentUserId = securityPort.getCurrentUserId() - val user = queryUserPort.queryUserById(currentUserId) ?: throw UserNotFoundException.EXCEPTION - val spot = querySpotPort.querySpotById(user.spotId) ?: throw SpotNotFoundException.EXCEPTION + val user = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() + val spot = querySpotPort.querySpotById(user.spotId) ?: throw SpotExceptions.NotFound() return QueryUserInfoResponse( name = user.name, diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCase.kt index 05f5b371..c2b77cbb 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCase.kt @@ -1,9 +1,8 @@ package team.comit.simtong.domain.user.usecase -import team.comit.simtong.domain.auth.exception.RequiredNewEmailAuthenticationException -import team.comit.simtong.domain.auth.exception.UncertifiedEmailException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.user.dto.ResetPasswordRequest -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.CommandUserPort import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserCommandAuthCodeLimitPort @@ -30,14 +29,14 @@ class ResetPasswordUseCase( fun execute(request: ResetPasswordRequest) { val authCodeLimit = queryAuthCodeLimitPort.queryAuthCodeLimitByEmail(request.email) - ?: throw RequiredNewEmailAuthenticationException.EXCEPTION + ?: throw AuthExceptions.RequiredNewEmailAuthentication() if (!authCodeLimit.verified) { - throw UncertifiedEmailException.EXCEPTION + throw AuthExceptions.UncertifiedEmail() } val user = queryUserPort.queryUserByEmailAndEmployeeNumber(request.email, request.employeeNumber) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() commandUserPort.save( user.copy( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCase.kt index e1621e4c..a41f6cfb 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCase.kt @@ -2,9 +2,7 @@ package team.comit.simtong.domain.user.usecase import team.comit.simtong.domain.auth.dto.TokenResponse import team.comit.simtong.domain.user.dto.SignInRequest -import team.comit.simtong.domain.user.exception.DifferentPasswordException -import team.comit.simtong.domain.user.exception.DifferentPermissionAccountException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserJwtPort @@ -28,14 +26,14 @@ class SignInUseCase( fun execute(request: SignInRequest): TokenResponse { val user = queryUserPort.queryUserByEmployeeNumber(request.employeeNumber) - ?: throw UserNotFoundException.EXCEPTION + ?: throw UserExceptions.NotFound() if (Authority.ROLE_COMMON != user.authority) { - throw DifferentPermissionAccountException.EXCEPTION + throw UserExceptions.DifferentPermissionAccount("사원 계정이 아닙니다.") } if (!userSecurityPort.compare(request.password, user.password)) { - throw DifferentPasswordException.EXCEPTION + throw UserExceptions.DifferentPassword() } return userJwtPort.receiveToken( diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCase.kt index ae01ea73..0400b005 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCase.kt @@ -1,12 +1,10 @@ package team.comit.simtong.domain.user.usecase import team.comit.simtong.domain.auth.dto.TokenResponse -import team.comit.simtong.domain.auth.exception.RequiredNewEmailAuthenticationException -import team.comit.simtong.domain.auth.exception.UncertifiedEmailException -import team.comit.simtong.domain.auth.exception.UsedEmailException -import team.comit.simtong.domain.file.exception.InvalidEmployeeException -import team.comit.simtong.domain.spot.exception.SpotNotFoundException -import team.comit.simtong.domain.team.exception.TeamNotFoundException +import team.comit.simtong.domain.auth.exception.AuthExceptions +import team.comit.simtong.domain.file.exception.FileExceptions +import team.comit.simtong.domain.spot.exception.SpotExceptions +import team.comit.simtong.domain.team.exception.TeamExceptions import team.comit.simtong.domain.user.dto.SignUpRequest import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User @@ -47,24 +45,24 @@ class SignUpUseCase( val (name, email, password, nickname, employeeNumber, profileImagePath) = request if (queryUserPort.existsUserByEmail(email)) { - throw UsedEmailException.EXCEPTION + throw AuthExceptions.AlreadyUsedEmail() } val authCodeLimit = queryAuthCodeLimitPort.queryAuthCodeLimitByEmail(email) - ?: throw RequiredNewEmailAuthenticationException.EXCEPTION + ?: throw AuthExceptions.RequiredNewEmailAuthentication() if (!authCodeLimit.verified) { - throw UncertifiedEmailException.EXCEPTION + throw AuthExceptions.UncertifiedEmail() } val employeeCertificate = queryEmployeeCertificatePort.queryEmployeeCertificateByNameAndEmployeeNumber(name, employeeNumber) - ?: throw InvalidEmployeeException.EXCEPTION + ?: throw FileExceptions.NotExistsEmployee() val spot = querySpotPort.querySpotByName(employeeCertificate.spotName) - ?: throw SpotNotFoundException.EXCEPTION + ?: throw SpotExceptions.NotFound() val team = queryTeamPort.queryTeamByName(employeeCertificate.teamName) - ?: throw TeamNotFoundException.EXCEPTION + ?: throw TeamExceptions.NotFound() val user = commandUserPort.save( User( diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCaseTests.kt index 71933108..98f30b0b 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCaseTests.kt @@ -6,7 +6,7 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.auth.exception.AuthCodeMismatchException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.auth.model.AuthCode import team.comit.simtong.domain.auth.spi.CommandAuthCodeLimitPort import team.comit.simtong.domain.auth.spi.QueryAuthCodePort @@ -70,7 +70,7 @@ class CheckAuthCodeUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { checkAuthCodeUseCase.execute(email, code) } } @@ -82,7 +82,7 @@ class CheckAuthCodeUseCaseTests { .willReturn(differentAuthCodeStub) // when & then - assertThrows { + assertThrows { checkAuthCodeUseCase.execute(email, code) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/ReissueTokenUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/ReissueTokenUseCaseTests.kt index 26d3235a..2231eb86 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/ReissueTokenUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/ReissueTokenUseCaseTests.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.assertThrows import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean import team.comit.simtong.domain.auth.dto.TokenResponse -import team.comit.simtong.domain.auth.exception.RefreshTokenNotFoundException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.auth.model.RefreshToken import team.comit.simtong.domain.auth.spi.JwtPort import team.comit.simtong.domain.auth.spi.QueryRefreshTokenPort @@ -75,7 +75,7 @@ class ReissueTokenUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { reissueTokenUseCase.execute(token) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCaseTests.kt index 11a6cd19..084affcb 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCaseTests.kt @@ -8,8 +8,7 @@ import org.mockito.BDDMockito.given import org.mockito.BDDMockito.willDoNothing import org.mockito.kotlin.any import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.auth.exception.CertifiedEmailException -import team.comit.simtong.domain.auth.exception.ExceededSendAuthCodeRequestException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.auth.model.AuthCode import team.comit.simtong.domain.auth.model.AuthCodeLimit import team.comit.simtong.domain.auth.spi.CommandAuthCodeLimitPort @@ -99,7 +98,7 @@ class SendAuthCodeUseCaseTests { .willReturn(verifiedAuthCodeLimitStub) // when & then - assertThrows { + assertThrows { sendAuthCodeUseCase.execute(email) } } @@ -111,7 +110,7 @@ class SendAuthCodeUseCaseTests { .willReturn(exceedAuthCodeLimitStub) // when & then - assertThrows { + assertThrows { sendAuthCodeUseCase.execute(email) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/file/usecase/CheckEmployeeUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/file/usecase/CheckEmployeeUseCaseTests.kt index e6c71070..1d149c87 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/file/usecase/CheckEmployeeUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/file/usecase/CheckEmployeeUseCaseTests.kt @@ -6,7 +6,7 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.file.exception.InvalidEmployeeException +import team.comit.simtong.domain.file.exception.FileExceptions import team.comit.simtong.domain.file.spi.QueryEmployeeCertificatePort import team.comit.simtong.global.annotation.SimtongTest @@ -46,7 +46,7 @@ class CheckEmployeeUseCaseTests { .willReturn(false) // when & then - assertThrows { + assertThrows { checkEmployeeUseCase.execute(name, employeeNumber) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCaseTests.kt index 3c927c74..010c1474 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCaseTests.kt @@ -6,14 +6,14 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.holiday.exception.WeekHolidayLimitExcessException +import team.comit.simtong.domain.holiday.exception.HolidayExceptions import team.comit.simtong.domain.holiday.model.Holiday import team.comit.simtong.domain.holiday.model.HolidayType import team.comit.simtong.domain.holiday.spi.CommandHolidayPort import team.comit.simtong.domain.holiday.spi.HolidayQueryUserPort import team.comit.simtong.domain.holiday.spi.HolidaySecurityPort import team.comit.simtong.domain.holiday.spi.QueryHolidayPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.global.annotation.SimtongTest @@ -97,7 +97,7 @@ class AppointHolidayUseCaseTests { .willReturn(Holiday.WEEK_HOLIDAY_LIMIT) // when & then - assertThrows { + assertThrows { appointHolidayUseCase.execute(dateStub) } } @@ -112,7 +112,7 @@ class AppointHolidayUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { appointHolidayUseCase.execute(dateStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/CancelHolidayUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/CancelHolidayUseCaseTests.kt index 239b4336..aad34dc7 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/CancelHolidayUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/CancelHolidayUseCaseTests.kt @@ -6,7 +6,7 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.holiday.exception.HolidayNotFoundException +import team.comit.simtong.domain.holiday.exception.HolidayExceptions import team.comit.simtong.domain.holiday.model.Holiday import team.comit.simtong.domain.holiday.model.HolidayType import team.comit.simtong.domain.holiday.spi.CommandHolidayPort @@ -77,7 +77,7 @@ class CancelHolidayUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { cancelHolidayUseCase.execute(dateStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt index 3689314f..13e49f16 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt @@ -10,7 +10,7 @@ import team.comit.simtong.domain.menu.model.Menu import team.comit.simtong.domain.menu.spi.MenuQueryUserPort import team.comit.simtong.domain.menu.spi.MenuSecurityPort import team.comit.simtong.domain.menu.spi.QueryMenuPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.global.annotation.SimtongTest @@ -102,7 +102,7 @@ class QueryMenuByMonthUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { queryMenuByMonthUseCase.execute(now) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/SaveMenuUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/SaveMenuUseCaseTests.kt index 57bc5418..65f3c8d4 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/SaveMenuUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/SaveMenuUseCaseTests.kt @@ -6,7 +6,7 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.menu.exception.MenuAlreadyExistsSameMonthException +import team.comit.simtong.domain.menu.exception.MenuExceptions import team.comit.simtong.domain.menu.model.Menu import team.comit.simtong.domain.menu.spi.CommandMenuPort import team.comit.simtong.domain.menu.spi.ParseMenuFilePort @@ -77,7 +77,7 @@ class SaveMenuUseCaseTests { .willReturn(listOf(menuStub)) // when & then - assertThrows { + assertThrows { saveMenuUseCase.execute(fileStub, year, month, spotId) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCaseTests.kt index 6be548c8..39a69df1 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCaseTests.kt @@ -10,7 +10,7 @@ import team.comit.simtong.domain.schedule.dto.AddIndividualScheduleRequest import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.global.annotation.SimtongTest @@ -89,7 +89,7 @@ class AddIndividualScheduleUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { addIndividualScheduleUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCaseTests.kt index 29d61ec3..f535933a 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCaseTests.kt @@ -10,8 +10,7 @@ import team.comit.simtong.domain.schedule.dto.AddSpotScheduleRequest import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.NotEnoughPermissionException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.global.annotation.SimtongTest @@ -103,7 +102,7 @@ class AddSpotScheduleUseCaseTests { .willReturn(userStub) // when & then - assertThrows { + assertThrows { addSpotScheduleUseCase.execute(requestStub) } } @@ -146,7 +145,7 @@ class AddSpotScheduleUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { addSpotScheduleUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCaseTest.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCaseTest.kt index f968e58f..34445c09 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCaseTest.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCaseTest.kt @@ -8,15 +8,14 @@ import org.mockito.Mock import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean import team.comit.simtong.domain.schedule.dto.ChangeIndividualScheduleRequest -import team.comit.simtong.domain.schedule.exception.NotScheduleOwnerException -import team.comit.simtong.domain.schedule.exception.ScheduleNotFoundException +import team.comit.simtong.domain.schedule.exception.ScheduleExceptions import team.comit.simtong.domain.schedule.model.Schedule import team.comit.simtong.domain.schedule.model.Scope import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.QuerySchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.global.annotation.SimtongTest @@ -137,7 +136,7 @@ class ChangeIndividualScheduleUseCaseTest { .willReturn(userStub) // when & then - assertThrows { + assertThrows { changeIndividualScheduleUseCase.execute(requestStub) } } @@ -155,7 +154,7 @@ class ChangeIndividualScheduleUseCaseTest { .willReturn(null) // when & then - assertThrows { + assertThrows { changeIndividualScheduleUseCase.execute(requestStub) } } @@ -170,7 +169,7 @@ class ChangeIndividualScheduleUseCaseTest { .willReturn(null) // when & then - assertThrows { + assertThrows { changeIndividualScheduleUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCaseTests.kt index 1bff10cb..004d8846 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCaseTests.kt @@ -7,16 +7,14 @@ import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean import team.comit.simtong.domain.schedule.dto.ChangeSpotScheduleRequest -import team.comit.simtong.domain.schedule.exception.NotScheduleOwnerException -import team.comit.simtong.domain.schedule.exception.ScheduleNotFoundException +import team.comit.simtong.domain.schedule.exception.ScheduleExceptions import team.comit.simtong.domain.schedule.model.Schedule import team.comit.simtong.domain.schedule.model.Scope import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.QuerySchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.NotEnoughPermissionException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.global.annotation.SimtongTest @@ -146,7 +144,7 @@ class ChangeSpotScheduleUseCaseTests { .willReturn(individualScheduleStub) // when & then - assertThrows { + assertThrows { changeSpotScheduleUseCase.execute(requestStub) } } @@ -177,7 +175,7 @@ class ChangeSpotScheduleUseCaseTests { .willReturn(scheduleStub) // when & then - assertThrows { + assertThrows { changeSpotScheduleUseCase.execute(requestStub) } } @@ -239,7 +237,7 @@ class ChangeSpotScheduleUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { changeSpotScheduleUseCase.execute(requestStub) } } @@ -254,7 +252,7 @@ class ChangeSpotScheduleUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { changeSpotScheduleUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCaseTests.kt index 8fc0df5e..7bd9fcf2 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCaseTests.kt @@ -13,7 +13,7 @@ import team.comit.simtong.domain.schedule.model.Scope import team.comit.simtong.domain.schedule.spi.QuerySchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.global.annotation.SimtongTest @@ -151,7 +151,7 @@ class QueryIndividualSpotScheduleUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { queryIndividualSpotScheduleUseCase.execute(date) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCaseTests.kt index 805186cc..894e6848 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCaseTests.kt @@ -6,16 +6,14 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.schedule.exception.DifferentScopeException -import team.comit.simtong.domain.schedule.exception.NotScheduleOwnerException -import team.comit.simtong.domain.schedule.exception.ScheduleNotFoundException +import team.comit.simtong.domain.schedule.exception.ScheduleExceptions import team.comit.simtong.domain.schedule.model.Schedule import team.comit.simtong.domain.schedule.model.Scope import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.QuerySchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.global.annotation.SimtongTest @@ -124,7 +122,7 @@ class RemoveIndividualScheduleUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { removeIndividualScheduleUseCase.execute(scheduleId) } } @@ -142,7 +140,7 @@ class RemoveIndividualScheduleUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { removeIndividualScheduleUseCase.execute(scheduleId) } } @@ -171,7 +169,7 @@ class RemoveIndividualScheduleUseCaseTests { .willReturn(scheduleStub) // when & then - assertThrows { + assertThrows { removeIndividualScheduleUseCase.execute(scheduleId) } } @@ -200,7 +198,7 @@ class RemoveIndividualScheduleUseCaseTests { .willReturn(scheduleStub) // when & then - assertThrows { + assertThrows { removeIndividualScheduleUseCase.execute(scheduleId) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCaseTests.kt index 72b076c4..1a35e9f3 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCaseTests.kt @@ -6,16 +6,14 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.schedule.exception.DifferentScopeException -import team.comit.simtong.domain.schedule.exception.ScheduleNotFoundException +import team.comit.simtong.domain.schedule.exception.ScheduleExceptions import team.comit.simtong.domain.schedule.model.Schedule import team.comit.simtong.domain.schedule.model.Scope import team.comit.simtong.domain.schedule.spi.CommandSchedulePort import team.comit.simtong.domain.schedule.spi.QuerySchedulePort import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort -import team.comit.simtong.domain.user.exception.NotEnoughPermissionException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.global.annotation.SimtongTest @@ -156,7 +154,7 @@ class RemoveSpotScheduleUseCaseTests { .willReturn(scheduleStub) // when & then - assertThrows { + assertThrows { removeSpotScheduleUseCase.execute(scheduleId) } } @@ -198,7 +196,7 @@ class RemoveSpotScheduleUseCaseTests { .willReturn(scheduleStub) // when & then - assertThrows { + assertThrows { removeSpotScheduleUseCase.execute(scheduleId) } } @@ -229,7 +227,7 @@ class RemoveSpotScheduleUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { removeSpotScheduleUseCase.execute(scheduleId) } } @@ -244,7 +242,7 @@ class RemoveSpotScheduleUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { removeSpotScheduleUseCase.execute(scheduleId) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCaseTests.kt index cd48e780..147b2f5c 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCaseTests.kt @@ -8,9 +8,7 @@ import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean import team.comit.simtong.domain.auth.dto.TokenResponse import team.comit.simtong.domain.user.dto.SignInRequest -import team.comit.simtong.domain.user.exception.DifferentPasswordException -import team.comit.simtong.domain.user.exception.DifferentPermissionAccountException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.QueryUserPort @@ -119,7 +117,7 @@ class AdminSignInUseCaseTests { .willReturn(false) // when & then - assertThrows { + assertThrows { adminSignInUseCase.execute(requestStub) } } @@ -131,7 +129,7 @@ class AdminSignInUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { adminSignInUseCase.execute(requestStub) } } @@ -143,7 +141,7 @@ class AdminSignInUseCaseTests { .willReturn(userStub) // when & then - assertThrows { + assertThrows { adminSignInUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCaseTests.kt index 2f87f04d..40b28719 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCaseTests.kt @@ -6,13 +6,11 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.auth.exception.RequiredNewEmailAuthenticationException -import team.comit.simtong.domain.auth.exception.UncertifiedEmailException -import team.comit.simtong.domain.auth.exception.UsedEmailException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.auth.model.AuthCodeLimit import team.comit.simtong.domain.auth.spi.QueryAuthCodeLimitPort import team.comit.simtong.domain.user.dto.ChangeEmailRequest -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.CommandUserPort @@ -111,7 +109,7 @@ class ChangeEmailUseCaseTests { .willReturn(true) // when & then - assertThrows { + assertThrows { changeEmailUseCase.execute(requestStub) } } @@ -126,7 +124,7 @@ class ChangeEmailUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { changeEmailUseCase.execute(requestStub) } } @@ -141,7 +139,7 @@ class ChangeEmailUseCaseTests { .willReturn(uncertifiedAuthCodeLimit) // when & then - assertThrows { + assertThrows { changeEmailUseCase.execute(requestStub) } } @@ -162,7 +160,7 @@ class ChangeEmailUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { changeEmailUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCaseTests.kt index 5726b363..6c33f469 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCaseTests.kt @@ -6,9 +6,8 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.auth.exception.UsedNicknameException import team.comit.simtong.domain.user.dto.ChangeNicknameRequest -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.CommandUserPort @@ -88,7 +87,7 @@ class ChangeNicknameUseCaseTests { .willReturn(true) // when & then - assertThrows { + assertThrows { changeNicknameUseCase.execute(requestStub) } } @@ -100,7 +99,7 @@ class ChangeNicknameUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { changeNicknameUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCaseTests.kt index de24507c..09aedf79 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCaseTests.kt @@ -7,8 +7,7 @@ import org.junit.jupiter.api.assertThrows import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean import team.comit.simtong.domain.user.dto.ChangePasswordRequest -import team.comit.simtong.domain.user.exception.DifferentPasswordException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.CommandUserPort @@ -95,7 +94,7 @@ class ChangePasswordUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { changePasswordUseCase.execute(requestStub) } } @@ -113,7 +112,7 @@ class ChangePasswordUseCaseTests { .willReturn(false) // when & then - assertThrows { + assertThrows { changePasswordUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCaseTests.kt index 58d3f16c..ff51ac0a 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCaseTests.kt @@ -6,10 +6,10 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.file.exception.NotFoundFilePathException +import team.comit.simtong.domain.file.exception.FileExceptions import team.comit.simtong.domain.file.spi.CheckFilePort import team.comit.simtong.domain.user.dto.ChangeProfileImageRequest -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.CommandUserPort @@ -93,7 +93,7 @@ class ChangeProfileImageUseCaseTests { .willReturn(false) // when & then - assertThrows { + assertThrows { changeProfileImageUseCase.execute(requestStub) } } @@ -111,7 +111,7 @@ class ChangeProfileImageUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { changeProfileImageUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCaseTests.kt index d313e126..c150343d 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCaseTests.kt @@ -9,16 +9,17 @@ import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.context.annotation.Import import org.springframework.test.context.junit.jupiter.SpringExtension -import team.comit.simtong.global.DomainPropertiesInitialization -import team.comit.simtong.domain.spot.exception.SpotNotFoundException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.schedule.exception.ScheduleExceptions +import team.comit.simtong.domain.spot.exception.SpotExceptions +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.CommandUserPort import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserQuerySpotPort import team.comit.simtong.domain.user.spi.UserSecurityPort -import java.util.* +import team.comit.simtong.global.DomainPropertiesInitialization +import java.util.UUID @Import(DomainPropertiesInitialization::class) @ExtendWith(SpringExtension::class) @@ -79,8 +80,6 @@ class ChangeSpotUseCaseTests { } } - - @Test fun `유저를 찾을 수 없음`() { // given @@ -91,7 +90,7 @@ class ChangeSpotUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { changeSpotUseCase.execute(spotId) } } @@ -109,7 +108,7 @@ class ChangeSpotUseCaseTests { .willReturn(false) // when & then - assertThrows { + assertThrows { changeSpotUseCase.execute(spotId) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCaseTests.kt index ac930de0..73686e21 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCaseTests.kt @@ -6,7 +6,7 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.auth.exception.UsedEmailException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.global.annotation.SimtongTest @@ -44,7 +44,7 @@ class CheckEmailDuplicationUseCaseTests { .willReturn(true) // when & then - assertThrows { + assertThrows { checkEmailDuplicationUseCase.execute(email) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCaseTests.kt index 662e1924..a960279a 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCaseTests.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean import team.comit.simtong.domain.user.dto.CheckMatchedAccountRequest -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.global.annotation.SimtongTest @@ -50,7 +50,7 @@ class CheckMatchedAccountUseCaseTests { .willReturn(false) // when & then - assertThrows { + assertThrows { checkMatchedAccountUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCaseTests.kt index 1345785b..f847e9ea 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCaseTests.kt @@ -6,7 +6,7 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.auth.exception.UsedNicknameException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.global.annotation.SimtongTest @@ -44,7 +44,7 @@ class CheckNicknameDuplicationUseCaseTests { .willReturn(true) // when & then - assertThrows { + assertThrows { checkNicknameDuplicationUseCase.execute(nickname) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCaseTests.kt index ef411c46..58dbd985 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCaseTests.kt @@ -6,8 +6,7 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.user.exception.DifferentPasswordException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.QueryUserPort @@ -84,7 +83,7 @@ class ComparePasswordUseCaseTests { .willReturn(false) // when & then - assertThrows { + assertThrows { comparePasswordUseCase.execute(passwordStub) } } @@ -98,7 +97,7 @@ class ComparePasswordUseCaseTests { given(queryUserPort.queryUserById(userId)) .willReturn(null) - assertThrows { + assertThrows { comparePasswordUseCase.execute(passwordStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCaseTests.kt index e34112c3..d94cd89f 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCaseTests.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.assertThrows import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean import team.comit.simtong.domain.user.dto.FindEmployeeNumberRequest -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.QueryUserPort @@ -74,7 +74,7 @@ class FindEmployeeNumberUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { findEmployeeNumberUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCaseTests.kt index 757b5cba..0bf9c626 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCaseTests.kt @@ -6,10 +6,10 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.spot.exception.SpotNotFoundException +import team.comit.simtong.domain.spot.exception.SpotExceptions import team.comit.simtong.domain.spot.model.Spot import team.comit.simtong.domain.user.dto.QueryAdminInfoResponse -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.QueryUserPort @@ -120,7 +120,7 @@ class QueryAdminInfoUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { queryAdminInfoUseCase.execute() } } @@ -138,7 +138,7 @@ class QueryAdminInfoUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { queryAdminInfoUseCase.execute() } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCaseTests.kt index d99983a3..706bd791 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCaseTests.kt @@ -6,10 +6,11 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.spot.exception.SpotNotFoundException +import team.comit.simtong.domain.schedule.exception.ScheduleExceptions +import team.comit.simtong.domain.spot.exception.SpotExceptions import team.comit.simtong.domain.spot.model.Spot import team.comit.simtong.domain.user.dto.QueryUserInfoResponse -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.QueryUserPort @@ -113,7 +114,7 @@ class QueryUserInfoUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { queryUserInfoUseCase.execute() } } @@ -131,7 +132,7 @@ class QueryUserInfoUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { queryUserInfoUseCase.execute() } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCaseTests.kt index 8b2dfb8b..90ccf977 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCaseTests.kt @@ -6,11 +6,10 @@ import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.given import org.springframework.boot.test.mock.mockito.MockBean -import team.comit.simtong.domain.auth.exception.RequiredNewEmailAuthenticationException -import team.comit.simtong.domain.auth.exception.UncertifiedEmailException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.auth.model.AuthCodeLimit import team.comit.simtong.domain.user.dto.ResetPasswordRequest -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.CommandUserPort @@ -114,7 +113,7 @@ class ResetPasswordUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { resetPasswordUseCase.execute(requestStub) } } @@ -126,7 +125,7 @@ class ResetPasswordUseCaseTests { .willReturn(uncertifiedAuthCodeLimit) // when & then - assertThrows { + assertThrows { resetPasswordUseCase.execute(requestStub) } } @@ -141,7 +140,7 @@ class ResetPasswordUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { resetPasswordUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCaseTests.kt index eb263681..9a11128a 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCaseTests.kt @@ -8,16 +8,15 @@ import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean import team.comit.simtong.domain.auth.dto.TokenResponse import team.comit.simtong.domain.user.dto.SignInRequest -import team.comit.simtong.domain.user.exception.DifferentPasswordException -import team.comit.simtong.domain.user.exception.DifferentPermissionAccountException -import team.comit.simtong.domain.user.exception.UserNotFoundException +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserJwtPort import team.comit.simtong.domain.user.spi.UserSecurityPort import team.comit.simtong.global.annotation.SimtongTest -import java.util.* +import java.util.UUID +import java.util.Date @SimtongTest class SignInUseCaseTests { @@ -114,7 +113,7 @@ class SignInUseCaseTests { .willReturn(false) // when & then - assertThrows { + assertThrows { signInUseCase.execute(requestStub) } } @@ -126,7 +125,7 @@ class SignInUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { signInUseCase.execute(requestStub) } } @@ -138,7 +137,7 @@ class SignInUseCaseTests { .willReturn(adminStub) // when & then - assertThrows { + assertThrows { signInUseCase.execute(requestStub) } } diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCaseTests.kt index 5181d881..3ae7c57b 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCaseTests.kt @@ -7,15 +7,13 @@ import org.junit.jupiter.api.assertThrows import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean import team.comit.simtong.domain.auth.dto.TokenResponse -import team.comit.simtong.domain.auth.exception.RequiredNewEmailAuthenticationException -import team.comit.simtong.domain.auth.exception.UncertifiedEmailException -import team.comit.simtong.domain.auth.exception.UsedEmailException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.auth.model.AuthCodeLimit -import team.comit.simtong.domain.file.exception.InvalidEmployeeException +import team.comit.simtong.domain.file.exception.FileExceptions import team.comit.simtong.domain.file.model.EmployeeCertificate -import team.comit.simtong.domain.spot.exception.SpotNotFoundException +import team.comit.simtong.domain.spot.exception.SpotExceptions import team.comit.simtong.domain.spot.model.Spot -import team.comit.simtong.domain.team.exception.TeamNotFoundException +import team.comit.simtong.domain.team.exception.TeamExceptions import team.comit.simtong.domain.team.model.Team import team.comit.simtong.domain.user.dto.SignUpRequest import team.comit.simtong.domain.user.model.Authority @@ -277,7 +275,7 @@ class SignUpUseCaseTests { .willReturn(unVerifiedAuthCodeLimitStub) // when & then - assertThrows { + assertThrows { signUpUseCase.execute(requestStub) } } @@ -289,7 +287,7 @@ class SignUpUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { signUpUseCase.execute(requestStub) } } @@ -304,7 +302,7 @@ class SignUpUseCaseTests { .willReturn(true) // when & then - assertThrows { + assertThrows { signUpUseCase.execute(requestStub) } } @@ -322,7 +320,7 @@ class SignUpUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { signUpUseCase.execute(requestStub) } } @@ -343,7 +341,7 @@ class SignUpUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { signUpUseCase.execute(requestStub) } } @@ -367,7 +365,7 @@ class SignUpUseCaseTests { .willReturn(null) // when & then - assertThrows { + assertThrows { signUpUseCase.execute(requestStub) } } diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/error/AuthErrorCode.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/error/AuthErrorCode.kt deleted file mode 100644 index 12bb4f06..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/error/AuthErrorCode.kt +++ /dev/null @@ -1,34 +0,0 @@ -package team.comit.simtong.domain.auth.error - -import team.comit.simtong.global.error.ErrorProperty - -/** - * - * Auth에 관련된 Error를 관리하는 AuthErrorCode - * - * @author Chokyunghyeon - * @date 2022/09/09 - * @version 1.0.0 - **/ -enum class AuthErrorCode( - private val status: Int, - private val message: String -): ErrorProperty { - - // 401 - AUTHCODE_MISMATCH(401, "인증 코드 불일치"), - UNCERTIFIED_EMAIL(401, "인증되지 않은 이메일"), - REFRESH_TOKEN_NOT_FOUND(401, "토큰을 찾을 수 없음"), - REQUIRED_NEW_EMAIL_AUTHENTICATION(401, "새로운 이메일 인증 필요"), - - // 409 - ALREADY_USED_EMAIL(409, "이미 사용된 이메일"), - ALREADY_USED_NICKNAME(409, "이미 사용된 닉네임"), - ALREADY_CERTIFIED_EMAIL(409, "이미 인증된 이메일"), - - // 429 - EXCEEDED_SEND_AUTHCODE_REQUEST(429, "인증 코드 발송 횟수 초과"); - - override fun message(): String = message - override fun status(): Int = status -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/AuthCodeMismatchException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/AuthCodeMismatchException.kt deleted file mode 100644 index aeba3503..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/AuthCodeMismatchException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.auth.exception - -import team.comit.simtong.domain.auth.error.AuthErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * AuthCode Mismatch Error를 발생시키는 AuthCodeMismatchException - * - * @author Chokyunghyeon - * @date 2022/09/25 - * @version 1.0.0 - **/ -class AuthCodeMismatchException private constructor(): BusinessException(AuthErrorCode.AUTHCODE_MISMATCH) { - - companion object { - @JvmField - val EXCEPTION = AuthCodeMismatchException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/AuthExceptions.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/AuthExceptions.kt new file mode 100644 index 00000000..e6f561d2 --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/AuthExceptions.kt @@ -0,0 +1,42 @@ +package team.comit.simtong.domain.auth.exception + +import team.comit.simtong.global.exception.BusinessException + +/** + * + * Auth Domain에서 발생하는 Exception을 관리하는 AuthExceptions + * + * @author kimbeomjin + * @date 2022/12/16 + * @version 1.0.0 + **/ +sealed class AuthExceptions( + override val status: Int, + override val message: String +) : BusinessException(status, message) { + + // 401 + class DifferentAuthCode(message: String = DIFFERENT_AUTH_CODE) : AuthExceptions(401, message) + class UncertifiedEmail(message: String = UNCERTIFIED_EMAIL) : AuthExceptions(401, message) + class RequiredNewEmailAuthentication(message: String = REQUIRED_NEW_EMAIL_AUTHENTICATION) : AuthExceptions(401, message) + + // 404 + class RefreshTokenNotFound(message: String = REFRESH_TOKEN_NOT_FOUND) : AuthExceptions(404, message) + + // 409 + class AlreadyUsedEmail(message: String = ALREADY_USED_EMAIL) : AuthExceptions(409, message) + class AlreadyCertifiedEmail(message: String = ALREADY_CERTIFIED_EMAIL) : AuthExceptions(409, message) + + // 429 + class ExceededSendAuthCodeRequest(message: String = EXCEEDED_SEND_AUTH_CODE_REQUEST) : AuthExceptions(429, message) + + companion object { + private const val DIFFERENT_AUTH_CODE = "인증 코드가 일치하지 않습니다." + private const val UNCERTIFIED_EMAIL = "인증되지 않은 이메일입니다." + private const val REQUIRED_NEW_EMAIL_AUTHENTICATION = "새로운 이메일 인증이 필요합니다." + private const val REFRESH_TOKEN_NOT_FOUND = "리프레시 토큰을 찾을 수 없습니다." + private const val ALREADY_USED_EMAIL = "이미 사용중인 이메일입니다." + private const val ALREADY_CERTIFIED_EMAIL = "이미 인증된 이메일입니다." + private const val EXCEEDED_SEND_AUTH_CODE_REQUEST = "인증 코드 발송 횟수를 초과하였습니다." + } +} diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/CertifiedEmailException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/CertifiedEmailException.kt deleted file mode 100644 index 705b7a93..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/CertifiedEmailException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.auth.exception - -import team.comit.simtong.domain.auth.error.AuthErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Already Certified Email Error를 발생시키는 CertifiedEmailException - * - * @author Chokyunghyeon - * @date 2022/09/24 - * @version 1.0.0 - **/ -class CertifiedEmailException private constructor(): BusinessException(AuthErrorCode.ALREADY_CERTIFIED_EMAIL) { - - companion object { - @JvmField - val EXCEPTION = CertifiedEmailException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/ExceededSendAuthCodeRequestException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/ExceededSendAuthCodeRequestException.kt deleted file mode 100644 index 779a1ff6..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/ExceededSendAuthCodeRequestException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.auth.exception - -import team.comit.simtong.domain.auth.error.AuthErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Exceeded Send AuthCode Request Error를 발생시키는 ExceededSendAuthCodeRequestException - * - * @author Chokyunghyeon - * @date 2022/09/24 - * @version 1.0.0 - **/ -class ExceededSendAuthCodeRequestException private constructor(): BusinessException(AuthErrorCode.EXCEEDED_SEND_AUTHCODE_REQUEST) { - - companion object { - @JvmField - val EXCEPTION = ExceededSendAuthCodeRequestException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/RefreshTokenNotFoundException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/RefreshTokenNotFoundException.kt deleted file mode 100644 index 4ade6d7c..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/RefreshTokenNotFoundException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.auth.exception - -import team.comit.simtong.domain.auth.error.AuthErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Refresh Not Found Error를 발생시키는 RefreshTokenNotFoundException - * - * @author Chokyunghyeon - * @date 2022/09/18 - * @version 1.0.0 - **/ -class RefreshTokenNotFoundException private constructor(): BusinessException(AuthErrorCode.REFRESH_TOKEN_NOT_FOUND) { - - companion object { - @JvmField - val EXCEPTION = RefreshTokenNotFoundException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/RequiredNewEmailAuthenticationException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/RequiredNewEmailAuthenticationException.kt deleted file mode 100644 index 1ad85159..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/RequiredNewEmailAuthenticationException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.auth.exception - -import team.comit.simtong.domain.auth.error.AuthErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Required New Email Authentication Error를 발생시키는 RequiredNewEmailAuthenticationException - * - * @author Chokyunghyeon - * @date 2022/10/10 - * @version 1.0.0 - **/ -class RequiredNewEmailAuthenticationException private constructor() : BusinessException(AuthErrorCode.REQUIRED_NEW_EMAIL_AUTHENTICATION) { - - companion object { - @JvmField - val EXCEPTION = RequiredNewEmailAuthenticationException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/UncertifiedEmailException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/UncertifiedEmailException.kt deleted file mode 100644 index 1e7aea04..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/UncertifiedEmailException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.auth.exception - -import team.comit.simtong.domain.auth.error.AuthErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Uncertified Email Error를 발생시키는 UncertifiedEmailException - * - * @author Chokyunghyeon - * @date 2022/09/09 - * @version 1.0.0 - **/ -class UncertifiedEmailException private constructor(): BusinessException(AuthErrorCode.UNCERTIFIED_EMAIL) { - - companion object { - @JvmField - val EXCEPTION = UncertifiedEmailException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/UsedEmailException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/UsedEmailException.kt deleted file mode 100644 index af55d445..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/UsedEmailException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.auth.exception - -import team.comit.simtong.domain.auth.error.AuthErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Already Used Email Error를 발생시키는 UsedEmailException - * - * @author Chokyunghyeon - * @date 2022/09/04 - * @version 1.0.0 - **/ -class UsedEmailException private constructor(): BusinessException(AuthErrorCode.ALREADY_USED_EMAIL) { - - companion object { - @JvmField - val EXCEPTION = UsedEmailException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/UsedNicknameException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/UsedNicknameException.kt deleted file mode 100644 index fe5a6497..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/exception/UsedNicknameException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.auth.exception - -import team.comit.simtong.domain.auth.error.AuthErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Already Used Nickname Error를 발생시키는 UsedNicknameException - * - * @author Chokyunghyeon - * @date 2022/10/03 - * @version 1.0.0 - **/ -class UsedNicknameException private constructor() : BusinessException(AuthErrorCode.ALREADY_USED_NICKNAME) { - - companion object { - @JvmField - val EXCEPTION = UsedNicknameException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/model/AuthCodeLimit.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/model/AuthCodeLimit.kt index ae660526..8f50c4e3 100644 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/model/AuthCodeLimit.kt +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/auth/model/AuthCodeLimit.kt @@ -1,6 +1,6 @@ package team.comit.simtong.domain.auth.model -import team.comit.simtong.domain.auth.exception.ExceededSendAuthCodeRequestException +import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.global.DomainProperties.getProperty import team.comit.simtong.global.DomainPropertiesPrefix import team.comit.simtong.global.annotation.Aggregate @@ -53,7 +53,7 @@ data class AuthCodeLimit @Default constructor( fun increaseCount(): AuthCodeLimit { if (attemptCount >= MAX_ATTEMPT_COUNT) { - throw ExceededSendAuthCodeRequestException.EXCEPTION + throw AuthExceptions.ExceededSendAuthCodeRequest() } return AuthCodeLimit( diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/error/FileErrorCode.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/error/FileErrorCode.kt deleted file mode 100644 index 22f7a420..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/error/FileErrorCode.kt +++ /dev/null @@ -1,28 +0,0 @@ -package team.comit.simtong.domain.file.error - -import team.comit.simtong.global.error.ErrorProperty - -/** - * - * File Error를 관리하는 FileErrorCode - * - * @author Chokyunghyeon - * @date 2022/09/08 - * @version 1.0.0 - **/ -enum class FileErrorCode( - private val status: Int, - private val message: String -) : ErrorProperty { - - NOT_VALID_CONTENT(400, "파일의 내용이 올바르지 않음"), - - INVALID_EMPLOYEE(401, "일치하는 사원 정보가 존재하지 않음"), - - NOT_FOUND_FILE_PATH(404, "업로드되지 않은 파일 경로"), - - IO_INTERRUPTED(500, "파일 입출력 처리 중단"); - - override fun status(): Int = status - override fun message(): String = message -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/FileExceptions.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/FileExceptions.kt new file mode 100644 index 00000000..bbce3c4f --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/FileExceptions.kt @@ -0,0 +1,36 @@ +package team.comit.simtong.domain.file.exception + +import team.comit.simtong.global.exception.BusinessException + +/** + * + * File Domain에서 발생하는 Exception을 관리하는 FileExceptions + * + * @author kimbeomjin + * @date 2022/12/16 + * @version 1.0.0 + **/ +sealed class FileExceptions( + override val status: Int, + override val message: String +) : BusinessException(status, message) { + + // 400 + class NotValidContent(message: String = NOT_VALID_CONTENT) : FileExceptions(400, message) + + // 401 + class NotExistsEmployee(message: String = NOT_EXISTS_EMPLOYEE) : FileExceptions(401, message) + + // 404 + class PathNotFound(message: String = PATH_NOT_FOUND) : FileExceptions(404, message) + + // 500 + class IOInterrupted(message: String = IO_INTERRUPTED) : FileExceptions(500, message) + + companion object { + private const val NOT_VALID_CONTENT = "파일의 내용이 올바르지 않습니다." + private const val NOT_EXISTS_EMPLOYEE = "일치하는 사원 정보가 존재하지 않습니다." + private const val PATH_NOT_FOUND = "휴무일을 찾을 수 없습니다." + private const val IO_INTERRUPTED = "파일 입출력 처리가 중단되었습니다." + } +} diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/FileIOInterruptedException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/FileIOInterruptedException.kt deleted file mode 100644 index b5db54c2..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/FileIOInterruptedException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.file.exception - -import team.comit.simtong.domain.file.error.FileErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * 파일 입출력 처리 오류를 발생시키는 FileIOInterruptedException - * - * @author Chokyunghyeon - * @date 2022/09/07 - * @version 1.0.0 - **/ -class FileIOInterruptedException private constructor() : BusinessException(FileErrorCode.IO_INTERRUPTED) { - - companion object { - @JvmField - val EXCEPTION = FileIOInterruptedException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/FileNotValidContentException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/FileNotValidContentException.kt deleted file mode 100644 index 6d16da06..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/FileNotValidContentException.kt +++ /dev/null @@ -1,20 +0,0 @@ -package team.comit.simtong.domain.file.exception - -import team.comit.simtong.domain.file.error.FileErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * 파일의 내용이 올바르지 않음 에러를 발생시키는 FileNotValidContentException - * - * @author Chokyunghyeon - * @date 2022/12/07 - * @version 1.0.0 - **/ -class FileNotValidContentException private constructor() : BusinessException(FileErrorCode.NOT_VALID_CONTENT) { - - companion object { - @JvmField - val EXCEPTION = FileNotValidContentException() - } -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/InvalidEmployeeException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/InvalidEmployeeException.kt deleted file mode 100644 index 1c1e3ecc..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/InvalidEmployeeException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.file.exception - -import team.comit.simtong.domain.file.error.FileErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * DB에 저장된 일치하는 사원이 없는 경우 발생시키는 InvalidEmployeeException - * - * @author kimbeomjin - * @date 2022/12/07 - * @version 1.0.0 - **/ -class InvalidEmployeeException private constructor() : BusinessException(FileErrorCode.INVALID_EMPLOYEE) { - - companion object { - @JvmField - val EXCEPTION = InvalidEmployeeException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/NotFoundFilePathException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/NotFoundFilePathException.kt deleted file mode 100644 index b6e40c82..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/file/exception/NotFoundFilePathException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.file.exception - -import team.comit.simtong.domain.file.error.FileErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * 파일 경로를 찾을 수 없음 에러를 발생시키는 NotFoundFilePathException - * - * @author Chokyunghyeon - * @date 2022/12/08 - * @version 1.0.0 - **/ -class NotFoundFilePathException private constructor() : BusinessException(FileErrorCode.NOT_FOUND_FILE_PATH) { - - companion object { - @JvmField - val EXCEPTION = NotFoundFilePathException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/error/HolidayErrorCode.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/error/HolidayErrorCode.kt deleted file mode 100644 index e1ad1dd8..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/error/HolidayErrorCode.kt +++ /dev/null @@ -1,25 +0,0 @@ -package team.comit.simtong.domain.holiday.error - -import team.comit.simtong.global.error.ErrorProperty - -/** - * - * 휴무일에 관한 Error를 관리하는 HolidayErrorCode - * - * @author Chokyunghyeon - * @date 2022/12/02 - * @version 1.0.0 - **/ -enum class HolidayErrorCode( - private val status: Int, - private val message: String -) : ErrorProperty { - - HOLIDAY_NOT_FOUND(404, "휴무일을 찾을 수 없습니다."), - - WEEK_HOLIDAY_LIMIT_EXCESS(409, "주 휴무일 지정 한도 초과"); - - override fun status(): Int = status - - override fun message(): String = message -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/exception/HolidayExceptions.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/exception/HolidayExceptions.kt new file mode 100644 index 00000000..393d9634 --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/exception/HolidayExceptions.kt @@ -0,0 +1,28 @@ +package team.comit.simtong.domain.holiday.exception + +import team.comit.simtong.global.exception.BusinessException + +/** + * + * Holiday Domain에서 발생하는 Exception을 관리하는 HolidayExceptions + * + * @author kimbeomjin + * @date 2022/12/16 + * @version 1.0.0 + **/ +sealed class HolidayExceptions( + override val status: Int, + override val message: String +) : BusinessException(status, message) { + + // 404 + class NotFound(message: String = NOT_FOUND) : HolidayExceptions(404, message) + + // 409 + class WeekHolidayLimitExcess(message: String = WEEK_HOLIDAY_LIMIT_EXCESS) : HolidayExceptions(409, message) + + companion object { + private const val NOT_FOUND = "휴무일을 찾을 수 없습니다." + private const val WEEK_HOLIDAY_LIMIT_EXCESS = "주 휴무일 지정 한도 초과" + } +} diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/exception/HolidayNotFoundException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/exception/HolidayNotFoundException.kt deleted file mode 100644 index 6de2c379..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/exception/HolidayNotFoundException.kt +++ /dev/null @@ -1,20 +0,0 @@ -package team.comit.simtong.domain.holiday.exception - -import team.comit.simtong.domain.holiday.error.HolidayErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * 휴무일을 찾을 수 없음 에러를 발생시키는 HolidayNotFoundException - * - * @author Chokyunghyeon - * @date 2022/12/04 - * @version 1.0.0 - **/ -class HolidayNotFoundException private constructor() : BusinessException(HolidayErrorCode.HOLIDAY_NOT_FOUND) { - - companion object { - @JvmField - val EXCEPTION = HolidayNotFoundException() - } -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/exception/WeekHolidayLimitExcessException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/exception/WeekHolidayLimitExcessException.kt deleted file mode 100644 index 1a602ed5..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/holiday/exception/WeekHolidayLimitExcessException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.holiday.exception - -import team.comit.simtong.domain.holiday.error.HolidayErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * 주 휴무일 한도 초과 에러를 발생시키는 WeekHolidayLimitExcessException - * - * @author Chokyunghyeon - * @date 2022/12/03 - * @version 1.0.0 - **/ -class WeekHolidayLimitExcessException private constructor() : BusinessException(HolidayErrorCode.WEEK_HOLIDAY_LIMIT_EXCESS) { - - companion object { - @JvmField - val EXCEPTION = WeekHolidayLimitExcessException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/error/MenuErrorCode.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/error/MenuErrorCode.kt deleted file mode 100644 index ccd3a5dc..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/error/MenuErrorCode.kt +++ /dev/null @@ -1,25 +0,0 @@ -package team.comit.simtong.domain.menu.error - -import team.comit.simtong.global.error.ErrorProperty - -/** - * - * Menu에 대해 발생하는 Error를 관리하는 MenuErrorCode - * - * @author kimbeomjin - * @date 2022/09/20 - * @version 1.0.0 - **/ -enum class MenuErrorCode( - private val status: Int, - private val message: String -) : ErrorProperty { - - ALREADY_EXISTS_SAME_MONTH(400, "같은 달에 메뉴가 이미 존재합니다.") - ; - - override fun status(): Int = status - - override fun message(): String = message - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/exception/MenuAlreadyExistsSameMonthException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/exception/MenuAlreadyExistsSameMonthException.kt deleted file mode 100644 index b4669115..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/exception/MenuAlreadyExistsSameMonthException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.menu.exception - -import team.comit.simtong.domain.menu.error.MenuErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * 같은 달에 메뉴가 이미 존재하는 경우 발생시키는 MenuAlreadyExistsSameMonthException - * - * @author kimbeomjin - * @date 2022/12/11 - * @version 1.0.0 - **/ -class MenuAlreadyExistsSameMonthException private constructor() : - BusinessException(MenuErrorCode.ALREADY_EXISTS_SAME_MONTH) { - - companion object { - @JvmField - val EXCEPTION = MenuAlreadyExistsSameMonthException() - } -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/exception/MenuExceptions.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/exception/MenuExceptions.kt new file mode 100644 index 00000000..32f1bd97 --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/exception/MenuExceptions.kt @@ -0,0 +1,24 @@ +package team.comit.simtong.domain.menu.exception + +import team.comit.simtong.global.exception.BusinessException + +/** + * + * Menu Domain에서 발생하는 Exception을 관리하는 MenuExceptions + * + * @author kimbeomjin + * @date 2022/12/17 + * @version 1.0.0 + **/ +sealed class MenuExceptions( + override val status: Int, + override val message: String +) : BusinessException(status, message) { + + // 409 + class AlreadyExistsSameMonth(message: String = ALREADY_EXISTS_SAME_MONTH) : MenuExceptions(409, message) + + companion object { + private const val ALREADY_EXISTS_SAME_MONTH = "같은 달에 메뉴가 이미 존재합니다." + } +} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/error/ScheduleErrorCode.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/error/ScheduleErrorCode.kt deleted file mode 100644 index 314c4928..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/error/ScheduleErrorCode.kt +++ /dev/null @@ -1,30 +0,0 @@ -package team.comit.simtong.domain.schedule.error - -import team.comit.simtong.global.error.ErrorProperty - -/** - * - * 일정에 대해 발생하는 Error를 관리하는 ScheduleErrorCode - * - * @author Chokyunghyeon - * @date 2022/11/21 - * @version 1.0.0 - **/ -enum class ScheduleErrorCode( - private val status: Int, - private val message: String -) : ErrorProperty { - - // 401 - DIFFERENT_SCHEDULE_SCOPE(401, "일정의 범위가 다름"), - - // 403 - NOT_SCHEDULE_OWNER(403, "일정의 소유자가 아님"), - - // 404 - SCHEDULE_NOT_FOUND(404, "일정을 찾을 수 없음"); - - override fun status() = status - - override fun message() = message -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/DifferentScopeException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/DifferentScopeException.kt deleted file mode 100644 index 0ea354c7..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/DifferentScopeException.kt +++ /dev/null @@ -1,20 +0,0 @@ -package team.comit.simtong.domain.schedule.exception - -import team.comit.simtong.domain.schedule.error.ScheduleErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Different Schedule Scope Error를 발생시키는 DifferentScopeException - * - * @author kimbeomjin - * @date 2022/12/03 - * @version 1.0.0 - **/ -class DifferentScopeException private constructor(): BusinessException(ScheduleErrorCode.DIFFERENT_SCHEDULE_SCOPE) { - - companion object { - @JvmField - val EXCEPTION = DifferentScopeException() - } -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/NotScheduleOwnerException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/NotScheduleOwnerException.kt deleted file mode 100644 index 7d344cc5..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/NotScheduleOwnerException.kt +++ /dev/null @@ -1,20 +0,0 @@ -package team.comit.simtong.domain.schedule.exception - -import team.comit.simtong.domain.schedule.error.ScheduleErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Not Schedule Owner Error를 발생시키는 NotScheduleOwnerException - * - * @author Chokyunghyeon - * @date 2022/11/27 - * @version 1.0.0 - **/ -class NotScheduleOwnerException private constructor() : BusinessException(ScheduleErrorCode.NOT_SCHEDULE_OWNER) { - - companion object { - @JvmField - val EXCEPTION = NotScheduleOwnerException() - } -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/ScheduleExceptions.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/ScheduleExceptions.kt new file mode 100644 index 00000000..71cf6a7d --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/ScheduleExceptions.kt @@ -0,0 +1,32 @@ +package team.comit.simtong.domain.schedule.exception + +import team.comit.simtong.global.exception.BusinessException + +/** + * + * Schedule Domain에서 발생하는 Exception을 관리하는 ScheduleExceptions + * + * @author kimbeomjin + * @date 2022/12/16 + * @version 1.0.0 + **/ +sealed class ScheduleExceptions( + override val status: Int, + override val message: String +) : BusinessException(status, message) { + + // 401 + class DifferentScope(message: String = DIFFERENT_SCOPE) : ScheduleExceptions(401, message) + + // 403 + class NotScheduleOwner(message: String = NOT_SCHEDULE_OWNER) : ScheduleExceptions(403, message) + + // 404 + class NotFound(message: String = NOT_FOUND) : ScheduleExceptions(404, message) + + companion object { + private const val DIFFERENT_SCOPE = "일정의 범위가 다릅니다." + private const val NOT_SCHEDULE_OWNER = "일정의 소유자가 아닙니다." + private const val NOT_FOUND = "일정을 찾을 수 없습니다." + } +} diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/ScheduleNotFoundException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/ScheduleNotFoundException.kt deleted file mode 100644 index b9897414..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/schedule/exception/ScheduleNotFoundException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.schedule.exception - -import team.comit.simtong.domain.schedule.error.ScheduleErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Schedule Not Found Error를 발생시키는 ScheduleNotFoundException - * - * @author Chokyunghyeon - * @date 2022/11/22 - * @version 1.0.0 - **/ -class ScheduleNotFoundException private constructor() : BusinessException(ScheduleErrorCode.SCHEDULE_NOT_FOUND) { - - companion object { - @JvmField - val EXCEPTION = ScheduleNotFoundException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/spot/error/SpotErrorCode.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/spot/error/SpotErrorCode.kt deleted file mode 100644 index 401d98d1..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/spot/error/SpotErrorCode.kt +++ /dev/null @@ -1,24 +0,0 @@ -package team.comit.simtong.domain.spot.error - -import team.comit.simtong.global.error.ErrorProperty - -/** - * - * Spot Error를 관리하는 SpotErrorCode - * - * @author Chokyunghyeon - * @date 2022/09/18 - * @version 1.0.0 - **/ -enum class SpotErrorCode( - private val status: Int, - private val message: String -) : ErrorProperty { - - // 404 - SPOT_NOT_FOUND(404, "지점을 찾을 수 없음"); - - override fun status(): Int = status - - override fun message(): String = message -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/spot/exception/SpotExceptions.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/spot/exception/SpotExceptions.kt new file mode 100644 index 00000000..0abc00d5 --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/spot/exception/SpotExceptions.kt @@ -0,0 +1,24 @@ +package team.comit.simtong.domain.spot.exception + +import team.comit.simtong.global.exception.BusinessException + +/** + * + * Spot Domain에서 발생하는 Exception을 관리하는 SpotExceptions + * + * @author kimbeomjin + * @date 2022/12/16 + * @version 1.0.0 + **/ +sealed class SpotExceptions( + override val status: Int, + override val message: String +) : BusinessException(status, message) { + + // 404 + class NotFound(message: String = NOT_FOUND) : SpotExceptions(404, message) + + companion object { + private const val NOT_FOUND = "지점을 찾을 수 없습니다." + } +} diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/spot/exception/SpotNotFoundException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/spot/exception/SpotNotFoundException.kt deleted file mode 100644 index 6a6db5e6..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/spot/exception/SpotNotFoundException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.spot.exception - -import team.comit.simtong.domain.spot.error.SpotErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Spot Not Found Error를 발생시키는 SpotNotFoundException - * - * @author Chokyunghyeon - * @date 2022/09/18 - * @version 1.0.0 - **/ -class SpotNotFoundException private constructor(): BusinessException(SpotErrorCode.SPOT_NOT_FOUND) { - - companion object { - @JvmField - val EXCEPTION = SpotNotFoundException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/team/error/TeamErrorCode.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/team/error/TeamErrorCode.kt deleted file mode 100644 index d3caec61..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/team/error/TeamErrorCode.kt +++ /dev/null @@ -1,25 +0,0 @@ -package team.comit.simtong.domain.team.error - -import team.comit.simtong.global.error.ErrorProperty - -/** - * - * Team에 대해 발생하는 Error를 관리하는 TeamErrorCode - * - * @author Chokyunghyeon - * @date 2022/09/18 - * @version 1.0.0 - **/ -enum class TeamErrorCode( - private val status: Int, - private val message: String -): ErrorProperty { - - // 404 - TEAM_NOT_FOUND(404, "팀을 찾을 수 없음"); - - override fun status(): Int = status - - override fun message(): String = message - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/team/exception/TeamExceptions.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/team/exception/TeamExceptions.kt new file mode 100644 index 00000000..9e71a1d5 --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/team/exception/TeamExceptions.kt @@ -0,0 +1,24 @@ +package team.comit.simtong.domain.team.exception + +import team.comit.simtong.global.exception.BusinessException + +/** + * + * Team Domain에서 발생하는 Exception을 관리하는 TeamExceptions + * + * @author kimbeomjin + * @date 2022/12/16 + * @version 1.0.0 + **/ +sealed class TeamExceptions private constructor( + override val status: Int, + override val message: String +) : BusinessException(status, message) { + + // 404 + class NotFound(message: String = NOT_FOUND) : TeamExceptions(404, message) + + companion object { + private const val NOT_FOUND = "팀을 찾을 수 없습니다." + } +} diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/team/exception/TeamNotFoundException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/team/exception/TeamNotFoundException.kt deleted file mode 100644 index 56827342..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/team/exception/TeamNotFoundException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.team.exception - -import team.comit.simtong.domain.team.error.TeamErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Team Not Found Error를 발생시키는 TeamNotFoundException - * - * @author Chokyunghyeon - * @date 2022/09/18 - * @version 1.0.0 - **/ -class TeamNotFoundException private constructor(): BusinessException(TeamErrorCode.TEAM_NOT_FOUND) { - - companion object { - @JvmField - val EXCEPTION = TeamNotFoundException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/error/UserErrorCode.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/error/UserErrorCode.kt deleted file mode 100644 index c9227acf..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/error/UserErrorCode.kt +++ /dev/null @@ -1,33 +0,0 @@ -package team.comit.simtong.domain.user.error - -import team.comit.simtong.global.error.ErrorProperty - -/** - * - * User에 대해 발생하는 Error를 관리하는 UserErrorCode - * - * @author Chokyunghyeon - * @author kimbeomjin - * @date 2022/09/04 - * @version 1.0.0 - **/ -enum class UserErrorCode( - private val status: Int, - private val message: String -): ErrorProperty { - - // 401 - DIFFERENT_PASSWORD(401, "비밀번호가 일치하지 않음"), - DIFFERENT_PERMISSION_ACCOUNT(401, "다른 권한의 계정"), - - // 403 - NOT_ENOUGH_PERMISSION(403, "권한이 부족한 동작"), - - // 404 - USER_NOT_FOUND(404, "유저를 찾을 수 없음"); - - override fun status(): Int = status - - override fun message(): String = message - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/DifferentPasswordException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/DifferentPasswordException.kt deleted file mode 100644 index 4fa7cd03..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/DifferentPasswordException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.user.exception - -import team.comit.simtong.domain.user.error.UserErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Different Password Error를 발생시키는 DifferentPasswordException - * - * @author kimbeomjin - * @date 2022/09/08 - * @version 1.0.0 - **/ -class DifferentPasswordException private constructor() : BusinessException(UserErrorCode.DIFFERENT_PASSWORD) { - - companion object { - @JvmField - val EXCEPTION = DifferentPasswordException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/DifferentPermissionAccountException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/DifferentPermissionAccountException.kt deleted file mode 100644 index 47a30fe5..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/DifferentPermissionAccountException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.user.exception - -import team.comit.simtong.domain.user.error.UserErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * 다른 권한의 계정 에러를 발생시키는 DifferentPermissionAccountException - * - * @author Chokyunghyeon - * @date 2022/10/12 - * @version 1.0.0 - **/ -class DifferentPermissionAccountException private constructor() : BusinessException(UserErrorCode.DIFFERENT_PERMISSION_ACCOUNT) { - - companion object { - @JvmField - val EXCEPTION = DifferentPermissionAccountException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/NotEnoughPermissionException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/NotEnoughPermissionException.kt deleted file mode 100644 index f9bc63d6..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/NotEnoughPermissionException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.user.exception - -import team.comit.simtong.domain.user.error.UserErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * Not Enough Permission Error를 발생시키는 NotEnoughPermissionException - * - * @author Chokyunghyeon - * @date 2022/11/21 - * @version 1.0.0 - **/ -class NotEnoughPermissionException private constructor() : BusinessException(UserErrorCode.NOT_ENOUGH_PERMISSION) { - - companion object { - @JvmField - val EXCEPTION = NotEnoughPermissionException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/UserExceptions.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/UserExceptions.kt new file mode 100644 index 00000000..475e60d3 --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/UserExceptions.kt @@ -0,0 +1,38 @@ +package team.comit.simtong.domain.user.exception + +import team.comit.simtong.global.exception.BusinessException + +/** + * + * User Domain에서 발생하는 Exception을 관리하는 UserExceptions + * + * @author kimbeomjin + * @date 2022/12/16 + * @version 1.0.0 + **/ +sealed class UserExceptions( + override val status: Int, + override val message: String +) : BusinessException(status, message) { + + // 401 + class DifferentPassword(message: String = DIFFERENT_SECRET) : UserExceptions(401, message) + class DifferentPermissionAccount(message: String = DIFFERENT_PERMISSION_ACCOUNT) : UserExceptions(401, message) + + // 403 + class NotEnoughPermission(message: String = NOT_ENOUGH_PERMISSION) : UserExceptions(403, message) + + // 404 + class NotFound(message: String = NOT_FOUND) : UserExceptions(404, message) + + // 409 + class AlreadyUsedNickname(message: String = ALREADY_USED_NICKNAME) : UserExceptions(409, message) + + companion object { + private const val DIFFERENT_SECRET = "비밀번호가 일치하지 않습니다." + private const val DIFFERENT_PERMISSION_ACCOUNT = "다른 권한의 계정입니다." + private const val NOT_ENOUGH_PERMISSION = "권한이 부족한 동작입니다." + private const val NOT_FOUND = "사용자를 찾을 수 없습니다." + private const val ALREADY_USED_NICKNAME = "이미 사용중인 닉네임입니다." + } +} diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/UserNotFoundException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/UserNotFoundException.kt deleted file mode 100644 index 2a400b46..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/exception/UserNotFoundException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.user.exception - -import team.comit.simtong.domain.user.error.UserErrorCode -import team.comit.simtong.global.error.BusinessException - -/** - * - * User Not Found Error를 발생시키는 UserNotFoundException - * - * @author Chokyunghyeon - * @date 2022/09/04 - * @version 1.0.0 - **/ -class UserNotFoundException private constructor(): BusinessException(UserErrorCode.USER_NOT_FOUND) { - - companion object { - @JvmField - val EXCEPTION = UserNotFoundException() - } - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/global/DomainProperties.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/global/DomainProperties.kt index 7552c645..6f66aa1f 100644 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/global/DomainProperties.kt +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/global/DomainProperties.kt @@ -1,6 +1,6 @@ package team.comit.simtong.global -import team.comit.simtong.global.exception.NotInitializationPropertiesException +import team.comit.simtong.global.exception.DomainExceptions import java.util.Properties /** @@ -14,7 +14,7 @@ import java.util.Properties object DomainProperties : Properties() { override fun getProperty(key: String): String { - return super.getProperty(key) ?: throw NotInitializationPropertiesException.EXCEPTION + return super.getProperty(key) ?: throw DomainExceptions.NotInitializationProperties() } } \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/global/error/DomainErrorCode.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/global/error/DomainErrorCode.kt deleted file mode 100644 index e1457ffd..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/global/error/DomainErrorCode.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.global.error - -/** - * - * Domain에서 발생하는 ErrorCode를 관리하는 DomainErrorCode - * - * @author Chokyunghyeon - * @date 2022/11/26 - * @version 1.0.0 - **/ -enum class DomainErrorCode( - private val status: Int, - private val message: String -) : ErrorProperty { - - NOT_INITIALIZATION_PROPERTIES(500, "Domain Properties 초기화 실패"); - - override fun message() = message - - override fun status() = status -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/global/error/ErrorProperty.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/global/error/ErrorProperty.kt deleted file mode 100644 index d8e3d08b..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/global/error/ErrorProperty.kt +++ /dev/null @@ -1,17 +0,0 @@ -package team.comit.simtong.global.error - -/** - * - * 모든 도메인별 ErrorCode 형식을 맞추기 위해 사용하는 ErrorProperty - * - * @author kimbeomjin - * @date 2022/08/22 - * @version 1.0.0 - **/ -interface ErrorProperty { - - fun status(): Int - - fun message(): String - -} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/global/error/BusinessException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/global/exception/BusinessException.kt similarity index 66% rename from simtong-domain/src/main/kotlin/team/comit/simtong/global/error/BusinessException.kt rename to simtong-domain/src/main/kotlin/team/comit/simtong/global/exception/BusinessException.kt index df1d8ff6..8fbc9aae 100644 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/global/error/BusinessException.kt +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/global/exception/BusinessException.kt @@ -1,13 +1,14 @@ -package team.comit.simtong.global.error +package team.comit.simtong.global.exception /** * * 원하는 상황에 예외를 발생시켜 알맞게 처리하기 위해 RuntimeException을 상속받은 BusinessException * * @author kimbeomjin - * @date 2022/08/22 + * @date 2022/12/16 * @version 1.0.0 **/ abstract class BusinessException( - val exceptionProperty: ErrorProperty + open val status: Int, + override val message: String ) : RuntimeException() \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/global/exception/DomainExceptions.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/global/exception/DomainExceptions.kt new file mode 100644 index 00000000..99d80271 --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/global/exception/DomainExceptions.kt @@ -0,0 +1,19 @@ +package team.comit.simtong.global.exception + +/** + * + * Domain에서 발생하는 Exception을 관리하는 DomainExceptions + * + * @author kimbeomjin + * @date 2022/12/16 + * @version 1.0.0 + **/ +sealed class DomainExceptions { + + // 500 + class NotInitializationProperties(message: String = NOT_INITIALIZATION_PROPERTIES) : BusinessException(500, message) + + companion object { + private const val NOT_INITIALIZATION_PROPERTIES = "Domain Properties 초기화 실패" + } +} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/global/exception/NotInitializationPropertiesException.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/global/exception/NotInitializationPropertiesException.kt deleted file mode 100644 index 64c1883f..00000000 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/global/exception/NotInitializationPropertiesException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.global.exception - -import team.comit.simtong.global.error.BusinessException -import team.comit.simtong.global.error.DomainErrorCode - -/** - * - * Domain Properties 초기화 에러를 발생시키는 NotInitializationPropertiesException - * - * @author Chokyunghyeon - * @date 2022/11/26 - * @version 1.0.0 - **/ -internal class NotInitializationPropertiesException private constructor() : BusinessException(DomainErrorCode.NOT_INITIALIZATION_PROPERTIES) { - - companion object { - @JvmField - val EXCEPTION = NotInitializationPropertiesException() - } - -} \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/GlobalErrorCode.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/GlobalErrorCode.kt deleted file mode 100644 index 9f5163fc..00000000 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/GlobalErrorCode.kt +++ /dev/null @@ -1,25 +0,0 @@ -package team.comit.simtong.global.error - -import org.springframework.http.HttpStatus - -/** - * - * 전체적으로 발생하는 ErrorCode를 관리하는 GlobalErrorCode - * - * @author kimbeomjin - * @date 2022/08/22 - * @version 1.0.0 - **/ -enum class GlobalErrorCode( - private val status: HttpStatus, - private val message: String -) : ErrorProperty { - - BAD_REQUEST(HttpStatus.BAD_REQUEST, "잘못된 입력값"), - METHOD_NOT_ALLOWED(HttpStatus.METHOD_NOT_ALLOWED, "허용되지 않은 HTTP 메소드"), - - INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "서버 에러"); - - override fun status(): Int = status.value() - override fun message(): String = message -} \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/GlobalErrorHandler.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/GlobalErrorHandler.kt index 6be06ce1..a3804024 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/GlobalErrorHandler.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/GlobalErrorHandler.kt @@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler import org.springframework.web.bind.annotation.ResponseStatus import org.springframework.web.bind.annotation.RestControllerAdvice import team.comit.simtong.global.error.dto.ErrorResponse +import team.comit.simtong.global.exception.GlobalExceptions /** * @@ -35,6 +36,6 @@ class GlobalErrorHandler { @ExceptionHandler(IllegalArgumentException::class) @ResponseStatus(HttpStatus.BAD_REQUEST) protected fun handleIllegalArgumentException(exception: IllegalArgumentException): ErrorResponse? { - return ErrorResponse.of(GlobalErrorCode.BAD_REQUEST) + return ErrorResponse.of(GlobalExceptions.BadRequest()) } } \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/WebErrorHandler.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/WebErrorHandler.kt index 108d5812..f5fbf967 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/WebErrorHandler.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/WebErrorHandler.kt @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.ResponseStatus import org.springframework.web.bind.annotation.RestControllerAdvice import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException import team.comit.simtong.global.error.dto.ErrorResponse +import team.comit.simtong.global.exception.GlobalExceptions import javax.validation.ConstraintViolationException /** @@ -77,7 +78,7 @@ class WebErrorHandler { @ExceptionHandler(IllegalArgumentException::class) @ResponseStatus(HttpStatus.BAD_REQUEST) protected fun handleIllegalArgumentException(exception: IllegalArgumentException): ErrorResponse? { - return ErrorResponse.of(GlobalErrorCode.BAD_REQUEST) + return ErrorResponse.of(GlobalExceptions.BadRequest()) } /** @@ -88,7 +89,7 @@ class WebErrorHandler { protected fun handleHttpRequestMethodNotSupportedException( exception: HttpRequestMethodNotSupportedException ): ErrorResponse? { - return ErrorResponse.of(GlobalErrorCode.METHOD_NOT_ALLOWED) + return ErrorResponse.of(GlobalExceptions.MethodNotAllowed()) } /** @@ -100,7 +101,7 @@ class WebErrorHandler { protected fun handleHttpMessageNotReadableException( exception: HttpMessageNotReadableException ): ErrorResponse? { - return ErrorResponse.of(GlobalErrorCode.BAD_REQUEST) + return ErrorResponse.of(GlobalExceptions.BadRequest()) } /** @@ -109,7 +110,7 @@ class WebErrorHandler { @ExceptionHandler(NullPointerException::class) @ResponseStatus(HttpStatus.BAD_REQUEST) protected fun handleNestedServletException(exception: NullPointerException): ErrorResponse? { - return ErrorResponse.of(GlobalErrorCode.BAD_REQUEST) + return ErrorResponse.of(GlobalExceptions.BadRequest()) } /** diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/dto/ErrorResponse.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/dto/ErrorResponse.kt index ee125165..007b9a11 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/dto/ErrorResponse.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/error/dto/ErrorResponse.kt @@ -4,9 +4,9 @@ import org.springframework.dao.DataIntegrityViolationException import org.springframework.validation.BindingResult import org.springframework.web.bind.MissingServletRequestParameterException import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException -import team.comit.simtong.global.error.ErrorProperty -import team.comit.simtong.global.error.GlobalErrorCode -import team.comit.simtong.global.error.WebErrorProperty +import team.comit.simtong.global.exception.BusinessException +import team.comit.simtong.global.exception.GlobalExceptions +import team.comit.simtong.global.exception.WebException import javax.validation.ConstraintViolationException /** @@ -24,20 +24,20 @@ class ErrorResponse( ) { companion object { - fun of(exception: ErrorProperty) = ErrorResponse( - status = exception.status(), - message = exception.message(), + fun of(e: BusinessException) = ErrorResponse( + status = e.status, + message = e.message, fieldErrors = emptyList() ) - fun of(exception: WebErrorProperty) = ErrorResponse( - status = exception.status(), - message = exception.message(), + fun of(exception: WebException) = ErrorResponse( + status = exception.status, + message = exception.message, fieldErrors = emptyList() ) fun of(bindingResult: BindingResult): ErrorResponse = of( - exception = GlobalErrorCode.BAD_REQUEST, + exception = GlobalExceptions.BadRequest(), fieldErrors = CustomFieldError.of(bindingResult) ) @@ -50,7 +50,7 @@ class ErrorResponse( } return of( - exception = GlobalErrorCode.BAD_REQUEST, + exception = GlobalExceptions.BadRequest(), fieldErrors = fieldErrors ) } @@ -60,7 +60,7 @@ class ErrorResponse( val fieldErrors = CustomFieldError.of(exception.name, value.toString(), exception.errorCode) return of( - exception = GlobalErrorCode.BAD_REQUEST, + exception = GlobalExceptions.BadRequest(), fieldErrors = fieldErrors ) } @@ -69,19 +69,19 @@ class ErrorResponse( val fieldErrors = CustomFieldError.of(exception.parameterName, "", exception.message) return of( - exception = GlobalErrorCode.BAD_REQUEST, + exception = GlobalExceptions.BadRequest(), fieldErrors = fieldErrors ) } fun of(exception: DataIntegrityViolationException): ErrorResponse = of( - exception = GlobalErrorCode.BAD_REQUEST, + exception = GlobalExceptions.BadRequest(), fieldErrors = CustomFieldError.of("", "", exception.message ?: "") ) - private fun of(exception: ErrorProperty, fieldErrors: List) = ErrorResponse( - status = exception.status(), - message = exception.message(), + private fun of(exception: BusinessException, fieldErrors: List) = ErrorResponse( + status = exception.status, + message = exception.message, fieldErrors = fieldErrors ) } diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/exception/GlobalExceptions.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/exception/GlobalExceptions.kt new file mode 100644 index 00000000..28264d9a --- /dev/null +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/exception/GlobalExceptions.kt @@ -0,0 +1,30 @@ +package team.comit.simtong.global.exception + +/** + * + * GlobalExceptions + * + * @author kimbeomjin + * @date 2022/12/17 + * @version 1.0.0 + **/ +sealed class GlobalExceptions( + override val status: Int, + override val message: String +) : BusinessException(status, message) { + + // 400 + class BadRequest(message: String = BAD_REQUEST) : GlobalExceptions(400, message) + + // 405 + class MethodNotAllowed(message: String = METHOD_NOT_ALLOWED) : GlobalExceptions(405, message) + + // 500 + class InternalServerError(message: String = INTERNAL_SERVER_ERROR) : GlobalExceptions(500, message) + + companion object { + private const val BAD_REQUEST = "잘못된 입력값입니다." + private const val METHOD_NOT_ALLOWED = "허용되지 않은 HTTP 메소드입니다." + private const val INTERNAL_SERVER_ERROR = "서버 에러가 발생하였습니다." + } +} diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/exception/InternalServerErrorException.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/exception/InternalServerErrorException.kt deleted file mode 100644 index bc8a5643..00000000 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/exception/InternalServerErrorException.kt +++ /dev/null @@ -1,20 +0,0 @@ -package team.comit.simtong.global.exception - -import team.comit.simtong.global.error.BusinessException -import team.comit.simtong.global.error.GlobalErrorCode - -/** - * - * Internal Server Error를 발생시키는 InternalServerErrorException - * - * @author kimbeomjin - * @date 2022/08/22 - * @version 1.0.0 - **/ -class InternalServerErrorException private constructor() : BusinessException(GlobalErrorCode.INTERNAL_SERVER_ERROR) { - - companion object { - @JvmField - val EXCEPTION = InternalServerErrorException() - } -} \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/filter/ExceptionFilter.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/filter/ExceptionFilter.kt index 18cf18d1..c14a43ce 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/filter/ExceptionFilter.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/filter/ExceptionFilter.kt @@ -3,12 +3,10 @@ package team.comit.simtong.global.filter import com.fasterxml.jackson.databind.ObjectMapper import org.springframework.http.MediaType import org.springframework.web.filter.OncePerRequestFilter -import team.comit.simtong.global.error.BusinessException -import team.comit.simtong.global.error.ErrorProperty -import team.comit.simtong.global.error.WebErrorProperty -import team.comit.simtong.global.error.WebException import team.comit.simtong.global.error.dto.ErrorResponse -import team.comit.simtong.global.exception.InternalServerErrorException +import team.comit.simtong.global.exception.BusinessException +import team.comit.simtong.global.exception.GlobalExceptions +import team.comit.simtong.global.exception.WebException import java.nio.charset.StandardCharsets import javax.servlet.FilterChain import javax.servlet.http.HttpServletRequest @@ -34,23 +32,23 @@ class ExceptionFilter( try { filterChain.doFilter(request, response) } catch (e: BusinessException) { - writeErrorCode(e.exceptionProperty, response) + writeErrorCode(e, response) } catch (e: Exception) { when (e.cause) { - is BusinessException -> writeErrorCode((e.cause as BusinessException).exceptionProperty, response) - is WebException -> writeErrorCode((e.cause as WebException).exceptionProperty, response) + is BusinessException -> writeErrorCode(e.cause as BusinessException, response) + is WebException -> writeErrorCode(e.cause as WebException, response) else -> { e.printStackTrace() - writeErrorCode(InternalServerErrorException.EXCEPTION.exceptionProperty, response) + writeErrorCode(GlobalExceptions.InternalServerError(), response) } } } } - private fun writeErrorCode(exception: ErrorProperty, response: HttpServletResponse) { + private fun writeErrorCode(exception: BusinessException, response: HttpServletResponse) { response.run { characterEncoding = StandardCharsets.UTF_8.name() - status = exception.status() + status = exception.status contentType = MediaType.APPLICATION_JSON_VALUE writer.write( objectMapper.writeValueAsString( @@ -60,10 +58,10 @@ class ExceptionFilter( } } - private fun writeErrorCode(exception: WebErrorProperty, response: HttpServletResponse) { + private fun writeErrorCode(exception: WebException, response: HttpServletResponse) { response.run { characterEncoding = StandardCharsets.UTF_8.name() - status = exception.status() + status = exception.status contentType = MediaType.APPLICATION_JSON_VALUE writer.write( objectMapper.writeValueAsString( diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/error/SecurityErrorCode.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/error/SecurityErrorCode.kt deleted file mode 100644 index 536c540a..00000000 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/error/SecurityErrorCode.kt +++ /dev/null @@ -1,30 +0,0 @@ -package team.comit.simtong.global.security.error - -import org.springframework.http.HttpStatus -import team.comit.simtong.global.error.ErrorProperty - -/** - * - * Security와 관련해 발생하는 ErrorCode를 관리하는 SecurityErrorCode - * - * @author kimbeomjin - * @author Chokyunghyeon - * @date 2022/08/31 - * @version 1.0.0 - **/ -enum class SecurityErrorCode( - private val status: HttpStatus, - private val message: String -) : ErrorProperty { - - EXPIRED_TOKEN(HttpStatus.UNAUTHORIZED, "만료된 토큰"), - - UNEXPECTED_TOKEN(HttpStatus.UNAUTHORIZED, "알 수 없는 토큰"), - - WRONG_TYPE_TOKEN(HttpStatus.UNAUTHORIZED, "유형이 맞지 않는 토큰"), - - INVALID_TOKEN(HttpStatus.UNAUTHORIZED, "유효하지 않은 토큰"); - - override fun status(): Int = status.value() - override fun message(): String = message -} \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/ExpiredTokenException.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/ExpiredTokenException.kt deleted file mode 100644 index fd9e0bf8..00000000 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/ExpiredTokenException.kt +++ /dev/null @@ -1,20 +0,0 @@ -package team.comit.simtong.global.security.exception - -import team.comit.simtong.global.error.BusinessException -import team.comit.simtong.global.security.error.SecurityErrorCode - -/** - * - * Expired Token Error를 발생시키는 ExpiredTokenException - * - * @author Chokyunghyeon - * @date 2022/09/02 - * @version 1.0.0 - **/ -class ExpiredTokenException private constructor() : BusinessException(SecurityErrorCode.EXPIRED_TOKEN) { - - companion object { - @JvmField - val EXCEPTION = ExpiredTokenException() - } -} \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/InvalidTokenException.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/InvalidTokenException.kt deleted file mode 100644 index 0a520f5d..00000000 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/InvalidTokenException.kt +++ /dev/null @@ -1,20 +0,0 @@ -package team.comit.simtong.global.security.exception - -import team.comit.simtong.global.error.BusinessException -import team.comit.simtong.global.security.error.SecurityErrorCode - -/** - * - * Invalid Token Error를 발생시키는 InvalidTokenException - * - * @author kimbeomjin - * @date 2022/08/31 - * @version 1.0.0 - **/ -class InvalidTokenException private constructor() : BusinessException(SecurityErrorCode.INVALID_TOKEN) { - - companion object { - @JvmField - val EXCEPTION = InvalidTokenException() - } -} \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/SecurityExceptions.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/SecurityExceptions.kt new file mode 100644 index 00000000..7bc55516 --- /dev/null +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/SecurityExceptions.kt @@ -0,0 +1,30 @@ +package team.comit.simtong.global.security.exception + +import team.comit.simtong.global.exception.BusinessException + +/** + * + * Security에서 발생하는 Exception을 관리하는 SecurityExceptions + * + * @author kimbeomjin + * @date 2022/12/17 + * @version 1.0.0 + **/ +sealed class SecurityExceptions( + override val status: Int, + override val message: String +) : BusinessException(status, message) { + + // 401 + class ExpiredToken(message: String = EXPIRED_TOKEN) : SecurityExceptions(401, message) + class UnexpectedToken(message: String = UNEXPECTED_TOKEN) : SecurityExceptions(401, message) + class WrongTypeToken(message: String = WRONG_TYPE_TOKEN) : SecurityExceptions(401, message) + class InvalidToken(message: String = INVALID_TOKEN) : SecurityExceptions(401, message) + + companion object { + private const val EXPIRED_TOKEN = "토큰이 만료되었습니다." + private const val UNEXPECTED_TOKEN = "알 수 없는 토큰입니다." + private const val WRONG_TYPE_TOKEN = "토큰 유형이 적합하지 않습니다." + private const val INVALID_TOKEN = "토큰이 유효하지 않습니다." + } +} diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/UnexpectedTokenException.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/UnexpectedTokenException.kt deleted file mode 100644 index 0e410b92..00000000 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/UnexpectedTokenException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.global.security.exception - -import team.comit.simtong.global.error.BusinessException -import team.comit.simtong.global.security.error.SecurityErrorCode - -/** - * - * 형식이 잘못된 토큰이 들어올 경우 - * Unexpected Token Error을 발생시키는 UnexpectedTokenException - * - * @author Chokyunghyeon - * @date 2022/09/02 - * @version 1.0.0 - **/ -class UnexpectedTokenException private constructor() : BusinessException(SecurityErrorCode.UNEXPECTED_TOKEN) { - - companion object { - @JvmField - val EXCEPTION = UnexpectedTokenException() - } -} \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/WrongTypeTokenException.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/WrongTypeTokenException.kt deleted file mode 100644 index 31372056..00000000 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/exception/WrongTypeTokenException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.global.security.exception - -import team.comit.simtong.global.error.BusinessException -import team.comit.simtong.global.security.error.SecurityErrorCode - -/** - * - * 원하는 토큰 Type이 아닐 경우 - * Wrong Type Token Error를 발생시키는 WrongTypeTokenException - * - * @author Chokyunghyeon - * @date 2022/09/02 - * @version 1.0.0 - **/ -class WrongTypeTokenException private constructor() : BusinessException(SecurityErrorCode.WRONG_TYPE_TOKEN) { - - companion object { - @JvmField - val EXCEPTION = WrongTypeTokenException() - } -} \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/principle/AuthDetailsService.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/principle/AuthDetailsService.kt index 155ffe0a..a2cb902d 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/principle/AuthDetailsService.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/principle/AuthDetailsService.kt @@ -4,9 +4,9 @@ import org.springframework.data.repository.findByIdOrNull import org.springframework.security.core.userdetails.UserDetails import org.springframework.security.core.userdetails.UserDetailsService import org.springframework.stereotype.Component -import team.comit.simtong.global.security.exception.InvalidTokenException +import team.comit.simtong.global.security.exception.SecurityExceptions import team.comit.simtong.persistence.user.repository.UserJpaRepository -import java.util.* +import java.util.UUID /** * @@ -23,7 +23,7 @@ class AuthDetailsService( override fun loadUserByUsername(userId: String): UserDetails { val id = UUID.fromString(userId) - val user = userRepository.findByIdOrNull(id) ?: throw InvalidTokenException.EXCEPTION + val user = userRepository.findByIdOrNull(id) ?: throw SecurityExceptions.InvalidToken("토큰 ID에 해당하는 유저를 찾을 수 없습니다.") return AuthDetails(id, user.authority) } diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/token/JwtParser.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/token/JwtParser.kt index 27b3e184..8e61837d 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/token/JwtParser.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/token/JwtParser.kt @@ -1,15 +1,18 @@ package team.comit.simtong.global.security.token -import io.jsonwebtoken.* +import io.jsonwebtoken.Claims +import io.jsonwebtoken.ExpiredJwtException +import io.jsonwebtoken.Header +import io.jsonwebtoken.InvalidClaimException +import io.jsonwebtoken.Jws +import io.jsonwebtoken.JwtException +import io.jsonwebtoken.Jwts import org.springframework.security.authentication.UsernamePasswordAuthenticationToken import org.springframework.security.core.Authentication import org.springframework.stereotype.Component -import team.comit.simtong.global.exception.InternalServerErrorException +import team.comit.simtong.global.exception.GlobalExceptions import team.comit.simtong.global.security.SecurityProperties -import team.comit.simtong.global.security.exception.UnexpectedTokenException -import team.comit.simtong.global.security.exception.ExpiredTokenException -import team.comit.simtong.global.security.exception.InvalidTokenException -import team.comit.simtong.global.security.exception.WrongTypeTokenException +import team.comit.simtong.global.security.exception.SecurityExceptions import team.comit.simtong.global.security.principle.AuthDetailsService /** @@ -32,11 +35,11 @@ class JwtParser( .setSigningKey(securityProperties.encodingSecretKey) .parseClaimsJws(token) } catch (e: Exception) { - when(e) { - is InvalidClaimException -> throw InvalidTokenException.EXCEPTION - is ExpiredJwtException -> throw ExpiredTokenException.EXCEPTION - is JwtException -> throw UnexpectedTokenException.EXCEPTION - else -> throw InternalServerErrorException.EXCEPTION + when (e) { + is InvalidClaimException -> throw SecurityExceptions.InvalidToken() + is ExpiredJwtException -> throw SecurityExceptions.ExpiredToken() + is JwtException -> throw SecurityExceptions.UnexpectedToken() + else -> throw GlobalExceptions.InternalServerError() } } } @@ -45,7 +48,7 @@ class JwtParser( val claims = getClaims(token) if (claims.header[Header.JWT_TYPE] != JwtComponent.ACCESS) { - throw WrongTypeTokenException.EXCEPTION + throw SecurityExceptions.WrongTypeToken("Access Token이어야 합니다.") } val details = authDetailsService.loadUserByUsername(claims.body.id) diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/parser/ExcelFileAdapter.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/parser/ExcelFileAdapter.kt index 92a80ecf..37652f19 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/parser/ExcelFileAdapter.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/parser/ExcelFileAdapter.kt @@ -8,8 +8,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook import org.springframework.stereotype.Component import team.comit.simtong.domain.file.converter.FileExtensions.XLS import team.comit.simtong.domain.file.converter.FileExtensions.XLSX -import team.comit.simtong.domain.file.exception.FileInvalidExtensionException -import team.comit.simtong.domain.file.exception.FileNotValidContentException +import team.comit.simtong.domain.file.exception.FileExceptions +import team.comit.simtong.domain.file.exception.WebFileExceptions import team.comit.simtong.domain.file.model.EmployeeCertificate import team.comit.simtong.domain.file.spi.ParseEmployeeCertificateFilePort import team.comit.simtong.domain.menu.model.Menu @@ -52,7 +52,7 @@ class ExcelFileAdapter : ParseEmployeeCertificateFilePort, ParseMenuFilePort { } }.onFailure { e -> e.printStackTrace() - throw FileNotValidContentException.EXCEPTION + throw FileExceptions.NotValidContent() } return employeeCertificateList @@ -106,7 +106,7 @@ class ExcelFileAdapter : ParseEmployeeCertificateFilePort, ParseMenuFilePort { } }.onFailure { e -> e.printStackTrace() - throw FileNotValidContentException.EXCEPTION + throw FileExceptions.NotValidContent() } return menu @@ -119,7 +119,7 @@ class ExcelFileAdapter : ParseEmployeeCertificateFilePort, ParseMenuFilePort { when (file.extension.uppercase()) { XLS -> HSSFWorkbook(inputStream) XLSX -> XSSFWorkbook(inputStream) - else -> throw FileInvalidExtensionException.EXCEPTION + else -> throw WebFileExceptions.InvalidExtension() } }.also { inputStream.close() diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/storage/AwsS3Adapter.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/storage/AwsS3Adapter.kt index 87351ab4..42fbd820 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/storage/AwsS3Adapter.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/thirdparty/storage/AwsS3Adapter.kt @@ -6,7 +6,7 @@ import com.amazonaws.services.s3.model.CannedAccessControlList import com.amazonaws.services.s3.model.ObjectMetadata import com.amazonaws.services.s3.model.PutObjectRequest import org.springframework.stereotype.Component -import team.comit.simtong.domain.file.exception.FileIOInterruptedException +import team.comit.simtong.domain.file.exception.FileExceptions import team.comit.simtong.domain.file.spi.CheckFilePort import team.comit.simtong.domain.file.spi.UploadFilePort import java.io.File @@ -25,7 +25,7 @@ import java.net.URLDecoder class AwsS3Adapter( private val awsProperties: AwsS3Properties, private val amazonS3Client: AmazonS3Client -): UploadFilePort, CheckFilePort { +) : UploadFilePort, CheckFilePort { override fun upload(file: File): String { runCatching { inputS3(file) } @@ -67,7 +67,7 @@ class AwsS3Adapter( ) } catch (e: IOException) { e.printStackTrace() - throw FileIOInterruptedException.EXCEPTION + throw FileExceptions.IOInterrupted() } } diff --git a/simtong-infrastructure/src/test/kotlin/team/comit/simtong/thirdparty/storage/AwsS3AdapterTests.kt b/simtong-infrastructure/src/test/kotlin/team/comit/simtong/thirdparty/storage/AwsS3AdapterTests.kt index bc3f0dec..bac07a4d 100644 --- a/simtong-infrastructure/src/test/kotlin/team/comit/simtong/thirdparty/storage/AwsS3AdapterTests.kt +++ b/simtong-infrastructure/src/test/kotlin/team/comit/simtong/thirdparty/storage/AwsS3AdapterTests.kt @@ -12,7 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.annotation.Import import org.springframework.mock.web.MockMultipartFile import org.springframework.test.context.junit.jupiter.SpringExtension -import team.comit.simtong.domain.file.exception.FileIOInterruptedException +import team.comit.simtong.domain.file.exception.FileExceptions import team.comit.simtong.thirdparty.AwsMockConfig import java.io.File @@ -84,7 +84,7 @@ class AwsS3AdapterTests { val file = File("test.jpg") // when & then - assertThrows { + assertThrows { awsS3Adapter.upload(file) } } @@ -99,7 +99,7 @@ class AwsS3AdapterTests { ) // when & then - assertThrows { + assertThrows { awsS3Adapter.upload(files) } } diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/converter/FileConverter.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/converter/FileConverter.kt index 48cd5c3f..cac6b2c5 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/converter/FileConverter.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/converter/FileConverter.kt @@ -1,7 +1,7 @@ package team.comit.simtong.domain.file.converter import org.springframework.web.multipart.MultipartFile -import team.comit.simtong.domain.file.exception.FileInvalidExtensionException +import team.comit.simtong.domain.file.exception.WebFileExceptions import java.io.File import java.io.FileOutputStream import java.util.UUID @@ -23,7 +23,7 @@ interface FileConverter { fun transferTo(multipartFile: MultipartFile): File { if (!isCorrectExtension(multipartFile)) { - throw FileInvalidExtensionException.EXCEPTION + throw WebFileExceptions.InvalidExtension() } return transferFile(multipartFile) @@ -32,7 +32,7 @@ interface FileConverter { fun transferToList(multipartFiles: List): List { multipartFiles.forEach { if (!isCorrectExtension(it)) { - throw FileInvalidExtensionException.EXCEPTION + throw WebFileExceptions.InvalidExtension() } } diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/error/WebFileErrorCode.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/error/WebFileErrorCode.kt deleted file mode 100644 index 43c8d9f5..00000000 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/error/WebFileErrorCode.kt +++ /dev/null @@ -1,24 +0,0 @@ -package team.comit.simtong.domain.file.error - -import team.comit.simtong.global.error.WebErrorProperty - -/** - * - * 표현 계층의 File Error를 관리하는 WebFileErrorCode - * - * @author Chokyunghyeon - * @date 2022/12/09 - * @version 1.0.0 - **/ -enum class WebFileErrorCode( - private val status: Int, - private val message: String -) : WebErrorProperty { - - INVALID_EXTENSION(400, "제한된 확장자"); - - override fun status(): Int = status - - override fun message(): String = message - -} \ No newline at end of file diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/exception/FileInvalidExtensionException.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/exception/FileInvalidExtensionException.kt deleted file mode 100644 index 5cabc0e8..00000000 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/exception/FileInvalidExtensionException.kt +++ /dev/null @@ -1,21 +0,0 @@ -package team.comit.simtong.domain.file.exception - -import team.comit.simtong.domain.file.error.WebFileErrorCode -import team.comit.simtong.global.error.WebException - -/** - * - * 파일 확장자 제한 에러를 발생시키는 FileInvalidExtensionException - * - * @author Chokyunghyeon - * @date 2022/12/09 - * @version 1.0.0 - **/ -class FileInvalidExtensionException private constructor() : WebException(WebFileErrorCode.INVALID_EXTENSION) { - - companion object { - @JvmField - val EXCEPTION = FileInvalidExtensionException() - } - -} \ No newline at end of file diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/exception/WebFileExceptions.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/exception/WebFileExceptions.kt new file mode 100644 index 00000000..ef41f64a --- /dev/null +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/exception/WebFileExceptions.kt @@ -0,0 +1,24 @@ +package team.comit.simtong.domain.file.exception + +import team.comit.simtong.global.exception.WebException + +/** + * + * WebFileExceptions + * + * @author kimbeomjin + * @date 2022/12/17 + * @version 1.0.0 + **/ +sealed class WebFileExceptions( + override val status: Int, + override val message: String +) : WebException(status, message) { + + // 400 + class InvalidExtension(message: String = INVALID_EXTENSION) : WebFileExceptions(400, message) + + companion object { + private const val INVALID_EXTENSION = "확장자가 유효하지 않습니다." + } +} diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/global/error/WebErrorProperty.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/global/error/WebErrorProperty.kt deleted file mode 100644 index f908480b..00000000 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/global/error/WebErrorProperty.kt +++ /dev/null @@ -1,17 +0,0 @@ -package team.comit.simtong.global.error - -/** - * - * 표현 계층의 ErrorCode 형식을 맞추기 위해 사용하는 WebErrorProperty - * - * @author Chokyunghyeon - * @date 2022/12/09 - * @version 1.0.0 - **/ -interface WebErrorProperty { - - fun status(): Int - - fun message(): String - -} \ No newline at end of file diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/global/error/WebException.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/global/exception/WebException.kt similarity index 66% rename from simtong-presentation/src/main/kotlin/team/comit/simtong/global/error/WebException.kt rename to simtong-presentation/src/main/kotlin/team/comit/simtong/global/exception/WebException.kt index bb4b460e..75aa95c9 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/global/error/WebException.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/global/exception/WebException.kt @@ -1,13 +1,15 @@ -package team.comit.simtong.global.error +package team.comit.simtong.global.exception /** * * 표현 계층에서 상황에 따라 예외를 처리하도록 Runtime Exception을 상속받은 WebException * * @author Chokyunghyeon + * @author kimbeomjin * @date 2022/12/09 * @version 1.0.0 **/ abstract class WebException( - val exceptionProperty: WebErrorProperty + open val status: Int, + override val message: String ) : RuntimeException() \ No newline at end of file