From 8ae70e70680d44c414884d1e131b4913e274474c Mon Sep 17 00:00:00 2001 From: dldmsql Date: Mon, 19 Jun 2023 23:29:50 +0900 Subject: [PATCH 01/10] =?UTF-8?q?=EB=B9=88=EC=A7=91=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EA=B8=80=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EA=B5=AC=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 기능 명세서에 따른 엔티티 생성 및 변경 --- .../domain/house/entity/Address.kt | 19 ++++ .../jhouse_server/domain/house/entity/Deal.kt | 22 +++++ .../domain/house/entity/DealStateConverter.kt | 20 ++++ .../domain/house/entity/House.kt | 95 +++++++++++++++++++ .../domain/house/entity/HouseTypeConverter.kt | 23 +++++ .../domain/house/entity/Scrap.kt | 21 ++++ .../jhouse_server/domain/user/entity/User.kt | 8 ++ 7 files changed, 208 insertions(+) create mode 100644 src/main/kotlin/com/example/jhouse_server/domain/house/entity/Address.kt create mode 100644 src/main/kotlin/com/example/jhouse_server/domain/house/entity/Deal.kt create mode 100644 src/main/kotlin/com/example/jhouse_server/domain/house/entity/DealStateConverter.kt create mode 100644 src/main/kotlin/com/example/jhouse_server/domain/house/entity/House.kt create mode 100644 src/main/kotlin/com/example/jhouse_server/domain/house/entity/HouseTypeConverter.kt create mode 100644 src/main/kotlin/com/example/jhouse_server/domain/house/entity/Scrap.kt diff --git a/src/main/kotlin/com/example/jhouse_server/domain/house/entity/Address.kt b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/Address.kt new file mode 100644 index 00000000..2100c861 --- /dev/null +++ b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/Address.kt @@ -0,0 +1,19 @@ +package com.example.jhouse_server.domain.house.entity + +import javax.persistence.Column +import javax.persistence.Embeddable + +@Embeddable +class Address( + @Column + var city: String, // 시도 + + @Column + var zipcode: String, // 우편번호 +) { + fun updateEntity(city: String, zipCode: String) : Address { + this.city = city + this.zipcode = zipCode + return this + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/example/jhouse_server/domain/house/entity/Deal.kt b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/Deal.kt new file mode 100644 index 00000000..93206007 --- /dev/null +++ b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/Deal.kt @@ -0,0 +1,22 @@ +package com.example.jhouse_server.domain.house.entity + +import com.example.jhouse_server.domain.user.entity.User +import com.example.jhouse_server.global.entity.BaseEntity +import javax.persistence.* + +@Entity +class Deal( + + @Convert(converter = DealStateConverter::class) + var dealState : DealState, + + @OneToOne + var buyer: User, + + @OneToOne + var house: House, + + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + val id : Long = 0L +) : BaseEntity() { +} \ No newline at end of file diff --git a/src/main/kotlin/com/example/jhouse_server/domain/house/entity/DealStateConverter.kt b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/DealStateConverter.kt new file mode 100644 index 00000000..07fe1ea0 --- /dev/null +++ b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/DealStateConverter.kt @@ -0,0 +1,20 @@ +package com.example.jhouse_server.domain.house.entity + +import javax.persistence.AttributeConverter +import javax.persistence.Converter + +@Converter(autoApply = true) +class DealStateConverter : AttributeConverter { + override fun convertToDatabaseColumn(attribute: DealState?): String? { + return attribute?.name + } + + override fun convertToEntityAttribute(dbData: String?): DealState? { + return DealState.values().firstOrNull {it.name == dbData} + } +} + +enum class DealState { + ONGOING, + COMPLETED, +} \ No newline at end of file diff --git a/src/main/kotlin/com/example/jhouse_server/domain/house/entity/House.kt b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/House.kt new file mode 100644 index 00000000..c6e26bb6 --- /dev/null +++ b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/House.kt @@ -0,0 +1,95 @@ +package com.example.jhouse_server.domain.house.entity + +import com.example.jhouse_server.domain.board.PrefixCategory +import com.example.jhouse_server.domain.board.entity.* +import com.example.jhouse_server.domain.user.entity.User +import com.example.jhouse_server.global.entity.BaseEntity +import com.example.jhouse_server.global.exception.ApplicationException +import com.example.jhouse_server.global.exception.ErrorCode +import java.time.LocalDate +import javax.persistence.* +import javax.validation.constraints.NotBlank +import javax.validation.constraints.NotNull + +@Entity +class House( + @Convert(converter = RentalTypeConverter::class) + var houseType: RentalType, // 매물유형 + + @Embedded + var address: Address, // 주소 + + var size: String, // 집 크기( m2 ) + + var purpose: String, // 용도 ( 예: 주택 ) + + @Column(nullable = true) + var floorNum : Int, // 층수 ( 다가구인 경우에만 ) + + @Column(nullable = true) + var sumFloor : Int, // 총 층수 + + var contact : String, // 바로 연락 가능한 연락처 + + var createdDate : String, // 준공연도, + + var price: Int, // 매물가격 + + @Column(nullable = true) + var monthlyPrice : Double, // 월세의 경우, + + var agentName: String, // 공인중개사명 + var title: String, // 게시글 제목 + @Column(length = Int.MAX_VALUE) + var content : String, // 게시글 내용 + @Column(length = Int.MAX_VALUE) + var code : String, // 게시글 코드 + @Column(length = Int.MAX_VALUE) + @Convert(converter = BoardImageUrlConverter::class) // 이미지 url ","로 슬라이싱 + var imageUrls : List, + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) + var user : User, + var useYn : Boolean = true, // 삭제여부 + @OneToMany(mappedBy = "house", cascade = [CascadeType.ALL], orphanRemoval = true) + var scrap: MutableList = mutableListOf(), + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0L +) : BaseEntity() { + + fun updateEntity( + rentalType: RentalType, + size: String, + purpose: String, + floorNum: Int, + sumFloor: Int, + contact: String, + createdDate: String, + price: Int, + monthlyPrice: Double, + agentName : String, + title: String, + code: String, + content : String, + imageUrls: List + ) : House { + this.houseType = rentalType + this.size = size + this.purpose = purpose + this.floorNum = floorNum + this.sumFloor = sumFloor + this.contact = contact + this.createdDate = createdDate + this.price = price + this.monthlyPrice = monthlyPrice + this.agentName = agentName + this.title = title + this.code = code + this.content = content + this.imageUrls = imageUrls + return this + } + fun deleteEntity() { + this.useYn = false + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/example/jhouse_server/domain/house/entity/HouseTypeConverter.kt b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/HouseTypeConverter.kt new file mode 100644 index 00000000..6558e628 --- /dev/null +++ b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/HouseTypeConverter.kt @@ -0,0 +1,23 @@ +package com.example.jhouse_server.domain.house.entity + +import javax.persistence.AttributeConverter +import javax.persistence.Converter + +@Converter(autoApply = true) +class RentalTypeConverter : AttributeConverter { + override fun convertToDatabaseColumn(attribute: RentalType?): String? { + return attribute?.name + } + + override fun convertToEntityAttribute(dbData: String?): RentalType? { + return RentalType.values().firstOrNull {it.name == dbData} + } + +} + +enum class RentalType(val value: String) { + SALE("매매"), + JEONSE("전세"), + MONTHLYRENT("월세"), + ; +} \ No newline at end of file diff --git a/src/main/kotlin/com/example/jhouse_server/domain/house/entity/Scrap.kt b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/Scrap.kt new file mode 100644 index 00000000..8bdc5221 --- /dev/null +++ b/src/main/kotlin/com/example/jhouse_server/domain/house/entity/Scrap.kt @@ -0,0 +1,21 @@ +package com.example.jhouse_server.domain.house.entity + +import com.example.jhouse_server.domain.house.entity.House +import com.example.jhouse_server.domain.user.entity.User +import com.example.jhouse_server.global.entity.BaseEntity +import javax.persistence.* + +@Entity +class Scrap( + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) + var subscriber: User, + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "house_id") + var house : House, + + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0L +) : BaseEntity() { +} \ No newline at end of file diff --git a/src/main/kotlin/com/example/jhouse_server/domain/user/entity/User.kt b/src/main/kotlin/com/example/jhouse_server/domain/user/entity/User.kt index 40ffed86..49906d55 100644 --- a/src/main/kotlin/com/example/jhouse_server/domain/user/entity/User.kt +++ b/src/main/kotlin/com/example/jhouse_server/domain/user/entity/User.kt @@ -1,7 +1,9 @@ package com.example.jhouse_server.domain.user.entity import com.example.jhouse_server.domain.board.entity.Board +import com.example.jhouse_server.domain.house.entity.Scrap import com.example.jhouse_server.domain.comment.entity.Comment +import com.example.jhouse_server.domain.house.entity.House import com.example.jhouse_server.domain.record.entity.Record import com.example.jhouse_server.domain.record_comment.entity.RecordComment import com.example.jhouse_server.domain.record_review.entity.RecordReview @@ -41,6 +43,12 @@ class User( @OneToMany(mappedBy = "user") val boards : MutableList = mutableListOf(), + @OneToMany(mappedBy = "subscriber") + val scraps : MutableList = mutableListOf(), + + @OneToMany(mappedBy = "user") + val houses: MutableList = mutableListOf(), + @OneToMany(mappedBy = "user") val records : MutableList = mutableListOf(), From bb55bc0a3eb5275c2f5a0087cde5971d41fa58cd Mon Sep 17 00:00:00 2001 From: dldmsql Date: Mon, 19 Jun 2023 23:30:45 +0900 Subject: [PATCH 02/10] =?UTF-8?q?HTML=20=EC=A0=95=EC=A0=81=20=ED=83=9C?= =?UTF-8?q?=EA=B7=B8=20value=20=EC=B6=94=EC=B6=9C=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=A0=84=EC=97=AD=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 글로벌 사용을 위해 함수 접근 범위를 지역에서 전역으로 수정 --- .../domain/board/service/BoardServiceImpl.kt | 74 +++++++++---------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/src/main/kotlin/com/example/jhouse_server/domain/board/service/BoardServiceImpl.kt b/src/main/kotlin/com/example/jhouse_server/domain/board/service/BoardServiceImpl.kt index 1e5a26b5..342a26c2 100644 --- a/src/main/kotlin/com/example/jhouse_server/domain/board/service/BoardServiceImpl.kt +++ b/src/main/kotlin/com/example/jhouse_server/domain/board/service/BoardServiceImpl.kt @@ -88,42 +88,40 @@ class BoardServiceImpl( override fun getCategory(name: String): List { return BoardCategory.values().filter { it.superCategory.name == name }.map { CodeResDto(it.value, it.name) } } - - - fun getContent(code: String): String { - var str = code - str = Normalizer.normalize(str, Normalizer.Form.NFKC) - var mat: Matcher - - //