API 1.0.40 split_tests, training_plan.treeId
This commit is contained in:
@@ -25,7 +25,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
private val tutorialRepository: TutorialRepository,
|
||||
private val descriptionRepository: DescriptionRepository,
|
||||
private val faqRepository: FaqRepository,
|
||||
private val trainingPlanRepository: TrainingPlanRepository
|
||||
private val trainingPlanRepository: TrainingPlanRepository,
|
||||
private val splitTestsRepository: SplitTestsRepository
|
||||
) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@@ -79,6 +80,9 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
val listTrainingPlan = trainingPlanRepository.findAll()
|
||||
val listTrainingPlanJson = gson.toJson(listTrainingPlan)
|
||||
|
||||
val listSplitTests = splitTestsRepository.findAll()
|
||||
val listSplitTestsJson = gson.toJson(listSplitTests)
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
||||
"|||" + getClassRecord(Product::class.simpleName, listProductsJson) +
|
||||
@@ -93,7 +97,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
"|||" + getClassRecord(Tutorial::class.simpleName, listTutorialJson) +
|
||||
"|||" + getClassRecord(Description::class.simpleName, listDescriptionJson) +
|
||||
"|||" + getClassRecord(Faq::class.simpleName, listFaqJson) +
|
||||
"|||" + getClassRecord(TrainingPlan::class.simpleName, listTrainingPlanJson)
|
||||
"|||" + getClassRecord(TrainingPlan::class.simpleName, listTrainingPlanJson) +
|
||||
"|||" + getClassRecord(SplitTests::class.simpleName, listSplitTestsJson)
|
||||
|
||||
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 SplitTests (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var testId: Long = 0,
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose var remoteConfigKey: String?,
|
||||
@Expose var remoteConfigValue: String?,
|
||||
@Expose @get: NotBlank var testValue: String = "",
|
||||
@Expose @get: NotBlank var active: Boolean = false,
|
||||
@Expose var validTo: String?,
|
||||
)
|
||||
@@ -10,6 +10,7 @@ import javax.validation.constraints.NotBlank
|
||||
@Entity
|
||||
data class TrainingPlan (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var trainingPlanId: Long = 0,
|
||||
@Expose var treeId: Int?,
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose var description: String?,
|
||||
@Expose @get: NotBlank var type: String = "",
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.SplitTests
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface SplitTestsRepository: JpaRepository<SplitTests, 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.39
|
||||
application.version=1.0.40
|
||||
|
||||
jwt.secret=aitrainer
|
||||
@@ -17,7 +17,7 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structure has been changed, increment this version number
|
||||
application.version=1.0.39
|
||||
application.version=1.0.40
|
||||
|
||||
jwt.secret=aitrainer
|
||||
jasypt.encryptor.password=Tibor
|
||||
|
||||
@@ -45,6 +45,8 @@ class AppPackageTest {
|
||||
private lateinit var faqRepository: FaqRepository
|
||||
@Autowired
|
||||
private lateinit var trainingPlanRepository: TrainingPlanRepository
|
||||
@Autowired
|
||||
private lateinit var splitTestsRepository: SplitTestsRepository
|
||||
|
||||
@Test
|
||||
fun testAppPackage() {
|
||||
@@ -64,7 +66,8 @@ class AppPackageTest {
|
||||
tutorialRepository,
|
||||
descriptionRepository,
|
||||
faqRepository,
|
||||
trainingPlanRepository
|
||||
trainingPlanRepository,
|
||||
splitTestsRepository
|
||||
)
|
||||
val response: ResponseEntity<*> = controller.getPackageData()
|
||||
|
||||
@@ -173,8 +176,16 @@ class AppPackageTest {
|
||||
assertEquals(plans[1].name, "Biceps")
|
||||
assertEquals(plans[1].internalName, "biceps_beginner")
|
||||
assertEquals(plans[1].free, true)
|
||||
assertEquals(plans[1].treeId, 15)
|
||||
assertEquals(plans[0].details[0].exerciseTypeId, 63)
|
||||
assertEquals(plans[0].details[1].weight, -1.0)
|
||||
} else if (record[0] == SplitTests::class.simpleName) {
|
||||
val splitTestJson: String = record[1]
|
||||
val type = object : TypeToken<List<SplitTests?>?>() {}.type
|
||||
val tests: List<SplitTests> = gson.fromJson(splitTestJson, type)
|
||||
assertEquals(tests.size,2)
|
||||
assertEquals(tests[1].name, "registration_skip")
|
||||
assertEquals(tests[1].testValue, "Colors.cyan")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user