API 1.0.46 TrainingPlanDay
This commit is contained in:
@@ -70,11 +70,6 @@ class ControllerAspect {
|
||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||
}
|
||||
|
||||
@Before("execution(* com.aitrainer.api.controller.ProductTestController.*(..))")
|
||||
fun productTestControllerAspect(joinPoint: JoinPoint) {
|
||||
println("product test controller")
|
||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||
}
|
||||
|
||||
@Before("execution(* com.aitrainer.api.controller.PropertyController.*(..))")
|
||||
fun propertyControllerAspect(joinPoint: JoinPoint) {
|
||||
@@ -94,4 +89,31 @@ class ControllerAspect {
|
||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||
}
|
||||
|
||||
@Before("execution(* com.aitrainer.api.controller.SportController.*(..))")
|
||||
fun sportControllerAspect(joinPoint: JoinPoint) {
|
||||
println("sport controller")
|
||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||
}
|
||||
|
||||
@Before("execution(* com.aitrainer.api.controller.TrackingController.*(..))")
|
||||
fun trackingControllerAspect(joinPoint: JoinPoint) {
|
||||
println("tracking controller")
|
||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||
}
|
||||
|
||||
@Before("execution(* com.aitrainer.api.controller.PackageController.*(..))")
|
||||
fun packageControllerAspect(joinPoint: JoinPoint) {
|
||||
println("package controller")
|
||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||
}
|
||||
|
||||
@Before("execution(* com.aitrainer.api.controller.CustomerPackageController.*(..))")
|
||||
fun customerPackageControllerAspect(joinPoint: JoinPoint) {
|
||||
println("customerPackage controller")
|
||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.RestController
|
||||
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,
|
||||
@@ -44,9 +43,6 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
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)
|
||||
|
||||
@@ -69,7 +65,6 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
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+"All", listCustomerPropertyAllJson) +
|
||||
"|||" + getClassRecord(CustomerProperty::class.simpleName, listCustomerPropertyJson) +
|
||||
|
||||
@@ -26,7 +26,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
private val descriptionRepository: DescriptionRepository,
|
||||
private val faqRepository: FaqRepository,
|
||||
private val trainingPlanRepository: TrainingPlanRepository,
|
||||
private val splitTestsRepository: SplitTestsRepository
|
||||
private val splitTestsRepository: SplitTestsRepository,
|
||||
private val trainingPlanDayRepository: TrainingPlanDayRepository
|
||||
) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@@ -83,6 +84,9 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
val listSplitTests = splitTestsRepository.findAll()
|
||||
val listSplitTestsJson = gson.toJson(listSplitTests)
|
||||
|
||||
val listTrainingPlanDay = trainingPlanDayRepository.findAll()
|
||||
val listTrainingPlanDayJson = gson.toJson(listTrainingPlanDay)
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
||||
"|||" + getClassRecord(Product::class.simpleName, listProductsJson) +
|
||||
@@ -98,7 +102,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
"|||" + getClassRecord(Description::class.simpleName, listDescriptionJson) +
|
||||
"|||" + getClassRecord(Faq::class.simpleName, listFaqJson) +
|
||||
"|||" + getClassRecord(TrainingPlan::class.simpleName, listTrainingPlanJson) +
|
||||
"|||" + getClassRecord(SplitTests::class.simpleName, listSplitTestsJson)
|
||||
"|||" + getClassRecord(SplitTests::class.simpleName, listSplitTestsJson) +
|
||||
"|||" + getClassRecord(TrainingPlanDay::class.simpleName, listTrainingPlanDayJson)
|
||||
|
||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(packageJson)
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.ProductTest
|
||||
import com.aitrainer.api.repository.ProductTestRepository
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import javax.validation.Valid
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class ProductTestController(private val productTestRepository: ProductTestRepository) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@GetMapping("/product_test/customer/{id}")
|
||||
fun getAllByCustomerId(@PathVariable(value = "id") customerId: Long): ResponseEntity<List<ProductTest>> {
|
||||
|
||||
val productTestList = productTestRepository.findByCustomerId(customerId)
|
||||
logger.info("Get all productTest by customerId $productTestList")
|
||||
|
||||
return if(productTestList.isNotEmpty())
|
||||
ResponseEntity.ok().body(productTestList) else
|
||||
ResponseEntity.notFound().build()
|
||||
}
|
||||
|
||||
@PostMapping("/product_test")
|
||||
fun insertProductTest(@Valid @RequestBody productTest: ProductTest): ResponseEntity<ProductTest> {
|
||||
val newProductTest = productTestRepository.save(productTest)
|
||||
logger.info("Create new productTest: $newProductTest")
|
||||
return ResponseEntity.ok().body(newProductTest)
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import org.springframework.lang.NonNull
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
import javax.persistence.GenerationType
|
||||
import javax.persistence.Id
|
||||
|
||||
@Entity
|
||||
data class ProductTest (
|
||||
@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
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
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 TrainingPlanDay (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var dayId: Long = 0,
|
||||
@Expose @get: NonNull var name: String,
|
||||
|
||||
) {
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "trainingPlanDay")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
@Expose val translations: List<TrainingPlanDayTranslation> = mutableListOf<TrainingPlanDayTranslation>().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 TrainingPlanDayTranslation (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var translationId: Long = 0,
|
||||
@Expose @get: NotBlank var languageCode: String? = "hu",
|
||||
@Expose @get: NonNull var nameTranslation: String? = null,
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "dayId", nullable = false)
|
||||
@JsonIgnore val trainingPlanDay: TrainingPlanDay? = null
|
||||
}
|
||||
@@ -17,6 +17,7 @@ data class TrainingPlanDetail (
|
||||
@Expose var restingTime: Int? = 0,
|
||||
@Expose var parallel: Boolean? = false,
|
||||
@Expose var day: String? = null,
|
||||
@Expose var dayId: Int? = 0,
|
||||
|
||||
) {
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.ProductTest
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface ProductTestRepository : JpaRepository<ProductTest, Long> {
|
||||
fun findByCustomerId(customerId: Long): List<ProductTest>
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.TrainingPlanDay
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface TrainingPlanDayRepository: JpaRepository<TrainingPlanDay, 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.45
|
||||
application.version=1.0.46
|
||||
|
||||
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.45
|
||||
application.version=1.0.46
|
||||
|
||||
jwt.secret=aitrainer
|
||||
jasypt.encryptor.password=Tibor
|
||||
|
||||
Reference in New Issue
Block a user