From 41b10c4268ff195fe3a8dbe2b20df9604cdbaa96 Mon Sep 17 00:00:00 2001 From: Bossanyi Tibor Date: Sat, 6 Feb 2021 15:16:06 +0100 Subject: [PATCH] V1.0.24+2 CustomerProperty actual into the app-package --- .../controller/CustomerPackageController.kt | 6 +++++- .../com/aitrainer/api/model/ExerciseResult.kt | 19 +++++++++---------- .../api/test/AppCustomerPackageTest.kt | 8 ++++++++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/aitrainer/api/controller/CustomerPackageController.kt b/src/main/kotlin/com/aitrainer/api/controller/CustomerPackageController.kt index c6707e0..7c4e9ef 100644 --- a/src/main/kotlin/com/aitrainer/api/controller/CustomerPackageController.kt +++ b/src/main/kotlin/com/aitrainer/api/controller/CustomerPackageController.kt @@ -47,9 +47,12 @@ class CustomerPackageController( private val customerRepository: CustomerReposit val listPurchase = purchaseRepository.findByCustomerId(customerId) val listPurchaseJson = gson.toJson(listPurchase) - val listCustomerProperty = customerPropertyRepository.findAllByCustomerId(customerId) + val listCustomerPropertyAll = customerPropertyRepository.findAllByCustomerId(customerId) + val listCustomerPropertyAllJson = gson.toJson(listCustomerPropertyAll) + val listCustomerProperty = customerPropertyRepository.findLastPropertiesByCustomerId(customerId) val listCustomerPropertyJson = gson.toJson(listCustomerProperty) + val listExerciseResult = exerciseResultRepository.getAllByCustomerId(customerId) val listExerciseResultJson = gson.toJson(listExerciseResult) @@ -59,6 +62,7 @@ class CustomerPackageController( private val customerRepository: CustomerReposit "|||" + getClassRecord(Exercises::class.simpleName, listExercisesJson) + "|||" + getClassRecord(ProductTest::class.simpleName, listProductTestJson) + "|||" + getClassRecord(Purchase::class.simpleName, listPurchaseJson) + + "|||" + getClassRecord(CustomerProperty::class.simpleName+"All", listCustomerPropertyAllJson) + "|||" + getClassRecord(CustomerProperty::class.simpleName, listCustomerPropertyJson) + "|||" + getClassRecord(ExerciseResult::class.simpleName, listExerciseResultJson) diff --git a/src/main/kotlin/com/aitrainer/api/model/ExerciseResult.kt b/src/main/kotlin/com/aitrainer/api/model/ExerciseResult.kt index 4fc477f..91eb176 100644 --- a/src/main/kotlin/com/aitrainer/api/model/ExerciseResult.kt +++ b/src/main/kotlin/com/aitrainer/api/model/ExerciseResult.kt @@ -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,15 +9,13 @@ import javax.persistence.Id @Entity data class ExerciseResult( - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - val exerciseResultId: Long = 0, - - @get: NonNull var customerId: Long = 0, - @get: NonNull var exerciseId: Long = 0, - @get: NonNull var exercisePlanId: Long? = null, - @get: NonNull var resultType: String? = null, - @get: NonNull var value: Double? = null, - @get: NonNull var dateFrom: String? = null, - @get: NonNull var dateTo: String? = null + @Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val exerciseResultId: Long = 0, + @Expose @get: NonNull var customerId: Long = 0, + @Expose @get: NonNull var exerciseId: Long = 0, + @Expose @get: NonNull var exercisePlanId: Long? = null, + @Expose @get: NonNull var resultType: String? = null, + @Expose @get: NonNull var value: Double? = null, + @Expose @get: NonNull var dateFrom: String? = null, + @Expose @get: NonNull var dateTo: String? = null ) \ No newline at end of file diff --git a/src/test/kotlin/com/aitrainer/api/test/AppCustomerPackageTest.kt b/src/test/kotlin/com/aitrainer/api/test/AppCustomerPackageTest.kt index a6dcfb9..50fccc6 100644 --- a/src/test/kotlin/com/aitrainer/api/test/AppCustomerPackageTest.kt +++ b/src/test/kotlin/com/aitrainer/api/test/AppCustomerPackageTest.kt @@ -87,6 +87,14 @@ class AppCustomerPackageTest { assertTrue(productTestList.isNotEmpty()) assertEquals(productTestList[0].productId,1) } else if (record[0] == CustomerProperty::class.simpleName) { + //actual values + val propertyJson: String = record[1] + val type = object : TypeToken?>() {}.type + val propertyList: List = gson.fromJson(propertyJson, type) + assertTrue(propertyList.isNotEmpty()) + assertEquals(propertyList[1].propertyId,4) + assertEquals(propertyList[1].propertyValue,37.0) + } else if (record[0] == CustomerProperty::class.simpleName+"All") { val propertyJson: String = record[1] val type = object : TypeToken?>() {}.type val propertyList: List = gson.fromJson(propertyJson, type)