From fe523e60eb3588aa135f41842edb9cc5a1d57a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B2=A0=EB=89=B4?= Date: Sat, 25 Jan 2025 01:22:51 +0900 Subject: [PATCH] fix: fix another logic related to non-null constraints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - nullable 조건 추가로 인한 자잘한 리팩터링 - 커스텀 예외 로직 반환하도록 수정 --- .../usecase/experiment/CreateExperimentPostUseCase.kt | 4 +++- .../usecase/experiment/GetExperimentPostsUseCase.kt | 2 +- .../kotlin/com/dobby/backend/domain/exception/ErrorCode.kt | 2 +- .../dto/response/experiment/ExperimentPostDetailResponse.kt | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/dobby/backend/application/usecase/experiment/CreateExperimentPostUseCase.kt b/src/main/kotlin/com/dobby/backend/application/usecase/experiment/CreateExperimentPostUseCase.kt index 47f3d3e9..009d0d58 100644 --- a/src/main/kotlin/com/dobby/backend/application/usecase/experiment/CreateExperimentPostUseCase.kt +++ b/src/main/kotlin/com/dobby/backend/application/usecase/experiment/CreateExperimentPostUseCase.kt @@ -193,7 +193,9 @@ class CreateExperimentPostUseCase( private fun validateOnlineMatchType(input: Input){ if(input.matchType == MatchType.ONLINE){ - require(input.univName == null && input.region == null && input.area == null) + if(input.univName != null || input.region != null || input.area != null) { + throw ExperimentPostException(ErrorCode.EXPERIMENT_POST_INVALID_ONLINE_REQUEST) + } } } } diff --git a/src/main/kotlin/com/dobby/backend/application/usecase/experiment/GetExperimentPostsUseCase.kt b/src/main/kotlin/com/dobby/backend/application/usecase/experiment/GetExperimentPostsUseCase.kt index 2902655e..2c839ef4 100644 --- a/src/main/kotlin/com/dobby/backend/application/usecase/experiment/GetExperimentPostsUseCase.kt +++ b/src/main/kotlin/com/dobby/backend/application/usecase/experiment/GetExperimentPostsUseCase.kt @@ -47,7 +47,7 @@ class GetExperimentPostsUseCase ( val experimentPostId: Long, val title: String, val views: Int, - val univName: String, + val univName: String?, val reward: String, val recruitStatus: Boolean, val durationInfo: DurationInfoOutput diff --git a/src/main/kotlin/com/dobby/backend/domain/exception/ErrorCode.kt b/src/main/kotlin/com/dobby/backend/domain/exception/ErrorCode.kt index f2bc9f29..6269028e 100644 --- a/src/main/kotlin/com/dobby/backend/domain/exception/ErrorCode.kt +++ b/src/main/kotlin/com/dobby/backend/domain/exception/ErrorCode.kt @@ -89,5 +89,5 @@ enum class ErrorCode( EXPERIMENT_POST_IMAGE_SIZE_LIMIT("EP005", "Image can be uploaded maximum 3 images.", HttpStatus.BAD_REQUEST), EXPERIMENT_POST_RECRUIT_STATUS_ERROR("EP006", "This experiment post has already closed recruitment.", HttpStatus.BAD_REQUEST), EXPERIMENT_POST_CANNOT_UPDATE_DATE("EP007", "You cannot update experiment post with past experiment dates.", HttpStatus.BAD_REQUEST), - EXPERIMENT_POST_CANNOT_UPDATE_ALARM("EP008", "The alarmAgree for the experiment post cannot be updated.", HttpStatus.BAD_REQUEST) + EXPERIMENT_POST_INVALID_ONLINE_REQUEST("EP008", "univName, region, area field value must be null when MatchType is online.", HttpStatus.BAD_REQUEST), } diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/experiment/ExperimentPostDetailResponse.kt b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/experiment/ExperimentPostDetailResponse.kt index 36592a37..3ce549a7 100644 --- a/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/experiment/ExperimentPostDetailResponse.kt +++ b/src/main/kotlin/com/dobby/backend/presentation/api/dto/response/experiment/ExperimentPostDetailResponse.kt @@ -88,13 +88,13 @@ data class ExperimentPostDetailResponse( @Schema(description = "주소 응답 DTO") data class AddressResponse( @Schema(description = "학교", example = "건국대학교") - val univName: String, + val univName: String?, @Schema(description = "지역", example = "SEOUL") - val region: Region, + val region: Region?, @Schema(description = "구/군", example = "GWANGJINGU") - val area: Area, + val area: Area?, @Schema(description = "상세 주소 (nullable)", example = "1동 101호", nullable = true) val detailedAddress: String?