API 1.0.30 CustomerActivity, Sort ExercisePlanTemplateDetail.sort
This commit is contained in:
@@ -28,12 +28,6 @@ class ControllerAspect {
|
||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||
}
|
||||
|
||||
@Before("execution(* com.aitrainer.api.controller.CustomerInformationController.*(..))")
|
||||
fun customerInformationControllerAspect(joinPoint: JoinPoint) {
|
||||
println("customer information controller")
|
||||
Singleton.checkDBUpdate(configurationRepository, properties)
|
||||
}
|
||||
|
||||
@Before("execution(* com.aitrainer.api.controller.CustomerPropertyController.*(..))")
|
||||
fun customerPropertyControllerAspect(joinPoint: JoinPoint) {
|
||||
println("customer property controller")
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.CustomerActivity
|
||||
import com.aitrainer.api.repository.CustomerActivityRepository
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import javax.validation.Valid
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class CustomerActivityController(private val customerActivityRepository: CustomerActivityRepository) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@PostMapping("/customer_activity")
|
||||
fun insertActivity(@Valid @RequestBody customerActivity: CustomerActivity): ResponseEntity<CustomerActivity> {
|
||||
val newActivity = customerActivityRepository.save(customerActivity)
|
||||
logger.info("Create new activity: $newActivity")
|
||||
return ResponseEntity.ok().body(newActivity)
|
||||
}
|
||||
}
|
||||
@@ -92,34 +92,31 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
|
||||
val returnCustomer: Customer = customerRepository.findById(customerId).orElse(null)
|
||||
?: return ResponseEntity.notFound().build()
|
||||
|
||||
val password: String? = newCustomer.password
|
||||
val updatedCustomer: Customer
|
||||
if ( password == null || password.isEmpty() ) {
|
||||
updatedCustomer =
|
||||
returnCustomer.copy(
|
||||
name = newCustomer.name,
|
||||
firstname = newCustomer.firstname,
|
||||
sex = newCustomer.sex,
|
||||
birthYear = newCustomer.birthYear,
|
||||
fitnessLevel = newCustomer.fitnessLevel,
|
||||
bodyType = newCustomer.bodyType,
|
||||
goal = newCustomer.goal,
|
||||
dateChange = newCustomer.dateChange
|
||||
)
|
||||
} else {
|
||||
updatedCustomer =
|
||||
returnCustomer.copy(
|
||||
name = newCustomer.name,
|
||||
firstname = newCustomer.firstname,
|
||||
password = newCustomer.password,
|
||||
sex = newCustomer.sex,
|
||||
birthYear = newCustomer.birthYear,
|
||||
fitnessLevel = newCustomer.fitnessLevel,
|
||||
bodyType = newCustomer.bodyType,
|
||||
goal = newCustomer.goal,
|
||||
dateChange = newCustomer.dateChange
|
||||
)
|
||||
}
|
||||
val updatedCustomer = returnCustomer.copy()
|
||||
if (newCustomer.email != null) {
|
||||
updatedCustomer.email = newCustomer.email
|
||||
}
|
||||
if (newCustomer.name != null) {
|
||||
updatedCustomer.name = newCustomer.name
|
||||
}
|
||||
if (newCustomer.firstname != null) {
|
||||
updatedCustomer.firstname = newCustomer.firstname
|
||||
}
|
||||
if (newCustomer.goal != null) {
|
||||
updatedCustomer.goal = newCustomer.goal
|
||||
}
|
||||
if (newCustomer.dateChange != null) {
|
||||
updatedCustomer.dateChange = newCustomer.dateChange
|
||||
}
|
||||
if (newCustomer.dataPolicyAllowed != null) {
|
||||
updatedCustomer.dataPolicyAllowed = newCustomer.dataPolicyAllowed
|
||||
}
|
||||
updatedCustomer.sex = newCustomer.sex
|
||||
updatedCustomer.birthYear = newCustomer.birthYear
|
||||
updatedCustomer.fitnessLevel = newCustomer.fitnessLevel
|
||||
|
||||
|
||||
|
||||
|
||||
return ResponseEntity.ok().body(customerRepository.save(updatedCustomer))
|
||||
}
|
||||
@@ -139,6 +136,9 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
|
||||
password = serviceBeans!!.passwordEncoder().encode(newUser.password)
|
||||
firebaseUid = newUser.firebaseUid
|
||||
dateAdd = nowFormatted
|
||||
firstname = ""
|
||||
name = ""
|
||||
email = ""
|
||||
}
|
||||
|
||||
val returnCustomer: Customer? = customerRepository.findByEmail(newUser.username).let {
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.CustomerInformation
|
||||
import com.aitrainer.api.repository.CustomerInformationRepository
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class CustomerInformationController( private val customerInformationRepository: CustomerInformationRepository ) {
|
||||
|
||||
@GetMapping("/customer_information")
|
||||
fun getCustomerInformation(): List<CustomerInformation> {
|
||||
val dateTime: String = LocalDateTime.now().toString()
|
||||
return customerInformationRepository.findByDisplayBeginLessThanAndDisplayEndGreaterThan(dateTime, dateTime )
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -17,7 +17,8 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
private val productTestRepository: ProductTestRepository,
|
||||
private val purchaseRepository: PurchaseRepository,
|
||||
private val customerPropertyRepository: CustomerPropertyRepository,
|
||||
private val exerciseResultRepository: ExerciseResultRepository) {
|
||||
private val exerciseResultRepository: ExerciseResultRepository,
|
||||
private val customerActivityRepository: CustomerActivityRepository) {
|
||||
|
||||
@GetMapping("/app_customer_package/{id}")
|
||||
fun getCustomerPackageData(@PathVariable(value = "id") customerId: Long): ResponseEntity<String> {
|
||||
@@ -56,6 +57,9 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
val listExerciseResult = exerciseResultRepository.getAllByCustomerId(customerId)
|
||||
val listExerciseResultJson = gson.toJson(listExerciseResult)
|
||||
|
||||
val listActivityResult = customerActivityRepository.findByCustomerId(customerId)
|
||||
val listActivityJson = gson.toJson(listActivityResult)
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(Customer::class.simpleName, customerJson) +
|
||||
"|||" + getClassRecord(CustomerExerciseDevice::class.simpleName, listCustomerExerciseDeviceJson) +
|
||||
@@ -64,7 +68,8 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
"|||" + getClassRecord(Purchase::class.simpleName, listPurchaseJson) +
|
||||
"|||" + getClassRecord(CustomerProperty::class.simpleName+"All", listCustomerPropertyAllJson) +
|
||||
"|||" + getClassRecord(CustomerProperty::class.simpleName, listCustomerPropertyJson) +
|
||||
"|||" + getClassRecord(ExerciseResult::class.simpleName, listExerciseResultJson)
|
||||
"|||" + getClassRecord(ExerciseResult::class.simpleName, listExerciseResultJson+
|
||||
"|||" + getClassRecord(CustomerActivity::class.simpleName, listActivityJson))
|
||||
|
||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(packageJson)
|
||||
|
||||
Reference in New Issue
Block a user