API 1.0.24 ExerciseAbility, AppPackage, AppCustomerPackage, Tracking
This commit is contained in:
parent
6808720577
commit
0ab6d5142e
@ -35,6 +35,8 @@ dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc") // JVM dependency
|
||||
implementation("io.jsonwebtoken:jjwt:0.9.1")
|
||||
implementation("org.yaml:snakeyaml:1.27")
|
||||
implementation("com.google.code.gson:gson:2.8.6")
|
||||
implementation("org.projectlombok:lombok:1.18.16")
|
||||
|
||||
runtimeOnly("mysql:mysql-connector-java")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test") {
|
||||
|
@ -905,6 +905,38 @@ INSERT INTO `exercise_result` (`exercise_result_id`, `customer_id`, `exercise_id
|
||||
INSERT INTO `exercise_result` (`exercise_result_id`, `customer_id`, `exercise_id`, `exercise_plan_id`, `result_type`, `value`, `date_from`, `date_to`) VALUES (3, 90, 1, 0, 'development', 11.1, '2020-12-12 10:57:28', NULL);
|
||||
INSERT INTO `exercise_result` (`exercise_result_id`, `customer_id`, `exercise_id`, `exercise_plan_id`, `result_type`, `value`, `date_from`, `date_to`) VALUES (4, 90, 1, 0, 'bpm_min', 113, '2020-12-12 10:57:52', NULL);
|
||||
|
||||
CREATE TABLE `exercise_ability` (
|
||||
`exercise_ability_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`description` VARCHAR(200) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
PRIMARY KEY (`exercise_ability_id`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
INSERT INTO `exercise_ability` (`exercise_ability_id`, `name`, `description`) VALUES (1, '1RM', 'One Rep Max');
|
||||
INSERT INTO `exercise_ability` (`exercise_ability_id`, `name`, `description`) VALUES (2, 'Endurance', NULL);
|
||||
INSERT INTO `exercise_ability` (`exercise_ability_id`, `name`, `description`) VALUES (3, 'Cardio', NULL);
|
||||
|
||||
CREATE TABLE `tracking` (
|
||||
`tacking_id` INT(20) NOT NULL AUTO_INCREMENT,
|
||||
`customer_id` INT(20) NOT NULL DEFAULT '0',
|
||||
`date_add` DATETIME NOT NULL,
|
||||
`event` CHAR(100) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`event_value` DOUBLE NULL DEFAULT NULL,
|
||||
`area` CHAR(100) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`platform` CHAR(20) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`version` CHAR(20) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
PRIMARY KEY (`tacking_id`) USING BTREE,
|
||||
INDEX `customer_id` (`customer_id`) USING BTREE,
|
||||
INDEX `event` (`event`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
|
46
data/db/update_1_0_24.sql
Normal file
46
data/db/update_1_0_24.sql
Normal file
@ -0,0 +1,46 @@
|
||||
START TRANSACTION;
|
||||
|
||||
CREATE TABLE `tracking` (
|
||||
`tacking_id` INT(20) NOT NULL AUTO_INCREMENT,
|
||||
`customer_id` INT(20) NOT NULL DEFAULT '0',
|
||||
`date_add` DATETIME NOT NULL,
|
||||
`event` CHAR(100) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`event_value` DOUBLE NULL DEFAULT NULL,
|
||||
`area` CHAR(100) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`platform` CHAR(20) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`version` CHAR(20) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
PRIMARY KEY (`tacking_id`) USING BTREE,
|
||||
INDEX `customer_id` (`customer_id`) USING BTREE,
|
||||
INDEX `event` (`event`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
|
||||
CREATE TABLE `exercise_ability` (
|
||||
`exercise_ability_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
`description` VARCHAR(200) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||
PRIMARY KEY (`exercise_ability_id`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
CREATE TABLE `exercise_tree_ability` (
|
||||
`exercise_tree_ability_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`exercise_tree_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`exercise_ability_id` INT(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`exercise_tree_ability_id`) USING BTREE,
|
||||
INDEX `exercise_tree_id` (`exercise_tree_id`) USING BTREE,
|
||||
INDEX `exercise_ability_id` (`exercise_ability_id`) USING BTREE
|
||||
)
|
||||
COLLATE='utf8_hungarian_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
UPDATE configuration set config_value = "1.0.24", date_change=CURRENT_DATE WHERE config_key = "db_version";
|
||||
|
||||
COMMIT;
|
||||
|
@ -0,0 +1,72 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.*
|
||||
import com.aitrainer.api.repository.*
|
||||
import com.google.gson.GsonBuilder
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class CustomerPackageController( private val customerRepository: CustomerRepository,
|
||||
private val customerExerciseDeviceRepository: CustomerExerciseDeviceRepository,
|
||||
private val exercisesRepository: ExercisesRepository,
|
||||
private val productTestRepository: ProductTestRepository,
|
||||
private val purchaseRepository: PurchaseRepository,
|
||||
private val customerPropertyRepository: CustomerPropertyRepository,
|
||||
private val exerciseResultRepository: ExerciseResultRepository) {
|
||||
|
||||
@GetMapping("/app_customer_package/{id}")
|
||||
fun getCustomerPackageData(@PathVariable(value = "id") customerId: Long): ResponseEntity<String> {
|
||||
|
||||
if (customerId <= 0) {
|
||||
return ResponseEntity.notFound().build()
|
||||
}
|
||||
|
||||
val gson = GsonBuilder()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.setPrettyPrinting()
|
||||
.create()
|
||||
|
||||
val customer: Customer = customerRepository.findById(customerId).orElse(null)
|
||||
?: return ResponseEntity.notFound().build()
|
||||
val customerJson: String = gson.toJson(customer)
|
||||
|
||||
val listCustomerExerciseDevices = customerExerciseDeviceRepository.findByCustomerId(customerId)
|
||||
val listCustomerExerciseDeviceJson = gson.toJson(listCustomerExerciseDevices)
|
||||
|
||||
val listExercises = exercisesRepository.getAllByCustomerIdOrderByDateAddDesc(customerId)
|
||||
val listExercisesJson = gson.toJson(listExercises)
|
||||
|
||||
val listProductTest = productTestRepository.findByCustomerId(customerId)
|
||||
val listProductTestJson = gson.toJson(listProductTest)
|
||||
|
||||
val listPurchase = purchaseRepository.findByCustomerId(customerId)
|
||||
val listPurchaseJson = gson.toJson(listPurchase)
|
||||
|
||||
val listCustomerProperty = customerPropertyRepository.findAllByCustomerId(customerId)
|
||||
val listCustomerPropertyJson = gson.toJson(listCustomerProperty)
|
||||
|
||||
val listExerciseResult = exerciseResultRepository.getAllByCustomerId(customerId)
|
||||
val listExerciseResultJson = gson.toJson(listExerciseResult)
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(Customer::class.simpleName, customerJson) +
|
||||
"|||" + getClassRecord(CustomerExerciseDevice::class.simpleName, listCustomerExerciseDeviceJson) +
|
||||
"|||" + getClassRecord(Exercises::class.simpleName, listExercisesJson) +
|
||||
"|||" + getClassRecord(ProductTest::class.simpleName, listProductTestJson) +
|
||||
"|||" + getClassRecord(Purchase::class.simpleName, listPurchaseJson) +
|
||||
"|||" + getClassRecord(CustomerProperty::class.simpleName, listCustomerPropertyJson) +
|
||||
"|||" + getClassRecord(ExerciseResult::class.simpleName, listExerciseResultJson)
|
||||
|
||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(packageJson)
|
||||
}
|
||||
|
||||
fun getClassRecord(className: String?, json: String): String {
|
||||
return "$className***$json"
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.ExerciseAbility
|
||||
import com.aitrainer.api.model.ExerciseDevice
|
||||
import com.aitrainer.api.repository.ExerciseAbilityRepository
|
||||
import com.aitrainer.api.repository.ExerciseDeviceRepository
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class ExerciseAbilityController(private val exerciseAbilityRepository: ExerciseAbilityRepository) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@GetMapping("/exercise_ability")
|
||||
fun getAbilities(): ResponseEntity<List<ExerciseAbility>> {
|
||||
val list = exerciseAbilityRepository.findAll()
|
||||
|
||||
logger.info(" -- Get All ExerciseAbility $list")
|
||||
return if (list.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(list)
|
||||
}
|
||||
}
|
@ -51,8 +51,7 @@ class ExerciseTypeController ( private val exerciseTypeRepository: ExerciseTypeR
|
||||
return exerciseTypeRepository.findById(exerciseTypeId).map { existingExerciseType ->
|
||||
val updatedExerciseType: ExerciseType = existingExerciseType
|
||||
.copy(name = newExerciseType.name,
|
||||
description = newExerciseType.description,
|
||||
treeId = newExerciseType.treeId)
|
||||
description = newExerciseType.description)
|
||||
ResponseEntity.ok().body(exerciseTypeRepository.save(updatedExerciseType))
|
||||
}.orElse(ResponseEntity.notFound().build())
|
||||
|
||||
|
@ -0,0 +1,71 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.*
|
||||
import com.aitrainer.api.repository.*
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import com.google.gson.GsonBuilder
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRepository,
|
||||
private val exerciseTypeRepository: ExerciseTypeRepository,
|
||||
private val exerciseTreeRepository: ExerciseTreeRepository,
|
||||
private val propertyRepository: PropertyRepository,
|
||||
private val productRepository: ProductRepository,
|
||||
private val exerciseDeviceRepository: ExerciseDeviceRepository,
|
||||
private val exerciseTreeParentsRepository: ExerciseTreeParentsRepository
|
||||
) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@GetMapping("/app_package")
|
||||
fun getPackageData(): ResponseEntity<String> {
|
||||
|
||||
val gson = GsonBuilder()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.setPrettyPrinting()
|
||||
.create()
|
||||
|
||||
val listDevices: List<ExerciseDevice> = exerciseDeviceRepository.getExerciseDevices()
|
||||
val listDevicesJson: String = gson.toJson(listDevices)
|
||||
|
||||
val listProducts = productRepository.findAll()
|
||||
val listProductsJson: String = gson.toJson(listProducts)
|
||||
|
||||
val listProperty:List<Property> = propertyRepository.getProperties()
|
||||
val listPropertyJson: String = gson.toJson(listProperty)
|
||||
|
||||
val listExerciseTree = exerciseTreeRepository.getActiveMenu()
|
||||
val listExerciseTreeJson: String = gson.toJson(listExerciseTree)
|
||||
|
||||
val listExerciseType = exerciseTypeRepository.getActiveExerciseTypes()
|
||||
val listExerciseTypeJson = gson.toJson(listExerciseType)
|
||||
|
||||
val listExerciseAbility = exerciseAbilityRepository.findAll()
|
||||
val listExerciseAbilityJson: String = gson.toJson(listExerciseAbility)
|
||||
|
||||
val listExerciseTreeParents = exerciseTreeParentsRepository.findAll()
|
||||
val listExerciseTreeParentsJson: String = gson.toJson(listExerciseTreeParents)
|
||||
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
||||
"|||" + getClassRecord(Product::class.simpleName, listProductsJson) +
|
||||
"|||" + getClassRecord(Property::class.simpleName, listPropertyJson) +
|
||||
"|||" + getClassRecord(ExerciseTree::class.simpleName, listExerciseTreeJson) +
|
||||
"|||" + getClassRecord(ExerciseType::class.simpleName, listExerciseTypeJson) +
|
||||
"|||" + getClassRecord(ExerciseAbility::class.simpleName, listExerciseAbilityJson) +
|
||||
"|||" + getClassRecord(ExerciseTreeParents::class.simpleName, listExerciseTreeParentsJson)
|
||||
|
||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(packageJson)
|
||||
}
|
||||
|
||||
fun getClassRecord(className: String?, json: String): String {
|
||||
return "$className***$json"
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.Tracking
|
||||
import com.aitrainer.api.repository.TrackingRepository
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import javax.validation.Valid
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class TrackingController(private val trackingRepository: TrackingRepository) {
|
||||
|
||||
@PostMapping("/tracking")
|
||||
fun createNewTracking(@Valid @RequestBody tracking: Tracking): ResponseEntity<Tracking> {
|
||||
return ResponseEntity.ok().body(trackingRepository.save(tracking))
|
||||
}
|
||||
|
||||
}
|
@ -1,28 +1,29 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import javax.persistence.*
|
||||
|
||||
@Entity
|
||||
data class Customer (
|
||||
var name: String = "",
|
||||
var firstname: String = "",
|
||||
var email: String = "",
|
||||
var age: Int? = 0,
|
||||
var sex: String = "m",
|
||||
var active: String = "N",
|
||||
var dateAdd: String? = null,
|
||||
var dateChange: String? = null,
|
||||
var dataPolicyAllowed: Int = 0,
|
||||
var admin: Int = 0,
|
||||
var trainer: Int = 0,
|
||||
var trainerId: Long = 0,
|
||||
var password: String? = "",
|
||||
var birthYear:Int = 0,
|
||||
var goal: String? = null,
|
||||
var fitnessLevel: String = "beginner",
|
||||
var bodyType: String? = null,
|
||||
var firebaseUid: String? = null,
|
||||
@Expose var name: String = "",
|
||||
@Expose var firstname: String = "",
|
||||
@Expose var email: String = "",
|
||||
@Expose var age: Int? = 0,
|
||||
@Expose var sex: String = "m",
|
||||
@Expose var active: String = "N",
|
||||
@Expose var dateAdd: String? = null,
|
||||
@Expose var dateChange: String? = null,
|
||||
@Expose var dataPolicyAllowed: Int = 0,
|
||||
@Expose var admin: Int = 0,
|
||||
@Expose var trainer: Int = 0,
|
||||
@Expose var trainerId: Long = 0,
|
||||
@Expose var password: String? = "",
|
||||
@Expose var birthYear:Int = 0,
|
||||
@Expose var goal: String? = null,
|
||||
@Expose var fitnessLevel: String = "beginner",
|
||||
@Expose var bodyType: String? = null,
|
||||
@Expose var firebaseUid: String? = null,
|
||||
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
var customerId: Long = 0
|
||||
@Expose var customerId: Long = 0
|
||||
)
|
||||
|
@ -1,6 +1,7 @@
|
||||
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 javax.persistence.*
|
||||
@ -8,13 +9,11 @@ import javax.validation.constraints.NotNull
|
||||
|
||||
@Entity
|
||||
data class CustomerExerciseDevice (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
var customerExerciseDeviceId: Long = 0,
|
||||
@get: NotNull var exerciseDeviceId: Long?,
|
||||
@get: NotNull var customerId: Long?,
|
||||
@get: NotNull var favourite: Boolean?,
|
||||
@get: NotNull var dateAdd: String? = null
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var customerExerciseDeviceId: Long = 0,
|
||||
@Expose @get: NotNull var exerciseDeviceId: Long?,
|
||||
@Expose @get: NotNull var customerId: Long?,
|
||||
@Expose @get: NotNull var favourite: Boolean?,
|
||||
@Expose @get: NotNull var dateAdd: String? = null
|
||||
|
||||
)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
@ -8,9 +9,9 @@ import javax.persistence.Id
|
||||
|
||||
@Entity
|
||||
data class CustomerProperty (
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var customerPropertyId: Long = 0,
|
||||
@get: NonNull var customerId: Long = 0,
|
||||
@get: NonNull var propertyId: Long = 0,
|
||||
@get: NonNull var propertyValue: Double? = null,
|
||||
@get: NonNull var dateAdd: String? = null
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var customerPropertyId: Long = 0,
|
||||
@Expose @get: NonNull var customerId: Long = 0,
|
||||
@Expose @get: NonNull var propertyId: Long = 0,
|
||||
@Expose @get: NonNull var propertyValue: Double? = null,
|
||||
@Expose @get: NonNull var dateAdd: String? = null
|
||||
)
|
14
src/main/kotlin/com/aitrainer/api/model/ExerciseAbility.kt
Normal file
14
src/main/kotlin/com/aitrainer/api/model/ExerciseAbility.kt
Normal file
@ -0,0 +1,14 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class ExerciseAbility (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val exerciseAbilityId: Long = 0,
|
||||
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose @get: NotBlank var description: String = "",
|
||||
)
|
@ -1,5 +1,6 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import org.hibernate.annotations.Fetch
|
||||
import org.hibernate.annotations.FetchMode
|
||||
import javax.persistence.*
|
||||
@ -7,21 +8,19 @@ import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class ExerciseDevice (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val exerciseDeviceId: Long = 0,
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val exerciseDeviceId: Long = 0,
|
||||
|
||||
@get: NotBlank var name: String = "",
|
||||
@get: NotBlank var description: String = "",
|
||||
@get: NotBlank var imageUrl: String = "",
|
||||
@get: NotBlank var sort: Int = 0,
|
||||
@get: NotBlank var place: Int = 0
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose var description: String?,
|
||||
@Expose var imageUrl: String?,
|
||||
@Expose @get: NotBlank var sort: Int = 0,
|
||||
@Expose @get: NotBlank var place: Int = 0
|
||||
){
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseDevice")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val translations: List<ExerciseDeviceTranslation> = mutableListOf<ExerciseDeviceTranslation>().toList()
|
||||
@Expose val translations: List<ExerciseDeviceTranslation> = mutableListOf<ExerciseDeviceTranslation>().toList()
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseDevice")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val alternatives: List<ExerciseDeviceAlternative> = mutableListOf<ExerciseDeviceAlternative>().toList()
|
||||
@Expose val alternatives: List<ExerciseDeviceAlternative> = mutableListOf<ExerciseDeviceAlternative>().toList()
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.google.gson.annotations.Expose
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotNull
|
||||
|
||||
@Entity
|
||||
data class ExerciseDeviceAlternative (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
var exerciseDeviceAlternativeId: Long = 0,
|
||||
//@get: NotNull var exerciseDeviceParentId: Long?,
|
||||
@get: NotNull var exerciseDeviceChildId: Long?
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var exerciseDeviceAlternativeId: Long = 0,
|
||||
@Expose @get: NotNull var exerciseDeviceChildId: Long?
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name = "exerciseDeviceParentId", nullable = false)
|
||||
|
@ -1,23 +1,24 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.google.gson.annotations.Expose
|
||||
import kotlinx.serialization.Contextual
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class ExerciseDeviceTranslation (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val translationId: Long = 0,
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val translationId: Long = 0,
|
||||
|
||||
@get: NotBlank var languageCode: String?,
|
||||
@get: NotBlank var name: String = ""
|
||||
@Expose @get: NotBlank var languageCode: String?,
|
||||
@Expose @get: NotBlank var name: String = ""
|
||||
|
||||
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name = "exerciseDeviceId", nullable = false)
|
||||
@JsonIgnore
|
||||
@Contextual
|
||||
val exerciseDevice: ExerciseDevice? = null
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
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
|
||||
@ -9,16 +9,19 @@ import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class ExerciseTree (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val treeId: Long = 0,
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val treeId: Long = 0,
|
||||
|
||||
@get: NotBlank var name: String = "",
|
||||
@get: NotBlank var imageUrl: String = "",
|
||||
@get: NonNull var active: Boolean?
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose @get: NotBlank var imageUrl: String = "",
|
||||
@Expose @get: NonNull var active: Boolean?
|
||||
|
||||
) {
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseTree")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val translations: List<ExerciseTreeTranslation> = mutableListOf<ExerciseTreeTranslation>().toList()
|
||||
@Expose val translations: List<ExerciseTreeTranslation> = mutableListOf<ExerciseTreeTranslation>().toList()
|
||||
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseTree")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
@Expose val abilities: List<ExerciseTreeAbility> = mutableListOf()
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.google.gson.annotations.Expose
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotNull
|
||||
|
||||
@Entity
|
||||
data class ExerciseTreeAbility (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val exerciseTreeAbilityId: Long = 0,
|
||||
|
||||
@Expose @get: NotNull var exerciseAbilityId: Int?
|
||||
|
||||
) {
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name="exerciseTreeId", nullable=false)
|
||||
@JsonIgnore
|
||||
val exerciseTree: ExerciseTree? = null
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.google.gson.annotations.Expose
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotNull
|
||||
|
||||
@Entity
|
||||
data class ExerciseTreeParents (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
var exerciseTreeParentsId: Long = 0,
|
||||
@get: NotNull var exerciseTreeParentId: Long?,
|
||||
@get: NotNull var exerciseTreeChildId: Long?
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var exerciseTreeParentsId: Long = 0,
|
||||
@Expose @get: NotNull var exerciseTreeParentId: Long?,
|
||||
@Expose @get: NotNull var exerciseTreeChildId: Long?
|
||||
)
|
||||
|
||||
|
@ -1,17 +1,16 @@
|
||||
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 ExerciseTreeTranslation (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val translationId: Long = 0,
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val translationId: Long = 0,
|
||||
|
||||
@get: NotBlank var languageCode: String?,
|
||||
@get: NotBlank var name: String = ""
|
||||
@Expose @get: NotBlank var languageCode: String?,
|
||||
@Expose @get: NotBlank var name: String = ""
|
||||
|
||||
|
||||
) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import org.hibernate.annotations.FetchMode
|
||||
import org.hibernate.annotations.Fetch
|
||||
import org.springframework.lang.NonNull
|
||||
@ -9,39 +10,35 @@ import javax.validation.constraints.Null
|
||||
|
||||
@Entity
|
||||
data class ExerciseType(
|
||||
@get: NonNull var treeId: Int,
|
||||
@get: NotBlank var name: String = "",
|
||||
@get: NotBlank var description: String = "",
|
||||
@get: Null var unit: String?,
|
||||
@get: Null var unitQuantity: String?,
|
||||
@get: Null var unitQuantityUnit: String?,
|
||||
@get: NonNull var active: Boolean?,
|
||||
@get: NonNull var base: Boolean?,
|
||||
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose @get: NotBlank var description: String = "",
|
||||
@Expose @get: Null var unit: String?,
|
||||
@Expose @get: Null var unitQuantity: String?,
|
||||
@Expose @get: Null var unitQuantityUnit: String?,
|
||||
@Expose @get: NonNull var active: Boolean?,
|
||||
@Expose @get: NonNull var base: Boolean?,
|
||||
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val exerciseTypeId: Long = 0
|
||||
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val exerciseTypeId: Long = 0,
|
||||
|
||||
) {
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val images: List<ExerciseTypeImage> = mutableListOf<ExerciseTypeImage>()
|
||||
@Expose val images: List<ExerciseTypeImage> = mutableListOf()
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val translations: List<ExerciseTypeTranslation> = mutableListOf<ExerciseTypeTranslation>()
|
||||
@Expose val translations: List<ExerciseTypeTranslation> = mutableListOf()
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val alternatives: List<ExerciseTypeAlternative> = mutableListOf<ExerciseTypeAlternative>()
|
||||
@Expose val alternatives: List<ExerciseTypeAlternative> = mutableListOf()
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val parents: List<ExerciseTypeParents> = mutableListOf<ExerciseTypeParents>()
|
||||
@Expose val parents: List<ExerciseTypeParents> = mutableListOf()
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val devices: List<ExerciseTypeDevice> = mutableListOf<ExerciseTypeDevice>()
|
||||
|
||||
@Expose val devices: List<ExerciseTypeDevice> = mutableListOf()
|
||||
}
|
||||
|
@ -1,16 +1,14 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.google.gson.annotations.Expose
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotNull
|
||||
|
||||
@Entity
|
||||
data class ExerciseTypeAlternative (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
var exerciseTypeAlternativeId: Long = 0,
|
||||
//@get: NotNull var exerciseTypeParentId: Long?,
|
||||
@get: NotNull var exerciseTypeChildId: Long?
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var exerciseTypeAlternativeId: Long = 0,
|
||||
@Expose @get: NotNull var exerciseTypeChildId: Long?
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name = "exerciseTypeParentId", nullable = false)
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.google.gson.annotations.Expose
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotNull
|
||||
|
||||
@Entity
|
||||
data class ExerciseTypeDevice (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val exerciseTypeDeviceId: Long = 0,
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val exerciseTypeDeviceId: Long = 0,
|
||||
|
||||
@get: NotNull var exerciseDeviceId: Int?
|
||||
@Expose @get: NotNull var exerciseDeviceId: Int?
|
||||
|
||||
) {
|
||||
|
||||
|
@ -1,20 +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 ExerciseTypeImage (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val imageId: Long = 0,
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val imageId: Long = 0,
|
||||
|
||||
//@get: NonNull var exerciseTypeId: Integer?,
|
||||
@get: NotBlank var name: String = "",
|
||||
@get: NotBlank var type: String = "",
|
||||
@get: NotBlank var url: String = ""
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose @get: NotBlank var type: String = "",
|
||||
@Expose @get: NotBlank var url: String = ""
|
||||
|
||||
) {
|
||||
|
||||
|
@ -1,16 +1,14 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.google.gson.annotations.Expose
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotNull
|
||||
|
||||
@Entity
|
||||
data class ExerciseTypeParents (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
var exerciseTypeParentsId: Long = 0,
|
||||
@get: NotNull var exerciseTreeId: Long?
|
||||
//@get: NotNull var exerciseTypeId: Long?
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var exerciseTypeParentsId: Long = 0,
|
||||
@Expose @get: NotNull var exerciseTreeId: Long?
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name = "exerciseTypeId", nullable = false)
|
||||
|
@ -1,18 +1,17 @@
|
||||
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 ExerciseTypeTranslation (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val translationId: Long = 0,
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val translationId: Long = 0,
|
||||
|
||||
@get: NotBlank var languageCode: String?,
|
||||
@get: NotBlank var name: String = "",
|
||||
@get: NotBlank var description: String = ""
|
||||
@Expose @get: NotBlank var languageCode: String?,
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose @get: NotBlank var description: String = ""
|
||||
) {
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
@ -9,15 +10,14 @@ import javax.validation.constraints.Null
|
||||
|
||||
@Entity
|
||||
data class Exercises (
|
||||
@get: NonNull var exerciseTypeId: Long = 0,
|
||||
@get: NonNull var customerId: Long = 0,
|
||||
@get: NonNull var dateAdd: String? = null,
|
||||
@get: NonNull var quantity: Double? = null,
|
||||
@get: Null var restTime: Int?, // in seconds
|
||||
@get: NonNull var unit: String? = null,
|
||||
@get: NonNull var unitQuantity: Double? = null,
|
||||
@get: NonNull var exercisePlanDetailId: Int = 0,
|
||||
@Expose @get: NonNull var exerciseTypeId: Long = 0,
|
||||
@Expose @get: NonNull var customerId: Long = 0,
|
||||
@Expose @get: NonNull var dateAdd: String? = null,
|
||||
@Expose @get: NonNull var quantity: Double? = null,
|
||||
@Expose @get: Null var restTime: Int?, // in seconds
|
||||
@Expose @get: NonNull var unit: String? = null,
|
||||
@Expose @get: NonNull var unitQuantity: Double? = null,
|
||||
@Expose @get: NonNull var exercisePlanDetailId: Int = 0,
|
||||
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val exerciseId: Long = 0
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val exerciseId: Long = 0
|
||||
)
|
@ -1,5 +1,6 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
@ -15,18 +16,18 @@ import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class Product (
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var productId: Int,
|
||||
@get: NotBlank var name: String = "",
|
||||
@get: NotBlank var description: String = "",
|
||||
@get: NonNull var appVersion: String? = null,
|
||||
@get: NonNull var productSet: Int? = null,
|
||||
@get: NonNull var sort: Int? = null,
|
||||
@get: NonNull var type: String? = null,
|
||||
@get: NonNull var validFrom: String? = null,
|
||||
@get: NonNull var validTo: String? = null,
|
||||
@get: NonNull var productIdIos: String? = null,
|
||||
@get: NonNull var productIdAndroid: String? = null,
|
||||
@get: NonNull var priceIos: Double? = null,
|
||||
@get: NonNull var priceAndroid: Double? = null
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var productId: Int,
|
||||
@Expose @get: NotBlank var name: String = "",
|
||||
@Expose @get: NotBlank var description: String = "",
|
||||
@Expose @get: NonNull var appVersion: String? = null,
|
||||
@Expose @get: NonNull var productSet: Int? = null,
|
||||
@Expose @get: NonNull var sort: Int? = null,
|
||||
@Expose @get: NonNull var type: String? = null,
|
||||
@Expose @get: NonNull var validFrom: String? = null,
|
||||
@Expose @get: NonNull var validTo: String? = null,
|
||||
@Expose @get: NonNull var productIdIos: String? = null,
|
||||
@Expose @get: NonNull var productIdAndroid: String? = null,
|
||||
@Expose @get: NonNull var priceIos: Double? = null,
|
||||
@Expose @get: NonNull var priceAndroid: Double? = null
|
||||
|
||||
)
|
@ -1,5 +1,6 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
@ -8,9 +9,9 @@ import javax.persistence.Id
|
||||
|
||||
@Entity
|
||||
data class ProductTest (
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var productTestId: Int = 0,
|
||||
@get: NonNull var customerId: Long = 0,
|
||||
@get: NonNull var productId: Int = 0,
|
||||
@get: NonNull var dateView: String? = null,
|
||||
@get: NonNull var purchaseClick: Boolean = false
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var productTestId: Int = 0,
|
||||
@Expose @get: NonNull var customerId: Long = 0,
|
||||
@Expose @get: NonNull var productId: Int = 0,
|
||||
@Expose @get: NonNull var dateView: String? = null,
|
||||
@Expose @get: NonNull var purchaseClick: Boolean = false
|
||||
)
|
@ -1,5 +1,7 @@
|
||||
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
|
||||
@ -8,12 +10,12 @@ import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class Property (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var propertyId: Long = 0,
|
||||
@get: NotBlank var propertyName: String = "",
|
||||
@get: NotBlank var propertyUnit: String = ""
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var propertyId: Long = 0,
|
||||
@Expose @get: NotBlank var propertyName: String = "",
|
||||
@Expose @get: NotBlank var propertyUnit: String = ""
|
||||
) {
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "property")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val translations: List<PropertyTranslation> = mutableListOf<PropertyTranslation>().toList()
|
||||
@Expose val translations: List<PropertyTranslation> = mutableListOf<PropertyTranslation>().toList()
|
||||
|
||||
}
|
@ -1,21 +1,24 @@
|
||||
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 PropertyTranslation (
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) val translationId: Long = 0,
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val translationId: Long = 0,
|
||||
|
||||
@get: NotBlank var languageCode: String?,
|
||||
@get: NotBlank var propertyName: String = ""
|
||||
@Expose @get: NotBlank var languageCode: String?,
|
||||
@Expose @get: NotBlank var propertyName: String = "",
|
||||
|
||||
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "propertyId", nullable = false)
|
||||
@JsonIgnore
|
||||
val property: Property? = null
|
||||
|
||||
/* override fun toString() : String {
|
||||
return "PropertyTranslation [id=$translationId, languageCode=$languageCode, propertyName=$propertyName]"
|
||||
}*/
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
@ -9,10 +10,10 @@ import javax.validation.constraints.NotBlank
|
||||
|
||||
@Entity
|
||||
data class Purchase (
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var purchaseId: Long = 0,
|
||||
@get: NonNull var customerId: Long = 0,
|
||||
@get: NonNull var productId: Int = 0,
|
||||
@get: NonNull var purchaseSum: Double? = null,
|
||||
@get: NonNull var dateAdd: String? = null,
|
||||
@get: NotBlank var currency: String = ""
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var purchaseId: Long = 0,
|
||||
@Expose @get: NonNull var customerId: Long = 0,
|
||||
@Expose @get: NonNull var productId: Int = 0,
|
||||
@Expose @get: NonNull var purchaseSum: Double? = null,
|
||||
@Expose @get: NonNull var dateAdd: String? = null,
|
||||
@Expose @get: NotBlank var currency: String = ""
|
||||
)
|
19
src/main/kotlin/com/aitrainer/api/model/Tracking.kt
Normal file
19
src/main/kotlin/com/aitrainer/api/model/Tracking.kt
Normal file
@ -0,0 +1,19 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
import javax.persistence.GenerationType
|
||||
import javax.persistence.Id
|
||||
|
||||
@Entity
|
||||
data class Tracking (
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var trackingId: Long = 0,
|
||||
@get: NonNull var customerId: Long = 0,
|
||||
@get: NonNull var dateAdd: String? = null,
|
||||
@get: NonNull var event: String = "",
|
||||
var eventValue: Double? = null,
|
||||
var area: String = "",
|
||||
var platform: String = "",
|
||||
var version: String = ""
|
||||
)
|
@ -0,0 +1,9 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.ExerciseAbility
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface ExerciseAbilityRepository: JpaRepository<ExerciseAbility, Long> {
|
||||
}
|
@ -10,6 +10,7 @@ interface ExerciseTreeRepository : JpaRepository<ExerciseTree, Long> {
|
||||
|
||||
@Query("FROM ExerciseTree as e " +
|
||||
"LEFT JOIN ExerciseTreeTranslation as t ON e.treeId = t.exerciseTree AND t.languageCode = 'hu' " +
|
||||
"LEFT JOIN ExerciseTreeAbility as t ON e.treeId = t.exerciseTree " +
|
||||
"WHERE e.active = 1 " +
|
||||
"ORDER BY e.treeId ")
|
||||
fun getActiveMenu(): List<ExerciseTree>
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.Tracking
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface TrackingRepository: JpaRepository<Tracking, 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.23
|
||||
application.version=1.0.24
|
||||
|
||||
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.23
|
||||
application.version=1.0.24
|
||||
|
||||
jwt.secret=aitrainer
|
101
src/test/kotlin/com/aitrainer/api/test/AppCustomerPackageTest.kt
Normal file
101
src/test/kotlin/com/aitrainer/api/test/AppCustomerPackageTest.kt
Normal file
@ -0,0 +1,101 @@
|
||||
package com.aitrainer.api.test
|
||||
|
||||
import com.aitrainer.api.controller.CustomerPackageController
|
||||
import com.aitrainer.api.model.*
|
||||
import com.aitrainer.api.repository.*
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.ResponseEntity
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@SpringBootTest
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class AppCustomerPackageTest {
|
||||
|
||||
@Autowired
|
||||
private lateinit var customerRepository: CustomerRepository
|
||||
|
||||
@Autowired
|
||||
private lateinit var customerExerciseDeviceRepository: CustomerExerciseDeviceRepository
|
||||
|
||||
@Autowired
|
||||
private lateinit var exercisesRepository: ExercisesRepository
|
||||
|
||||
@Autowired
|
||||
private lateinit var productTestRepository: ProductTestRepository
|
||||
|
||||
@Autowired
|
||||
private lateinit var purchaseRepository: PurchaseRepository
|
||||
|
||||
@Autowired
|
||||
private lateinit var customerPropertyRepository: CustomerPropertyRepository
|
||||
|
||||
@Autowired
|
||||
private lateinit var exerciseResultRepository: ExerciseResultRepository
|
||||
|
||||
@Test
|
||||
fun customerPackageTest() {
|
||||
val gson = Gson()
|
||||
|
||||
val controller = CustomerPackageController(customerRepository, customerExerciseDeviceRepository,
|
||||
exercisesRepository, productTestRepository, purchaseRepository, customerPropertyRepository,
|
||||
exerciseResultRepository)
|
||||
var response: ResponseEntity<*> = controller.getCustomerPackageData(91)
|
||||
assertEquals(response.statusCode, HttpStatus.NOT_FOUND)
|
||||
|
||||
response = controller.getCustomerPackageData(90)
|
||||
assertEquals(response.statusCode, HttpStatus.OK)
|
||||
|
||||
val appPackageJson: String = response.body as String
|
||||
assertTrue(appPackageJson.isNotEmpty())
|
||||
|
||||
|
||||
val packages = appPackageJson.split("|||").toTypedArray()
|
||||
|
||||
packages.forEach {
|
||||
val record = it.split("***")
|
||||
print(record[0] + "\n")
|
||||
if (record[0] == Customer::class.simpleName) {
|
||||
val customerJson: String = record[1]
|
||||
val type = object : TypeToken<Customer?>() {}.type
|
||||
val customer: Customer = gson.fromJson(customerJson, type)
|
||||
assertEquals(customer.email, "sw@andio.biz")
|
||||
assertEquals(customer.birthYear, 1972)
|
||||
} else if (record[0] == Exercises::class.simpleName) {
|
||||
val exercisesJson: String = record[1]
|
||||
val type = object : TypeToken<List<Exercises?>?>() {}.type
|
||||
val exerciseList: List<Exercises> = gson.fromJson(exercisesJson, type)
|
||||
assertTrue(exerciseList.isNotEmpty())
|
||||
assertEquals(exerciseList[0].exerciseTypeId, 37)
|
||||
assertEquals(exerciseList[0].quantity, 40.0)
|
||||
} else if (record[0] == CustomerExerciseDevice::class.simpleName) {
|
||||
val exerciseDeviceJson: String = record[1]
|
||||
val type = object : TypeToken<List<CustomerExerciseDevice?>?>() {}.type
|
||||
val customerExerciseDeviceList: List<CustomerExerciseDevice> = gson.fromJson(exerciseDeviceJson, type)
|
||||
assertTrue(customerExerciseDeviceList.isNotEmpty())
|
||||
assertEquals(customerExerciseDeviceList[1].exerciseDeviceId,2)
|
||||
} else if (record[0] == ProductTest::class.simpleName) {
|
||||
val productTestJson: String = record[1]
|
||||
val type = object : TypeToken<List<ProductTest?>?>() {}.type
|
||||
val productTestList: List<ProductTest> = gson.fromJson(productTestJson, type)
|
||||
assertTrue(productTestList.isNotEmpty())
|
||||
assertEquals(productTestList[0].productId,1)
|
||||
} else if (record[0] == CustomerProperty::class.simpleName) {
|
||||
val propertyJson: String = record[1]
|
||||
val type = object : TypeToken<List<CustomerProperty?>?>() {}.type
|
||||
val propertyList: List<CustomerProperty> = gson.fromJson(propertyJson, type)
|
||||
assertTrue(propertyList.isNotEmpty())
|
||||
assertEquals(propertyList[1].propertyId,1)
|
||||
assertEquals(propertyList[1].propertyValue,82.0)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
95
src/test/kotlin/com/aitrainer/api/test/AppPackageTest.kt
Normal file
95
src/test/kotlin/com/aitrainer/api/test/AppPackageTest.kt
Normal file
@ -0,0 +1,95 @@
|
||||
package com.aitrainer.api.test
|
||||
|
||||
import com.aitrainer.api.controller.PackageController
|
||||
import com.aitrainer.api.model.*
|
||||
import com.aitrainer.api.repository.*
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.http.ResponseEntity
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@SpringBootTest
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class AppPackageTest {
|
||||
|
||||
@Autowired
|
||||
private lateinit var exerciseAbilityRepository: ExerciseAbilityRepository
|
||||
@Autowired
|
||||
private lateinit var exerciseTypeRepository: ExerciseTypeRepository
|
||||
@Autowired
|
||||
private lateinit var exerciseTreeRepository: ExerciseTreeRepository
|
||||
@Autowired
|
||||
private lateinit var propertyRepository: PropertyRepository
|
||||
@Autowired
|
||||
private lateinit var productRepository: ProductRepository
|
||||
@Autowired
|
||||
private lateinit var exerciseDeviceRepository: ExerciseDeviceRepository
|
||||
@Autowired
|
||||
private lateinit var exerciseTreeParentsRepository: ExerciseTreeParentsRepository
|
||||
|
||||
@Test
|
||||
fun testAppPackage() {
|
||||
val gson = Gson()
|
||||
|
||||
val controller = PackageController(
|
||||
exerciseAbilityRepository,
|
||||
exerciseTypeRepository,
|
||||
exerciseTreeRepository,
|
||||
propertyRepository,
|
||||
productRepository,
|
||||
exerciseDeviceRepository,
|
||||
exerciseTreeParentsRepository
|
||||
)
|
||||
val response: ResponseEntity<*> = controller.getPackageData()
|
||||
|
||||
val appPackageJson: String = response.body as String
|
||||
assertTrue(appPackageJson.isNotEmpty())
|
||||
|
||||
|
||||
val packages = appPackageJson.split("|||").toTypedArray()
|
||||
|
||||
packages.forEach {
|
||||
val record = it.split("***")
|
||||
print(record[0] + "\n")
|
||||
if ( record[0] == ExerciseType::class.simpleName) {
|
||||
print("List ExerciseType: " + record[1])
|
||||
val exerciseTypeJson: String = record[1]
|
||||
val type = object : TypeToken<List<ExerciseType?>?>() {}.type
|
||||
val listExerciseType: List<ExerciseType> = gson.fromJson(exerciseTypeJson, type)
|
||||
assertTrue(listExerciseType.isNotEmpty())
|
||||
assertEquals(listExerciseType[1].name, "Biceps")
|
||||
assertEquals(listExerciseType[1].translations[0].name, "Bicepsz")
|
||||
} else if (record[0] == ExerciseTree::class.simpleName) {
|
||||
val exerciseTreeJson: String = record[1]
|
||||
val type = object : TypeToken<List<ExerciseTree?>?>() {}.type
|
||||
val listExerciseTree: List<ExerciseTree> = gson.fromJson(exerciseTreeJson, type)
|
||||
assertTrue(listExerciseTree.isNotEmpty())
|
||||
assertEquals(listExerciseTree[1].name, "Strength")
|
||||
assertEquals(listExerciseTree[1].translations[0].name, "Erő!")
|
||||
} else if (record[0] == Property::class.simpleName) {
|
||||
val propertyJson: String = record[1]
|
||||
val type = object : TypeToken<List<Property?>?>() {}.type
|
||||
val listProperty: List<Property> = gson.fromJson(propertyJson, type)
|
||||
assertTrue(listProperty.isNotEmpty())
|
||||
assertEquals(listProperty[2].propertyName, "Chest")
|
||||
assertEquals(listProperty[0].translations[0].propertyName, "Tömeg")
|
||||
} else if (record[0] == ExerciseTreeParents::class.simpleName) {
|
||||
val exerciseTreeParentsJson: String = record[1]
|
||||
val type = object : TypeToken<List<ExerciseTreeParents?>?>() {}.type
|
||||
val listParents: List<ExerciseTreeParents> = gson.fromJson(exerciseTreeParentsJson, type)
|
||||
assertTrue(listParents.isNotEmpty())
|
||||
assertEquals(listParents[2].exerciseTreeParentId, 0)
|
||||
assertEquals(listParents[6].exerciseTreeParentId, 4)
|
||||
assertEquals(listParents[6].exerciseTreeChildId, 9)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.aitrainer.api.test
|
||||
|
||||
import com.aitrainer.api.controller.ExerciseAbilityController
|
||||
import com.aitrainer.api.controller.ExerciseDeviceController
|
||||
import com.aitrainer.api.repository.ExerciseAbilityRepository
|
||||
import com.aitrainer.api.repository.ExerciseDeviceRepository
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@SpringBootTest
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class ExerciseAbilityTest {
|
||||
|
||||
@Autowired
|
||||
private lateinit var exerciseAbilityRepository: ExerciseAbilityRepository
|
||||
|
||||
|
||||
@Test
|
||||
fun testGetExerciseAbilities() {
|
||||
val controller = ExerciseAbilityController(exerciseAbilityRepository )
|
||||
val response = controller.getAbilities()
|
||||
|
||||
val abilities = response.body
|
||||
|
||||
assertTrue(abilities is List)
|
||||
assertTrue(abilities.isNotEmpty())
|
||||
assertEquals(abilities.size, 3)
|
||||
assertEquals(abilities[0].name, "1RM")
|
||||
assertEquals(abilities[1].name, "Endurance")
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,7 @@ class ExerciseResultTest {
|
||||
|
||||
val exerciseResults = response.body
|
||||
assertTrue(exerciseResults is List)
|
||||
assertEquals(exerciseResults!!.size, 4)
|
||||
assertEquals(exerciseResults.size, 4)
|
||||
assertEquals(exerciseResults[0].customerId, 90)
|
||||
assertEquals(exerciseResults[0].exerciseId, 1)
|
||||
assertEquals(exerciseResults[0].value, 134.0)
|
||||
@ -51,7 +51,7 @@ class ExerciseResultTest {
|
||||
val exerciseNew = response.body
|
||||
|
||||
assertTrue(exerciseNew is ExerciseResult)
|
||||
assertTrue(exerciseNew!!.exercisePlanId == null)
|
||||
assertTrue(exerciseNew.exercisePlanId == null)
|
||||
assertEquals(exerciseNew.customerId, 103)
|
||||
assertEquals(exerciseNew.resultType, "calorie")
|
||||
|
||||
|
@ -28,5 +28,6 @@ class ExerciseTreeTest {
|
||||
val exerciseTreeItem = responseEntity.body!![0]
|
||||
assertEquals(exerciseTreeItem.name, "Cardio")
|
||||
assertEquals(responseEntity.body!![1].translations[0].name, "Erő!")
|
||||
assertEquals(responseEntity.body!![0].abilities[0].exerciseAbilityId, 3)
|
||||
}
|
||||
}
|
@ -52,7 +52,7 @@ class ExerciseTypeTest {
|
||||
@Test
|
||||
fun testInsert(){
|
||||
logger.info("Add 'Húzodszkodás 2")
|
||||
val newEx = ExerciseType( 0,"Húzodszkodás 2", " A legtöbb húzodszkodást 24 óra alatt John Ort érte el 7600-al 2016-ban. ", null, null, null ,true, false)
|
||||
val newEx = ExerciseType( "Húzodszkodás 2", " A legtöbb húzodszkodást 24 óra alatt John Ort érte el 7600-al 2016-ban. ", null, null, null ,true, false)
|
||||
val savedEx: ExerciseType = exerciseTypeRepository.save(newEx)
|
||||
assertEquals(savedEx.name, "Húzodszkodás 2")
|
||||
|
||||
|
@ -25,7 +25,7 @@ class ProductTesting {
|
||||
val products = response.body
|
||||
|
||||
assertTrue(products is List)
|
||||
assertTrue(products!!.isNotEmpty())
|
||||
assertTrue(products.isNotEmpty())
|
||||
assertEquals(products.size, 18)
|
||||
assertEquals(products[0].name, "Subscription A")
|
||||
assertEquals(products[0].productIdIos, "p_ios_1")
|
||||
|
@ -14,10 +14,10 @@ class PropertiesTest {
|
||||
|
||||
@Test
|
||||
fun testDatasourceUrl() {
|
||||
//val url: String = properties.getDatasourceUrl()
|
||||
//assertEquals(url, "jdbc:mysql://localhost:3306/aitrainer2?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true")
|
||||
val url: String = properties.getDatasourceUrl()
|
||||
assertEquals(url, "jdbc:mysql://localhost:3306/aitrainer2?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true")
|
||||
val dialect: String = properties.getDatasourceUsername()
|
||||
//assertEquals(dialect, "root")
|
||||
assertEquals(dialect, "aitrainer")
|
||||
}
|
||||
|
||||
}
|
53
src/test/kotlin/com/aitrainer/api/test/TrackingTest.kt
Normal file
53
src/test/kotlin/com/aitrainer/api/test/TrackingTest.kt
Normal file
@ -0,0 +1,53 @@
|
||||
package com.aitrainer.api.test
|
||||
|
||||
import com.aitrainer.api.controller.ExerciseController
|
||||
import com.aitrainer.api.controller.TrackingController
|
||||
import com.aitrainer.api.model.Exercises
|
||||
import com.aitrainer.api.model.Tracking
|
||||
import com.aitrainer.api.repository.ExercisesRepository
|
||||
import com.aitrainer.api.repository.TrackingRepository
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.ResponseEntity
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@SpringBootTest
|
||||
class TrackingTest {
|
||||
|
||||
@Autowired
|
||||
private lateinit var trackingRepository: TrackingRepository
|
||||
|
||||
|
||||
@Test
|
||||
fun testInsert() {
|
||||
var tracking = Tracking(
|
||||
customerId = 90,
|
||||
dateAdd = "2021-02-04 23:40:00",
|
||||
event = "Home"
|
||||
)
|
||||
val trackingNew = trackingRepository.save(tracking)
|
||||
assertEquals(trackingNew.event, "Home")
|
||||
trackingRepository.delete(tracking)
|
||||
|
||||
tracking = Tracking(
|
||||
customerId = 90,
|
||||
dateAdd = "2021-02-04 23:42:00",
|
||||
event = "SalesPage",
|
||||
platform = "iOS",
|
||||
version = "1.1.5"
|
||||
)
|
||||
|
||||
val controller = TrackingController(trackingRepository)
|
||||
val response = controller.createNewTracking(tracking)
|
||||
assertEquals(response.statusCode, HttpStatus.OK)
|
||||
assertTrue(response.body is Tracking )
|
||||
val trackingResponse = response.body
|
||||
assertEquals(trackingResponse!!.event, "SalesPage")
|
||||
assertEquals(trackingResponse.version, "1.1.5")
|
||||
trackingRepository.delete(trackingResponse)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user