Skip to content

Commit 0f98026

Browse files
committed
fix: 농가거래 유효성 검사 조건 수정
1 parent 4d9460c commit 0f98026

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/main/kotlin/com/example/jhouse_server/domain/house/entity/House.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class House(
3838
var purpose: String?, // 용도 ( 예: 주택 )
3939

4040
@Column(nullable = true)
41-
var floorNum: Int, // 층수 ( 다가구인 경우에만 )
41+
var floorNum: Int = 0, // 층수 ( 다가구인 경우에만 )
4242

4343
@Column(length = 13)
4444
var contact: String, // 바로 연락 가능한 연락처

src/main/kotlin/com/example/jhouse_server/domain/house/service/HouseServiceImpl.kt

+5-8
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ class HouseServiceImpl(
6060
// (2) null 데이터 blank로 변경
6161
val tmpReq = changeNullToBlank(req)
6262
// (3) 임시저장 데이터 생성
63-
val address = Address(tmpReq.city!!, tmpReq.detail!!, tmpReq.zipCode!!)
63+
val address = Address(tmpReq.city!!, tmpReq.detail, tmpReq.zipCode!!)
6464
val content = getContent(tmpReq.code!!)
6565
val tmp = House(
6666
tmpReq.agentDetail,
6767
tmpReq.houseType,
6868
tmpReq.rentalType!!,
6969
address,
7070
tmpReq.size!!,
71-
tmpReq.purpose!!,
72-
tmpReq.floorNum!!,
71+
tmpReq.purpose,
72+
tmpReq.floorNum,
7373
tmpReq.contact!!,
7474
tmpReq.createdDate!!,
7575
tmpReq.price!!,
@@ -97,7 +97,7 @@ class HouseServiceImpl(
9797
// (1) 유효성 검사
9898
if (validationReqDto(req)) {
9999
// (2) 게시글 생성
100-
val address = Address(req.city!!, req.detail!!, req.zipCode!!)
100+
val address = Address(req.city!!, req.detail, req.zipCode!!)
101101
val content = getContent(req.code!!)
102102
val house = House(
103103
req.agentDetail,
@@ -178,7 +178,7 @@ class HouseServiceImpl(
178178
val house = houseRepository.findByIdOrThrow(houseId)
179179
// (2) 권한 체크 ( 작성자 본인이 아닌 경우 )
180180
if (user != house.user) throw ApplicationException(UNAUTHORIZED_EXCEPTION)
181-
house.address.updateEntity(req.city!!, req.detail!!, req.zipCode!!)
181+
house.address.updateEntity(req.city!!, req.detail, req.zipCode!!)
182182
// (3) 연관 테이블 ( 주소 ) 수정
183183
val content = getContent(req.code!!)
184184
// (4) 임시저장 -> 등록 && 유효성 검사
@@ -441,7 +441,6 @@ class HouseServiceImpl(
441441
private fun validationReqDto(req: HouseReqDto): Boolean {
442442
if (req.rentalType == null) throw ReqValidationException("매매 타입은 필수값입니다. ")
443443
if (req.city.isNullOrBlank()) throw ReqValidationException("주소는 필수값입니다.")
444-
if (req.detail.isNullOrEmpty()) throw ReqValidationException("상세주소는 필수값입니다.")
445444
if (req.zipCode.isNullOrEmpty()) throw ReqValidationException("우편변호는 필수값입니다.")
446445
if (req.size.isNullOrEmpty()) throw ReqValidationException("건물 크기는 필수값입니다.")
447446
if (req.contact.isNullOrEmpty()) throw ReqValidationException("연락 가능한 휴대폰번호는 필수값입니다.")
@@ -463,10 +462,8 @@ class HouseServiceImpl(
463462
private fun changeNullToBlank(req: HouseReqDto): HouseReqDto {
464463
if (req.rentalType == null) req.rentalType = RentalType.SALE
465464
if (req.city.isNullOrBlank()) req.city = ""
466-
if (req.detail.isNullOrEmpty()) req.detail = ""
467465
if (req.zipCode.isNullOrEmpty()) req.zipCode = ""
468466
if (req.size.isNullOrEmpty()) req.size = ""
469-
if (req.purpose.isNullOrEmpty()) req.purpose = ""
470467
if (req.contact.isNullOrEmpty()) req.contact = ""
471468
if (req.createdDate.isNullOrEmpty()) req.createdDate = ""
472469
if (req.code.isNullOrEmpty()) req.code = ""

0 commit comments

Comments
 (0)