API 1.0.29 Evaluation

This commit is contained in:
Bossanyi Tibor
2021-04-03 15:50:16 +02:00
parent 4d9f2307aa
commit b1dc434e96
17 changed files with 264 additions and 20 deletions
@@ -0,0 +1,20 @@
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.*
import javax.validation.constraints.NotBlank
@Entity
data class Evaluation (
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var evaluationId: Int,
@Expose @get: NonNull var exerciseTypeId: Long = 0,
@Expose @get: NotBlank var name: String = "",
@Expose @get: NonNull var unit: String = "",
) {
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "evaluation")
@Fetch(value = FetchMode.SUBSELECT)
@Expose val attributes: List<EvaluationAttribute> = mutableListOf()
}
@@ -0,0 +1,27 @@
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.NotBlank
@Entity
data class EvaluationAttribute (
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var evaluationAttrId: Int,
//@Expose @get: NonNull var evaluationId: Long = 0,
@Expose @get: NotBlank var name: String = "",
@Expose var sex: String = "m",
@Expose @get: NonNull var ageMin: Int = 0,
@Expose @get: NonNull var ageMax: Int = 0,
@Expose @get: NonNull var valueMin: Double = 0.0,
@Expose @get: NonNull var valueMax: Double = 0.0,
@Expose @get: NonNull var evaluation_text: String = "",
@Expose var suggestion: String?,
) {
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name="evaluationId", nullable=false)
@JsonIgnore
val evaluation: Evaluation? = null
}