API 1.0.40 split_tests, training_plan.treeId
This commit is contained in:
parent
ac6256bebc
commit
aeb62acaa3
@ -11,7 +11,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.aitrainer"
|
||||
version = "1.0.39"
|
||||
version = "1.0.40"
|
||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
repositories {
|
||||
|
23
data/db/update_1_0_40.sql
Normal file
23
data/db/update_1_0_40.sql
Normal file
@ -0,0 +1,23 @@
|
||||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `training_plan`
|
||||
ADD COLUMN `tree_id` INT NULL DEFAULT NULL AFTER `training_plan_id`;
|
||||
|
||||
CREATE TABLE `split_tests` (
|
||||
`test_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` CHAR(50) NOT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`remote_config_key` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`remote_config_value` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`test_value` TEXT NOT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`active` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
`valid_to` DATETIME NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`test_id`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
|
||||
UPDATE configuration set config_value = "1.0.40", date_change=CURRENT_DATE WHERE config_key = "db_version";
|
||||
|
||||
COMMIT;
|
@ -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)
|
||||
|
20
src/main/kotlin/com/aitrainer/api/model/SplitTests.kt
Normal file
20
src/main/kotlin/com/aitrainer/api/model/SplitTests.kt
Normal file
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user