API 1.0.50 AppText Translations
This commit is contained in:
parent
3ace3eeeba
commit
0ba5909a0e
@ -11,7 +11,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.aitrainer"
|
group = "com.aitrainer"
|
||||||
version = "1.0.49"
|
version = "1.0.50"
|
||||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -2,7 +2,7 @@ START TRANSACTION;
|
|||||||
|
|
||||||
|
|
||||||
ALTER TABLE `customer`
|
ALTER TABLE `customer`
|
||||||
ADD COLUMN `firebase_reg_token` CHAR(100) NULL DEFAULT NULL AFTER `trial_date`;
|
ADD COLUMN `firebase_reg_token` CHAR(255) NULL DEFAULT NULL AFTER `trial_date`;
|
||||||
|
|
||||||
|
|
||||||
UPDATE configuration set config_value = "1.0.49", date_change=CURRENT_DATE WHERE config_key = "db_version";
|
UPDATE configuration set config_value = "1.0.49", date_change=CURRENT_DATE WHERE config_key = "db_version";
|
||||||
|
27
data/db/update_1_0_50.sql
Normal file
27
data/db/update_1_0_50.sql
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
CREATE TABLE `app_text` (
|
||||||
|
`text_id` INT(13) NOT NULL AUTO_INCREMENT,
|
||||||
|
`text_key` MEDIUMTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
|
||||||
|
`screenshot_url` CHAR(200) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
|
||||||
|
`checked` TINYINT(1) NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`text_id`) USING BTREE
|
||||||
|
)
|
||||||
|
COLLATE='utf8mb4_general_ci'
|
||||||
|
ENGINE=InnoDB
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE TABLE `app_text_translation` (
|
||||||
|
`translation_id` INT(13) NOT NULL AUTO_INCREMENT,
|
||||||
|
`text_id` INT(11) NOT NULL,
|
||||||
|
`language_code` CHAR(2) NOT NULL DEFAULT 'en' COLLATE 'utf8mb4_general_ci',
|
||||||
|
`text` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
|
||||||
|
PRIMARY KEY (`translation_id`) USING BTREE
|
||||||
|
)
|
||||||
|
COLLATE='utf8mb4_general_ci'
|
||||||
|
ENGINE=InnoDB
|
||||||
|
;
|
||||||
|
|
||||||
|
UPDATE configuration set config_value = "1.0.50", date_change=CURRENT_DATE WHERE config_key = "db_version";
|
||||||
|
|
||||||
|
COMMIT;
|
@ -27,7 +27,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
|||||||
private val faqRepository: FaqRepository,
|
private val faqRepository: FaqRepository,
|
||||||
private val trainingPlanRepository: TrainingPlanRepository,
|
private val trainingPlanRepository: TrainingPlanRepository,
|
||||||
private val splitTestsRepository: SplitTestsRepository,
|
private val splitTestsRepository: SplitTestsRepository,
|
||||||
private val trainingPlanDayRepository: TrainingPlanDayRepository
|
private val trainingPlanDayRepository: TrainingPlanDayRepository,
|
||||||
|
private val appTextRepository: AppTextRepository
|
||||||
) {
|
) {
|
||||||
private val logger = LoggerFactory.getLogger(javaClass)
|
private val logger = LoggerFactory.getLogger(javaClass)
|
||||||
|
|
||||||
@ -87,6 +88,9 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
|||||||
val listTrainingPlanDay = trainingPlanDayRepository.findAll()
|
val listTrainingPlanDay = trainingPlanDayRepository.findAll()
|
||||||
val listTrainingPlanDayJson = gson.toJson(listTrainingPlanDay)
|
val listTrainingPlanDayJson = gson.toJson(listTrainingPlanDay)
|
||||||
|
|
||||||
|
val listAppText = appTextRepository.findAll()
|
||||||
|
val listAppTextJson = gson.toJson(listAppText)
|
||||||
|
|
||||||
val packageJson: String =
|
val packageJson: String =
|
||||||
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
||||||
"|||" + getClassRecord(Product::class.simpleName, listProductsJson) +
|
"|||" + getClassRecord(Product::class.simpleName, listProductsJson) +
|
||||||
@ -103,7 +107,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
|||||||
"|||" + getClassRecord(Faq::class.simpleName, listFaqJson) +
|
"|||" + getClassRecord(Faq::class.simpleName, listFaqJson) +
|
||||||
"|||" + getClassRecord(TrainingPlan::class.simpleName, listTrainingPlanJson) +
|
"|||" + getClassRecord(TrainingPlan::class.simpleName, listTrainingPlanJson) +
|
||||||
"|||" + getClassRecord(SplitTests::class.simpleName, listSplitTestsJson) +
|
"|||" + getClassRecord(SplitTests::class.simpleName, listSplitTestsJson) +
|
||||||
"|||" + getClassRecord(TrainingPlanDay::class.simpleName, listTrainingPlanDayJson)
|
"|||" + getClassRecord(TrainingPlanDay::class.simpleName, listTrainingPlanDayJson) +
|
||||||
|
"|||" + getClassRecord(AppText::class.simpleName, listAppTextJson)
|
||||||
|
|
||||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||||
ResponseEntity.ok().body(packageJson)
|
ResponseEntity.ok().body(packageJson)
|
||||||
|
20
src/main/kotlin/com/aitrainer/api/model/AppText.kt
Normal file
20
src/main/kotlin/com/aitrainer/api/model/AppText.kt
Normal file
@ -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 AppText (
|
||||||
|
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var textId: Long = 0,
|
||||||
|
@Expose @get: NonNull var textKey: String,
|
||||||
|
@Expose @get: NonNull var screenshotUrl: String,
|
||||||
|
@Expose @get: NonNull var checked: Boolean? = null,
|
||||||
|
) {
|
||||||
|
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "appText")
|
||||||
|
@Fetch(value = FetchMode.SUBSELECT)
|
||||||
|
@Expose val translations: List<AppTextTranslation> = mutableListOf<AppTextTranslation>().toList()
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
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 AppTextTranslation (
|
||||||
|
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var translationId: Long = 0,
|
||||||
|
@Expose @get: NotBlank var languageCode: String? = "hu",
|
||||||
|
@Expose @get: NonNull var text: String? = null
|
||||||
|
) {
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||||
|
@JoinColumn(name = "textId", nullable = false)
|
||||||
|
@JsonIgnore val appText: AppText? = null
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.aitrainer.api.repository
|
||||||
|
|
||||||
|
import com.aitrainer.api.model.AppText
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
interface AppTextRepository: JpaRepository<AppText, Long> {
|
||||||
|
}
|
@ -17,6 +17,6 @@ logging.config=classpath:logback-spring.xml
|
|||||||
logging.file=logs
|
logging.file=logs
|
||||||
|
|
||||||
# if the database structure has been changed, increment this version number
|
# if the database structure has been changed, increment this version number
|
||||||
application.version=1.0.49
|
application.version=1.0.50
|
||||||
|
|
||||||
jwt.secret=aitrainer
|
jwt.secret=aitrainer
|
@ -17,7 +17,7 @@ logging.config=classpath:logback-spring.xml
|
|||||||
logging.file=logs
|
logging.file=logs
|
||||||
|
|
||||||
# if the database structure has been changed, increment this version number
|
# if the database structure has been changed, increment this version number
|
||||||
application.version=1.0.49
|
application.version=1.0.50
|
||||||
|
|
||||||
jwt.secret=aitrainer
|
jwt.secret=aitrainer
|
||||||
jasypt.encryptor.password=Tibor
|
jasypt.encryptor.password=Tibor
|
||||||
|
@ -49,6 +49,8 @@ class AppPackageTest {
|
|||||||
private lateinit var splitTestsRepository: SplitTestsRepository
|
private lateinit var splitTestsRepository: SplitTestsRepository
|
||||||
@Autowired
|
@Autowired
|
||||||
private lateinit var trainingPlanDayRepository: TrainingPlanDayRepository
|
private lateinit var trainingPlanDayRepository: TrainingPlanDayRepository
|
||||||
|
@Autowired
|
||||||
|
private lateinit var appTextRepository: AppTextRepository
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testAppPackage() {
|
fun testAppPackage() {
|
||||||
@ -70,7 +72,8 @@ class AppPackageTest {
|
|||||||
faqRepository,
|
faqRepository,
|
||||||
trainingPlanRepository,
|
trainingPlanRepository,
|
||||||
splitTestsRepository,
|
splitTestsRepository,
|
||||||
trainingPlanDayRepository
|
trainingPlanDayRepository,
|
||||||
|
appTextRepository
|
||||||
)
|
)
|
||||||
val response: ResponseEntity<*> = controller.getPackageData()
|
val response: ResponseEntity<*> = controller.getPackageData()
|
||||||
|
|
||||||
@ -201,6 +204,13 @@ class AppPackageTest {
|
|||||||
assertEquals(days.size,3)
|
assertEquals(days.size,3)
|
||||||
assertEquals(days[0].name, "Mo")
|
assertEquals(days[0].name, "Mo")
|
||||||
assertEquals(days[0].translations[0].nameTranslation, "H")
|
assertEquals(days[0].translations[0].nameTranslation, "H")
|
||||||
|
} else if (record[0] == AppText::class.simpleName) {
|
||||||
|
val appTextJson: String = record[1]
|
||||||
|
val type = object : TypeToken<List<AppText?>?>() {}.type
|
||||||
|
val texts: List<AppText> = gson.fromJson(appTextJson, type)
|
||||||
|
assertEquals(texts.size, 1)
|
||||||
|
assertEquals(texts[0].translations[0].text, "Done!")
|
||||||
|
assertEquals(texts[0].translations[1].text, "Kész!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user