Skip to content

Commit

Permalink
feat: 농가거래 파트로 기능 전환
Browse files Browse the repository at this point in the history
  • Loading branch information
dldmsql committed Aug 18, 2024
1 parent 50522ec commit fc308de
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 109 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.example.jhouse_server.domain.house.dto

import com.example.jhouse_server.domain.house.entity.DealState
import com.example.jhouse_server.domain.house.entity.House
import com.example.jhouse_server.domain.house.entity.RecommendedTag
import com.example.jhouse_server.domain.house.entity.RentalType
import com.example.jhouse_server.domain.house.entity.*
import com.example.jhouse_server.domain.user.entity.UserType
import org.hibernate.validator.constraints.Length
import java.io.Serializable
Expand All @@ -18,6 +15,7 @@ import javax.validation.constraints.Pattern
* ================================================================================================
* */
data class HouseReqDto(
var houseType: HouseType,
var rentalType: RentalType? = null,
var city: String?,
var detail: String?,
Expand All @@ -29,11 +27,11 @@ data class HouseReqDto(
var createdDate: String?,
var price: Int,
var monthlyPrice: Double,
var agentName : String?, // 공인중개사인 경우
var agentName: String?, // 공인중개사인 경우
var title: String?, // 게시글 제목
var code: String?, // 게시글 내용
var imageUrls: List<String>?, // 이미지 주소
val tmpYn : Boolean, // 임시저장 false -> save , true -> tmpSave
val tmpYn: Boolean, // 임시저장 false -> save , true -> tmpSave
var recommendedTag: List<String>? // 추천 태그
)

Expand All @@ -43,12 +41,13 @@ data class HouseReqDto(
* ================================================================================================
* */
data class HouseListDto(
var houseType: String?, // 빈집 매물 타입
val rentalType: String?, // 빈집 매물 유형
val city: String?, // 매물 위치
val recommendedTag: List<RecommendedTag>?, // 추천 태그
val search: String?, // 검색어 ( 제목과 닉네임 )
val dealState: String? //
): Serializable
) : Serializable

/**
* ================================================================================================
Expand All @@ -58,15 +57,18 @@ data class HouseListDto(
data class HouseAgentListDto(
val search: String?,
val dealState: String?,
val isCompleted: Boolean? //거래 기능 개발 후 판매상태 조건 추가
val isCompleted: Boolean?, //거래 기능 개발 후 판매상태 조건 추가
val houseType: String?,
)

/**
* ================================================================================================
* 마이페이지) 빈집 매물 게시글 목록 조회 DTO -- 일반 사용자
* ================================================================================================
* */
data class MyHouseResDto(
val houseId: Long,
var houseType: HouseType,
val rentalType: RentalType,
val city: String,
val title: String,
Expand All @@ -82,23 +84,26 @@ data class MyHouseResDto(
* */
class HouseResDto() : Serializable {
var houseId: Long = 0 // 게시글 아이디
lateinit var houseType: HouseType // 매물 타입
lateinit var rentalType: RentalType // 매물 유형
lateinit var city: String // 매물 위치
lateinit var city: String // 매물 위치
var price: Int? = 0 // 매물 가격 ( 월세의 경우, 보증금 )
var monthlyPrice: Double? = 0.0 // 매물 월세
lateinit var nickName: String // 매물 작성자 닉네임
lateinit var createdAt: Date // 게시글 작성일자 ( yyyy-MM-dd ) -> 클라이언트 측에서 파싱
var isCompleted: Boolean = false // 매물 거래 여부
var imageUrl : String? = null // 썸네일
var imageUrl: String? = null // 썸네일
lateinit var title: String // 게시글 제목
lateinit var recommendedTag: List<RecommendedTag> // 추천 태그
lateinit var recommendedTagName: List<String> // 추천 태그명

constructor(
houseId : Long,
rentalType : RentalType,
houseId: Long,
houseType: HouseType,
rentalType: RentalType,
city: String,
price: Int,
monthlyPrice : Double,
monthlyPrice: Double,
nickName: String,
createdAt: Date,
isCompleted: Boolean,
Expand All @@ -108,6 +113,7 @@ class HouseResDto() : Serializable {
recommendedTagName: List<String>
) : this() {
this.houseId = houseId
this.houseType = houseType
this.rentalType = rentalType
this.city = city
this.price = price
Expand All @@ -120,37 +126,38 @@ class HouseResDto() : Serializable {
this.recommendedTag = recommendedTag
this.recommendedTagName = recommendedTagName
}
}
}

/**
* ================================================================================================
* 빈집 매물 게시글 단일 조회 시, 응답 DTO
* ================================================================================================
* */
data class HouseResOneDto(
val houseId: Long,
val rentalType: RentalType,
val city: String,
val detail: String?,
val zipCode: String,
val size: String,
val purpose: String,
val floorNum: Int,
val contact: String,
val createdDate: String, // 준공연도
val price: Int,
val monthlyPrice: Double,
val agentName: String, // 공인중개사명
val title: String,
val code: String,
val imageUrls: List<String>,
val nickName: String, // 게시글 작성자
val userType: UserType, // 게시글 작성자의 타입 ( 일반회원, 공인중개사 )
val createdAt: Date,
val isCompleted: Boolean, // 거래 완료 여부
val isScraped : Boolean, // 게시글 스크랩 여부
val recommendedTag: List<RecommendedTag>, // 게시글 추천 태그
val recommendedTagName: List<String>, // 게시글 추천 태그명
val houseId: Long,
var houseType: HouseType,
val rentalType: RentalType,
val city: String,
val detail: String?,
val zipCode: String,
val size: String,
val purpose: String?,
val floorNum: Int,
val contact: String,
val createdDate: String?, // 준공연도
val price: Int,
val monthlyPrice: Double,
val agentName: String, // 공인중개사명
val title: String,
val code: String,
val imageUrls: List<String>,
val nickName: String, // 게시글 작성자
val userType: UserType, // 게시글 작성자의 타입 ( 일반회원, 공인중개사 )
val createdAt: Date,
val isCompleted: Boolean, // 거래 완료 여부
val isScraped: Boolean, // 게시글 스크랩 여부
val recommendedTag: List<RecommendedTag>, // 게시글 추천 태그
val recommendedTagName: List<String>, // 게시글 추천 태그명
)

/**
Expand All @@ -172,14 +179,17 @@ data class ReportReqDto(
* */
data class DealReqDto(
@field:NotNull(message = "만족도 점수는 필수값입니다.")
val score : Int,
val review : String?,
val score: Int,
val review: String?,
val nickName: String?,
val age : String?,
val age: String?,
@field:NotNull(message = "구매자 연락처 정보는 필수값입니다.")
val contact : String,
@field:Pattern(regexp = "\"\"\"^\\d{4}-\\d{2}-\\d{2}\$\"\"\"", message = "팔린날짜는 필수값입니다. ( yyyy-MM-dd )")
val dealDate : String,
val contact: String,
@field:Pattern(
regexp = "\"\"\"^\\d{4}-\\d{2}-\\d{2}\$\"\"\"",
message = "팔린날짜는 필수값입니다. ( yyyy-MM-dd )"
)
val dealDate: String,
)

/**
Expand All @@ -188,27 +198,77 @@ data class DealReqDto(
* ================================================================================================
* */

fun getTagByNameFromHouseTags(houseTag: List<RecommendedTag>) : List<RecommendedTag> {
fun getTagByNameFromHouseTags(houseTag: List<RecommendedTag>): List<RecommendedTag> {
return houseTag.stream().map { RecommendedTag.getTagByName(it.name) }.toList()
}

fun toListDto(house: House) : HouseResDto {
val recommendedTag: List<RecommendedTag> = getTagByNameFromHouseTags(house.houseTag.stream().map { it.recommendedTag }.toList())
val recommendedTagName: List<String> = house.houseTag.stream().map { RecommendedTag.getValueByTagName(it.recommendedTag.name) }.toList()
val imageUrl = if(house.imageUrls.isEmpty()) null else house.imageUrls[0]
return HouseResDto(house.id, house.rentalType, house.address.city, house.price, house.monthlyPrice,
house.user.nickName, Timestamp.valueOf(house.createdAt), house.dealState == DealState.COMPLETED,
imageUrl, house.title, recommendedTag, recommendedTagName )
fun toListDto(house: House): HouseResDto {
val recommendedTag: List<RecommendedTag> =
getTagByNameFromHouseTags(house.houseTag.stream().map { it.recommendedTag }.toList())
val recommendedTagName: List<String> =
house.houseTag.stream().map { RecommendedTag.getValueByTagName(it.recommendedTag.name) }
.toList()
val imageUrl = if (house.imageUrls.isEmpty()) null else house.imageUrls[0]
return HouseResDto(
house.id,
house.houseType,
house.rentalType,
house.address.city,
house.price,
house.monthlyPrice,
house.user.nickName,
Timestamp.valueOf(house.createdAt),
house.dealState == DealState.COMPLETED,
imageUrl,
house.title,
recommendedTag,
recommendedTagName
)
}
fun toDto(house: House, isScraped: Boolean) : HouseResOneDto {
val recommendedTag: List<RecommendedTag> = getTagByNameFromHouseTags(house.houseTag.stream().map { it.recommendedTag }.toList())
val recommendedTagName: List<String> = house.houseTag.stream().map { RecommendedTag.getValueByTagName(it.recommendedTag.name) }.toList()
return HouseResOneDto(house.id, house.rentalType, house.address.city, house.address.detail,
house.address.zipCode, house.size, house.purpose, house.floorNum, house.contact,
house.createdDate, house.price, house.monthlyPrice,
house.agentName, house.title, house.code, house.imageUrls, house.user.nickName,
house.user.userType, Timestamp.valueOf(house.createdAt), house.dealState == DealState.COMPLETED, isScraped, recommendedTag, recommendedTagName)

fun toDto(house: House, isScraped: Boolean): HouseResOneDto {
val recommendedTag: List<RecommendedTag> =
getTagByNameFromHouseTags(house.houseTag.stream().map { it.recommendedTag }.toList())
val recommendedTagName: List<String> =
house.houseTag.stream().map { RecommendedTag.getValueByTagName(it.recommendedTag.name) }
.toList()
return HouseResOneDto(
house.id,
house.houseType,
house.rentalType,
house.address.city,
house.address.detail,
house.address.zipCode,
house.size,
house.purpose,
house.floorNum,
house.contact,
house.createdDate,
house.price,
house.monthlyPrice,
house.agentName,
house.title,
house.code,
house.imageUrls,
house.user.nickName,
house.user.userType,
Timestamp.valueOf(house.createdAt),
house.dealState == DealState.COMPLETED,
isScraped,
recommendedTag,
recommendedTagName
)
}
fun toMyHouseDto(house: House) : MyHouseResDto {
return MyHouseResDto(house.id, house.rentalType, house.address.city, house.title, house.imageUrls[0], house.dealState.name, house.dealState.value)

fun toMyHouseDto(house: House): MyHouseResDto {
return MyHouseResDto(
house.id,
house.houseType,
house.rentalType,
house.address.city,
house.title,
house.imageUrls[0],
house.dealState.name,
house.dealState.value
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import javax.persistence.*
])
@Entity
class House(

@Enumerated(EnumType.STRING)
@Column(name = "house_type")
var houseType : HouseType, // 매물타입

@Convert(converter = RentalTypeConverter::class)
@Column(length = 40)
var rentalType: RentalType, // 매물유형
Expand All @@ -22,7 +27,7 @@ class House(
var size: String, // 집 크기( m2 )

@Column(length = 100)
var purpose: String, // 용도 ( 예: 주택 )
var purpose: String?, // 용도 ( 예: 주택 )

@Column(nullable = true)
var floorNum : Int, // 층수 ( 다가구인 경우에만 )
Expand All @@ -31,7 +36,7 @@ class House(
var contact : String, // 바로 연락 가능한 연락처

@Column(length = 5)
var createdDate : String, // 준공연도,
var createdDate : String?, // 준공연도,

var price: Int, // 매물가격

Expand Down Expand Up @@ -91,12 +96,13 @@ class House(
lateinit var deal:Deal

fun updateEntity(
houseType: HouseType,
rentalType: RentalType,
size: String,
purpose: String,
purpose: String?,
floorNum: Int,
contact: String,
createdDate: String,
createdDate: String?,
price: Int,
monthlyPrice: Double,
agentName : String,
Expand All @@ -105,6 +111,7 @@ class House(
code: String,
imageUrls: List<String>
) : House {
this.houseType = houseType
this.rentalType = rentalType
this.size = size
this.purpose = purpose
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.jhouse_server.domain.house.entity

enum class HouseType(val description: String) {
LAND("토지"),
HOUSE("주택"),
FARM_HOUSE("농가"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class HouseRepositoryImpl(
.where(
searchWithKeyword(houseListDto.search), // 키워드 검색어
searchWithRentalType(houseListDto.rentalType), // 매물 타입 필터링
searchWithHouseType(houseListDto.houseType),
house.useYn.eq(true), // 삭제 X
house.tmpYn.eq(false), // 임시저장 X
house.reported.eq(false), // 신고 X
Expand Down Expand Up @@ -81,6 +82,10 @@ class HouseRepositoryImpl(
return PageableExecutionUtils.getPage(result, pageable) { countQuery }
}

private fun searchWithHouseType(houseType: String?): BooleanExpression? {
return if(houseType == null) null else house.houseType.eq(HouseType.valueOf(houseType))
}

/**
* ============================================================================================
* 자신이 작성한 임시저장된 게시글 목록 조회
Expand Down
Loading

0 comments on commit fc308de

Please sign in to comment.