Skip to content

Commit

Permalink
feat: 엔티티 설정 배포
Browse files Browse the repository at this point in the history
  • Loading branch information
h-beeen committed Aug 10, 2024
1 parent 4f8683a commit 960d212
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 47 deletions.
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ dependencies {
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
}

allOpen {
annotation("jakarta.persistence.Entity")
annotation("jakarta.persistence.MappedSuperclass")
annotation("jakarta.persistence.Embeddable")
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
Expand Down
26 changes: 13 additions & 13 deletions src/main/kotlin/com/ggsdh/backend/global/auditing/BaseEntity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ import java.time.LocalDateTime
@EntityListeners(value = [AuditingEntityListener::class])
abstract class BaseEntity {
@Column(
nullable = false,
insertable = false,
updatable = false,
columnDefinition = "datetime default CURRENT_TIMESTAMP",
nullable = false,
insertable = false,
updatable = false,
columnDefinition = "datetime default CURRENT_TIMESTAMP",
)
@CreatedDate
@JsonFormat(
shape = JsonFormat.Shape.STRING,
pattern = "yyyy-MM-dd a HH:mm",
shape = JsonFormat.Shape.STRING,
pattern = "yyyy-MM-dd a HH:mm",
)
open var createdDate: LocalDateTime? = null
var createdDate: LocalDateTime? = null

@Column(
nullable = false,
insertable = false,
columnDefinition = "datetime default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP",
nullable = false,
insertable = false,
columnDefinition = "datetime default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP",
)
@LastModifiedDate
@JsonFormat(
shape = JsonFormat.Shape.STRING,
pattern = "yyyy-MM-dd a HH:mm",
shape = JsonFormat.Shape.STRING,
pattern = "yyyy-MM-dd a HH:mm",
)
open var updatedDate: LocalDateTime? = null
var updatedDate: LocalDateTime? = null
}
18 changes: 9 additions & 9 deletions src/main/kotlin/com/ggsdh/backend/trip/domain/FestivalEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ open class FestivalEvent(
ranking: Long?,
dataModifiedAt: LocalDate,
dataCreatedAt: LocalDate,
open var sponsorName: String?,
open var startDate: LocalDate?,
open var endDate: LocalDate?,
open var playTime: String?,
open var ageLimit: String?,
open var eventPlace: String?,
open var spendTimeFestival: String?,
open var usetimeFestival: String?,
open var discountInfo: String?
var sponsorName: String?,
var startDate: LocalDate?,
var endDate: LocalDate?,
var playTime: String?,
var ageLimit: String?,
var eventPlace: String?,
var spendTimeFestival: String?,
var usetimeFestival: String?,
var discountInfo: String?
) : TourArea(
tripThemeConstants,
sigunguCode,
Expand Down
13 changes: 11 additions & 2 deletions src/main/kotlin/com/ggsdh/backend/trip/domain/Lane.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package com.ggsdh.backend.trip.domain

import jakarta.persistence.*
import jakarta.persistence.CascadeType.REMOVE

@Entity
@Table(name = "TB_LANE")
class Lane(var name: String) {

class Lane(
var name: String
) {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "lane_id")
var id: Long? = null

@OneToMany(
targetEntity = LaneMapping::class,
orphanRemoval = true,
cascade = [REMOVE]
)
var laneMappings: List<LaneMapping>? = listOf()
}
4 changes: 2 additions & 2 deletions src/main/kotlin/com/ggsdh/backend/trip/domain/Restaurant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ open class Restaurant(
ranking: Long?,
dataModifiedAt: LocalDate,
dataCreatedAt: LocalDate,
open var firstMenuImage: String?,
open var firstMenuName: String?
var firstMenuImage: String?,
var firstMenuName: String?
) : TourArea(
tripThemeConstants,
sigunguCode,
Expand Down
43 changes: 26 additions & 17 deletions src/main/kotlin/com/ggsdh/backend/trip/domain/TourArea.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,48 @@ import com.ggsdh.backend.global.auditing.BaseEntity
import com.ggsdh.backend.trip.domain.constants.SigunguCode
import com.ggsdh.backend.trip.domain.constants.TripThemeConstants
import jakarta.persistence.*
import jakarta.persistence.CascadeType.REMOVE
import java.time.LocalDate

@Entity
@Table(name = "TB_TOUR_AREA")
@DiscriminatorColumn(name = "content_type")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
open class TourArea(
class TourArea(
@Enumerated(EnumType.STRING)
open var tripThemeConstants: TripThemeConstants,
var tripThemeConstants: TripThemeConstants,

@Enumerated(EnumType.STRING)
open var sigunguCode: SigunguCode,

open var contentId: Long,
open var address1: String,
open var address2: String?,
open var image: String?,
open var latitude: Double,
open var longitude: Double,
open var mapLevel: Long?,
open var telNo: String?,
open var name: String,
open var ranking: Long?,
var sigunguCode: SigunguCode,

var contentId: Long,
var address1: String,
var address2: String?,
var image: String?,
var latitude: Double,
var longitude: Double,
var mapLevel: Long?,
var telNo: String?,
var name: String,
var ranking: Long?,

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
open var dataModifiedAt: LocalDate,
var dataModifiedAt: LocalDate,

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
open var dataCreatedAt: LocalDate
var dataCreatedAt: LocalDate
) : BaseEntity() {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "tour_area_id")
open var id: Long? = null
var id: Long? = null

@OneToMany(
targetEntity = LaneMapping::class,
mappedBy = "tourArea",
orphanRemoval = true,
cascade = [REMOVE]
)
var laneMappings: List<LaneMapping>? = listOf()
}
4 changes: 2 additions & 2 deletions src/main/kotlin/com/ggsdh/backend/trip/domain/TourismSpot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ open class TourismSpot(
dataModifiedAt: LocalDate,
dataCreatedAt: LocalDate,
ranking: Long?,
open var grandTourYn: Boolean,
open var associatedGrandTourYn: Boolean
var grandTourYn: Boolean,
var associatedGrandTourYn: Boolean
) : TourArea(
tripThemeConstants,
sigunguCode,
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/com/ggsdh/backend/trip/domain/TripMate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ class TripMate(
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "TRIP_MATE_ID")
var id: Long? = null
private set
}
1 change: 0 additions & 1 deletion src/main/kotlin/com/ggsdh/backend/trip/domain/TripTheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ class TripTheme(
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "trip_theme_id")
var id: Long? = null
private set
}

0 comments on commit 960d212

Please sign in to comment.