API: ExercisePlan, ExercisePlanDetail
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import org.hibernate.annotations.Fetch
|
||||
import org.hibernate.annotations.FetchMode
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.*
|
||||
|
||||
@Entity
|
||||
data class ExercisePlan(
|
||||
@get: NonNull var customerId: Long = 0,
|
||||
@get: NonNull var name: String? = null,
|
||||
@get: NonNull var description: String? = null,
|
||||
@get: NonNull var private: Boolean = false,
|
||||
@get: NonNull var dateAdd: String? = null
|
||||
) {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
var exercisePlanId: Long = 0
|
||||
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "exercisePlan")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val planDetailList: List<ExercisePlanDetail> = mutableListOf<ExercisePlanDetail>()
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.*
|
||||
|
||||
@Entity
|
||||
data class ExercisePlanDetail (
|
||||
@get: NonNull var exerciseTypeId: Long = 0,
|
||||
@get: NonNull var serie: Int = 0,
|
||||
@get: NonNull var repeats: Int = 0,
|
||||
@get: NonNull var weightEquation: String? = "",
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name = "exercisePlanId", nullable = false)
|
||||
@JsonIgnore
|
||||
val exercisePlan: ExercisePlan? = null
|
||||
) {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val exercisePlanDetailId: Long = 0
|
||||
}
|
||||
Reference in New Issue
Block a user