Property, CustomerProperty

This commit is contained in:
Bossanyi Tibor
2020-11-09 22:49:15 +01:00
parent 6cf74d2738
commit fd10f40306
27 changed files with 460 additions and 335 deletions
@@ -0,0 +1,16 @@
package com.aitrainer.api.model
import org.springframework.lang.NonNull
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
@Entity
data class CustomerProperty (
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var customerPropertyId: Long = 0,
@get: NonNull var customerId: Long = 0,
@get: NonNull var propertyId: Long = 0,
@get: NonNull var propertyValue: Double? = null,
@get: NonNull var dateAdd: String? = null
)
@@ -0,0 +1,19 @@
package com.aitrainer.api.model
import org.hibernate.annotations.Fetch
import org.hibernate.annotations.FetchMode
import org.springframework.lang.NonNull
import javax.persistence.*
import javax.validation.constraints.NotBlank
@Entity
data class Property (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var propertyId: Long = 0,
@get: NotBlank var propertyName: String = "",
@get: NotBlank var propertyUnit: String = ""
) {
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "property")
@Fetch(value = FetchMode.SUBSELECT)
val translations: List<PropertyTranslation> = mutableListOf<PropertyTranslation>().toList()
}
@@ -0,0 +1,21 @@
package com.aitrainer.api.model
import com.fasterxml.jackson.annotation.JsonIgnore
import javax.persistence.*
import javax.validation.constraints.NotBlank
@Entity
data class PropertyTranslation (
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) val translationId: Long = 0,
@get: NotBlank var languageCode: String?,
@get: NotBlank var propertyName: String = ""
) {
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "propertyId", nullable = false)
@JsonIgnore
val property: Property? = null
}