API 1.0.37 faq, training plans
This commit is contained in:
@@ -23,7 +23,9 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
private val evaluationRepository: EvaluationRepository,
|
||||
private val sportRepository: SportRepository,
|
||||
private val tutorialRepository: TutorialRepository,
|
||||
private val descriptionRepository: DescriptionRepository
|
||||
private val descriptionRepository: DescriptionRepository,
|
||||
private val faqRepository: FaqRepository,
|
||||
private val trainingPlanRepository: TrainingPlanRepository
|
||||
) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@@ -71,6 +73,12 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
val listDescriptions = descriptionRepository.findAll()
|
||||
val listDescriptionJson: String = gson.toJson(listDescriptions)
|
||||
|
||||
val listFaq = faqRepository.findAll()
|
||||
val listFaqJson: String = gson.toJson(listFaq)
|
||||
|
||||
val listTrainingPlan = trainingPlanRepository.findAll()
|
||||
val listTrainingPlanJson = gson.toJson(listTrainingPlan)
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
||||
"|||" + getClassRecord(Product::class.simpleName, listProductsJson) +
|
||||
@@ -83,7 +91,9 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
"|||" + getClassRecord(Evaluation::class.simpleName, listEvaluationJson) +
|
||||
"|||" + getClassRecord(Sport::class.simpleName, listSportsJson) +
|
||||
"|||" + getClassRecord(Tutorial::class.simpleName, listTutorialJson) +
|
||||
"|||" + getClassRecord(Description::class.simpleName, listDescriptionJson)
|
||||
"|||" + getClassRecord(Description::class.simpleName, listDescriptionJson) +
|
||||
"|||" + getClassRecord(Faq::class.simpleName, listFaqJson) +
|
||||
"|||" + getClassRecord(TrainingPlan::class.simpleName, listTrainingPlanJson)
|
||||
|
||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(packageJson)
|
||||
|
||||
@@ -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.*
|
||||
|
||||
@Entity
|
||||
data class Faq (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var faqId: Long = 0,
|
||||
@Expose @get: NonNull var name: String,
|
||||
@Expose @get: NonNull var description: String,
|
||||
|
||||
) {
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "faq")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
@Expose val translations: List<FaqTranslation> = mutableListOf<FaqTranslation>().toList()
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
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 FaqTranslation (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var translationId: Long = 0,
|
||||
@Expose @get: NotBlank var languageCode: String? = "hu",
|
||||
@Expose @get: NonNull var nameTranslation: String? = null,
|
||||
@Expose @get: NonNull var descriptionTranslation: String? = null
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "faqId", nullable = false)
|
||||
@JsonIgnore val faq: Faq? = null
|
||||
}
|
||||
@@ -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 TrainingPlan (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var trainingPlanId: Long = 0,
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose @get: NotBlank var type: String = "",
|
||||
) {
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "trainingPlan")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
@Expose val details: List<TrainingPlanDetail> = mutableListOf<TrainingPlanDetail>().toList()
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
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 TrainingPlanDetail (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var trainingPlanDetailId: Long = 0,
|
||||
@Expose @get: NotBlank var exerciseTypeId: Int = 0,
|
||||
@Expose @get: NotBlank var sort: Int = 0,
|
||||
@Expose @get: NotBlank var set: Int = 0,
|
||||
@Expose @get: NotBlank var repeats: Int = 0,
|
||||
@Expose @get: NotBlank var weight: Double = 0.0,
|
||||
@Expose @get: NotBlank var restingTime: Int = 0,
|
||||
@Expose @get: NotBlank var parallel: Boolean = false,
|
||||
@Expose var day: String? = null,
|
||||
|
||||
) {
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "trainingPlanId", nullable = false)
|
||||
@JsonIgnore
|
||||
val trainingPlan: TrainingPlan? = null
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.Faq
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface FaqRepository: JpaRepository<Faq, Long> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.TrainingPlan
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface TrainingPlanRepository: JpaRepository<TrainingPlan, Long> {
|
||||
}
|
||||
@@ -17,6 +17,6 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structure has been changed, increment this version number
|
||||
application.version=1.0.36
|
||||
application.version=1.0.37
|
||||
|
||||
jwt.secret=aitrainer
|
||||
@@ -17,6 +17,6 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structure has been changed, increment this version number
|
||||
application.version=1.0.36
|
||||
application.version=1.0.37
|
||||
|
||||
jwt.secret=aitrainer
|
||||
Reference in New Issue
Block a user