API 1.0.41 customer_training_plan details, exercises

This commit is contained in:
Bossanyi Tibor
2021-05-20 15:02:48 +02:00
parent aeb62acaa3
commit d02f6bd1f7
16 changed files with 203 additions and 17 deletions
@@ -7,6 +7,7 @@ import javax.persistence.*
@Entity
data class Customer (
@Expose var name: String? = null,
@Expose var firstname: String? = null,
@Expose var email: String? = null,
@@ -27,6 +28,5 @@ data class Customer (
@Expose var firebaseUid: String? = null,
@Expose var sportId: Int? = null,
@Expose var emailSubscription: Int? = 0,
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Expose var customerId: Long = 0
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Expose var customerId: Long = 0,
)
@@ -1,16 +1,21 @@
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
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.*
@Entity
data class CustomerTrainingPlan (
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var customerTrainingPlanId: Long = 0,
@Expose @get: NonNull var customerId: Long = 0,
@Expose @get: NonNull var trainingPlanId: Long = 0,
@Expose @get: NonNull var dateAdd: String? = null
)
@Expose @get: NonNull var dateAdd: String? = null,
@Expose var active: Boolean?,
@Expose @get: NonNull var status: String? = null,
) {
@OneToMany(fetch = FetchType.EAGER, mappedBy = "customerTrainingPlan")
@Fetch(value = FetchMode.SUBSELECT)
@Expose val details: List<CustomerTrainingPlanDetails> = mutableListOf<CustomerTrainingPlanDetails>()
}
@@ -0,0 +1,22 @@
package com.aitrainer.api.model
import com.fasterxml.jackson.annotation.JsonIgnore
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 CustomerTrainingPlanDetails (
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var customerTrainingPlanDetailsId: Long = 0,
@Expose @get: NonNull var exerciseTypeId: Long = 0,
@Expose var set: Int?,
@Expose var repeats: Int?,
@Expose var weight: Double?,
) {
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "customerTrainingPlanId", nullable = false)
@JsonIgnore
val customerTrainingPlan: CustomerTrainingPlan? = null
}
@@ -0,0 +1,15 @@
package com.aitrainer.api.model
import com.google.gson.annotations.Expose
import org.springframework.lang.NonNull
import javax.persistence.*
@Entity
data class CustomerTrainingPlanExercise (
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var customerTrainingPlanExerciseId: Long = 0,
@Expose @get: NonNull var customerTrainingPlanDetailsId: Long = 0,
@Expose @get: NonNull var customerId: Long = 0,
@Expose @get: NonNull var exerciseId: Long = 0,
@Expose var repeats: Int?,
@Expose var weight: Double?,
)