Skip to content

Commit

Permalink
fix: fix another logic related to non-null constraints
Browse files Browse the repository at this point in the history
- nullable 조건 추가로 인한 자잘한 리팩터링
- 커스텀 예외 로직 반환하도록 수정
  • Loading branch information
chock-cho committed Jan 24, 2025
1 parent 755b03a commit fe523e6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit fe523e6

Please sign in to comment.