API 1.0.15 CustomerExerciseDevice

This commit is contained in:
Bossanyi Tibor
2020-11-23 18:15:46 +01:00
parent af2f5be1bf
commit 3a70bcd10f
20 changed files with 171 additions and 61 deletions
@@ -1,9 +1,8 @@
package com.aitrainer.api.model
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import org.hibernate.annotations.Fetch
import org.hibernate.annotations.FetchMode
import javax.persistence.*
@Entity
data class Customer (
@@ -21,7 +20,7 @@ data class Customer (
var trainerId: Long = 0,
var password: String? = "",
var birthYear:Int = 0,
var weight: Int = 0,
// var weight: Int = 0,
var goal: String? = null,
var fitnessLevel: String = "beginner",
var bodyType: String? = null,
@@ -29,4 +28,8 @@ data class Customer (
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
var customerId: Long = 0
)
) {
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "customer")
@Fetch(value = FetchMode.SUBSELECT)
var exerciseDevices: List<CustomerExerciseDevice> = mutableListOf<CustomerExerciseDevice>()
}
@@ -0,0 +1,25 @@
package com.aitrainer.api.model
import com.fasterxml.jackson.annotation.JsonIgnore
import org.hibernate.annotations.Fetch
import org.hibernate.annotations.FetchMode
import javax.persistence.*
import javax.validation.constraints.NotNull
@Entity
data class CustomerExerciseDevice (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val customerExerciseDeviceId: Long = 0,
@get: NotNull var exerciseDeviceId: Long?,
//@get: NotNull var customerId: Long?,
@get: NotNull var favourite: Boolean?,
@get: NotNull var dateAdd: String? = null
) {
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "customerId", nullable = false)
@JsonIgnore
val customer: Customer? = null
}
@@ -1,6 +1,5 @@
package com.aitrainer.api.model
import com.fasterxml.jackson.annotation.JsonIgnore
import org.hibernate.annotations.Fetch
import org.hibernate.annotations.FetchMode
import javax.persistence.*
@@ -10,7 +9,7 @@ import javax.validation.constraints.NotBlank
data class ExerciseDevice (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val deviceId: Long = 0,
val exerciseDeviceId: Long = 0,
@get: NotBlank var name: String = "",
@get: NotBlank var description: String = "",
@@ -16,7 +16,7 @@ data class ExerciseDeviceTranslation (
) {
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "deviceId", nullable = false)
@JoinColumn(name = "exerciseDeviceId", nullable = false)
@JsonIgnore
val exerciseDevice: ExerciseDevice? = null
@@ -32,8 +32,4 @@ data class ExerciseType(
@Fetch(value = FetchMode.SUBSELECT)
val translations: List<ExerciseTypeTranslation> = mutableListOf<ExerciseTypeTranslation>()
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
@Fetch(value = FetchMode.SUBSELECT)
val exerciseDevices: List<ExerciseTypeDevice> = mutableListOf<ExerciseTypeDevice>()
}
@@ -1,7 +1,6 @@
package com.aitrainer.api.model
import com.fasterxml.jackson.annotation.JsonIgnore
import org.springframework.lang.NonNull
import javax.persistence.*
import javax.validation.constraints.NotBlank
@@ -11,7 +10,6 @@ data class ExerciseTypeTranslation (
@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 = ""