API 1.0.26 ExercisePlanTemplate

This commit is contained in:
Bossanyi Tibor
2021-02-23 22:55:19 +01:00
parent 7ddb724ccc
commit 5b876d84bb
11 changed files with 199 additions and 10 deletions
@@ -0,0 +1,23 @@
package com.aitrainer.api.model
import com.google.gson.annotations.Expose
import org.hibernate.annotations.Fetch
import org.hibernate.annotations.FetchMode
import org.springframework.lang.NonNull
import javax.persistence.*
@Entity
data class ExercisePlanTemplate(
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var exercisePlanTemplateId: Int = 0,
@Expose @get: NonNull var name: String? = null,
@Expose @get: NonNull var description: String? = null,
@Expose @get: NonNull var templateType: String? = null
) {
@OneToMany(fetch = FetchType.EAGER, mappedBy = "exercisePlanTemplate")
@Fetch(value = FetchMode.SUBSELECT)
@Expose val translations: List<ExercisePlanTemplateTranslation> = mutableListOf<ExercisePlanTemplateTranslation>()
@OneToMany(fetch = FetchType.EAGER, mappedBy = "exercisePlanTemplate")
@Fetch(value = FetchMode.SUBSELECT)
@Expose val details: List<ExercisePlanTemplateDetail> = mutableListOf<ExercisePlanTemplateDetail>()
}
@@ -0,0 +1,24 @@
package com.aitrainer.api.model
import com.fasterxml.jackson.annotation.JsonIgnore
import com.google.gson.annotations.Expose
import org.springframework.lang.NonNull
import javax.persistence.*
import javax.validation.constraints.Null
@Entity
data class ExercisePlanTemplateDetail (
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var exercisePlanTemplateDetailId: Long = 0,
@Expose @get: NonNull var exerciseTypeId: Int = 0,
@Expose @get: Null var serie: Int? = 0,
@Expose @get: Null var quantity: Double? = 0.0,
@Expose @get: Null var quantityUnitQuantity: Double? = 0.0,
@Expose @get: NonNull var restingTime: String? = null
) {
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "exercisePlanTemplateId", nullable = false)
@JsonIgnore
val exercisePlanTemplate: ExercisePlanTemplate? = null
}
@@ -0,0 +1,23 @@
package com.aitrainer.api.model
import com.fasterxml.jackson.annotation.JsonIgnore
import com.google.gson.annotations.Expose
import javax.persistence.*
import javax.validation.constraints.NotBlank
@Entity
data class ExercisePlanTemplateTranslation (
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val translationId: Long = 0,
@Expose @get: NotBlank var languageCode: String?,
@Expose @get: NotBlank var name: String = "",
@Expose @get: NotBlank var description: String = "",
) {
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "exercisePlanTemplateId", nullable = false)
@JsonIgnore
val exercisePlanTemplate: ExercisePlanTemplate? = null
}