API 1.0.26 ExercisePlanTemplate
This commit is contained in:
@@ -18,7 +18,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
private val propertyRepository: PropertyRepository,
|
||||
private val productRepository: ProductRepository,
|
||||
private val exerciseDeviceRepository: ExerciseDeviceRepository,
|
||||
private val exerciseTreeParentsRepository: ExerciseTreeParentsRepository
|
||||
private val exerciseTreeParentsRepository: ExerciseTreeParentsRepository,
|
||||
private val exercisePlanTemplateRepository: ExercisePlanTemplateRepository
|
||||
) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@@ -51,6 +52,9 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
val listExerciseTreeParents = exerciseTreeParentsRepository.findAll()
|
||||
val listExerciseTreeParentsJson: String = gson.toJson(listExerciseTreeParents)
|
||||
|
||||
val listPlanTemplate = exercisePlanTemplateRepository.findAll()
|
||||
val listPlanTemplateJson: String = gson.toJson(listPlanTemplate)
|
||||
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
||||
@@ -59,7 +63,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
"|||" + getClassRecord(ExerciseTree::class.simpleName, listExerciseTreeJson) +
|
||||
"|||" + getClassRecord(ExerciseType::class.simpleName, listExerciseTypeJson) +
|
||||
"|||" + getClassRecord(ExerciseAbility::class.simpleName, listExerciseAbilityJson) +
|
||||
"|||" + getClassRecord(ExerciseTreeParents::class.simpleName, listExerciseTreeParentsJson)
|
||||
"|||" + getClassRecord(ExerciseTreeParents::class.simpleName, listExerciseTreeParentsJson) +
|
||||
"|||" + getClassRecord(ExercisePlanTemplate::class.simpleName, listPlanTemplateJson)
|
||||
|
||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(packageJson)
|
||||
|
||||
@@ -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
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.ExercisePlanTemplate
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface ExercisePlanTemplateRepository: JpaRepository<ExercisePlanTemplate, Int> {
|
||||
}
|
||||
Reference in New Issue
Block a user