ExerciseType extension with Images and Translations
DB 1.0.5
This commit is contained in:
@@ -1,24 +1,32 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import org.hibernate.type.BinaryType
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
import javax.persistence.GenerationType
|
||||
import javax.persistence.Id
|
||||
import org.hibernate.annotations.FetchMode
|
||||
import org.hibernate.annotations.Fetch
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotBlank
|
||||
import javax.validation.constraints.Null
|
||||
|
||||
@Entity
|
||||
data class ExerciseType (
|
||||
|
||||
@get: NotBlank var name: String = "",
|
||||
data class ExerciseType(
|
||||
@get: NonNull var treeId: Int,
|
||||
@get: NotBlank var name: String = "",
|
||||
@get: NotBlank var description: String = "",
|
||||
@get: Null var video: BinaryType?,
|
||||
@get: Null var unit: String?,
|
||||
@get: Null var unitQuantity: String?,
|
||||
@get: Null var unitQuantityUnit: String?,
|
||||
@get: NonNull var active: Boolean?,
|
||||
|
||||
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val exerciseTypeId: Long = 0
|
||||
val exerciseTypeId: Long = 0,
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val images: List<ExerciseTypeImage> = mutableListOf<ExerciseTypeImage>().toList(),
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val translations: List<ExerciseTypeTranslation> = mutableListOf<ExerciseTypeTranslation>().toList()
|
||||
|
||||
)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class ExerciseTypeImage (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val imageId: Long = 0,
|
||||
|
||||
//@get: NonNull var exerciseTypeId: Integer?,
|
||||
@get: NotBlank var name: String = "",
|
||||
@get: NotBlank var type: String = "",
|
||||
@get: NotBlank var url: String = ""
|
||||
|
||||
) {
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name="exerciseTypeId", nullable=false)
|
||||
val exerciseType: ExerciseType? = null
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class ExerciseTypeTranslation (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val translationId: Long = 0,
|
||||
|
||||
//@get: NonNull var exerciseTypeId: Integer?,
|
||||
@get: NotBlank var languageCode: String?,
|
||||
@get: NotBlank var name: String = "",
|
||||
@get: NotBlank var description: String = ""
|
||||
) {
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name = "exerciseTypeId", nullable = false)
|
||||
val exerciseType: ExerciseType? = null
|
||||
}
|
||||
Reference in New Issue
Block a user