API 1.0.32 tutorials
This commit is contained in:
@@ -21,7 +21,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
private val exerciseTreeParentsRepository: ExerciseTreeParentsRepository,
|
||||
private val exercisePlanTemplateRepository: ExercisePlanTemplateRepository,
|
||||
private val evaluationRepository: EvaluationRepository,
|
||||
private val sportRepository: SportRepository
|
||||
private val sportRepository: SportRepository,
|
||||
private val tutorialRepository: TutorialRepository
|
||||
) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@@ -61,7 +62,10 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
val listEvaluationJson: String = gson.toJson(listEvaluations)
|
||||
|
||||
val listSports = sportRepository.getSports()
|
||||
val listSportsJson: String = gson.toJson((listSports))
|
||||
val listSportsJson: String = gson.toJson(listSports)
|
||||
|
||||
val listTutorials = tutorialRepository.findAll()
|
||||
val listTutorialJson: String = gson.toJson(listTutorials)
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
||||
@@ -73,7 +77,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
"|||" + getClassRecord(ExerciseTreeParents::class.simpleName, listExerciseTreeParentsJson) +
|
||||
"|||" + getClassRecord(ExercisePlanTemplate::class.simpleName, listPlanTemplateJson) +
|
||||
"|||" + getClassRecord(Evaluation::class.simpleName, listEvaluationJson) +
|
||||
"|||" + getClassRecord(Sport::class.simpleName, listSportsJson)
|
||||
"|||" + getClassRecord(Sport::class.simpleName, listSportsJson) +
|
||||
"|||" + getClassRecord(Tutorial::class.simpleName, listTutorialJson)
|
||||
|
||||
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 kotlinx.serialization.Serializable
|
||||
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 Tutorial (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var tutorialId: Long = 0,
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
) {
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "tutorial")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
@Expose val steps: List<TutorialSteps> = mutableListOf<TutorialSteps>().toList()
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
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.*
|
||||
import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class TutorialSteps (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var tutorialStepId: Long = 0,
|
||||
@Expose @get: NotBlank var tutorialText: String = "",
|
||||
@Expose @get: NotBlank var step: Int = 0,
|
||||
@Expose var errorText: String? = null,
|
||||
@Expose var checkText: String? = null,
|
||||
) {
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "tutorialId", nullable = false)
|
||||
@JsonIgnore
|
||||
val tutorial: Tutorial? = null
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "tutorialSteps")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
@Expose val translations: List<TutorialTranslation> = mutableListOf<TutorialTranslation>().toList()
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
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 TutorialTranslation (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val translationId: Long = 0,
|
||||
|
||||
@Expose @get: NotBlank var languageCode: String?,
|
||||
@Expose @get: NotBlank var tutorialText: String = "",
|
||||
@Expose var errorText: String? = null,
|
||||
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "tutorialStepId", nullable = false)
|
||||
@JsonIgnore
|
||||
val tutorialSteps: TutorialSteps? = null
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.Tutorial
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface TutorialRepository: JpaRepository<Tutorial, 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.31
|
||||
application.version=1.0.32
|
||||
|
||||
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.31
|
||||
application.version=1.0.32
|
||||
|
||||
jwt.secret=aitrainer
|
||||
Reference in New Issue
Block a user