API 1.0.25+2 customer.dateAdd dateChange

This commit is contained in:
Bossanyi Tibor
2021-02-19 17:56:42 +01:00
parent 59d09ed115
commit 7ddb724ccc
3 changed files with 24 additions and 7 deletions
@@ -10,6 +10,9 @@ import org.springframework.http.HttpHeaders
import org.springframework.http.ResponseEntity
import org.springframework.security.access.annotation.Secured
import org.springframework.web.bind.annotation.*
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.*
import javax.validation.Valid
@@ -100,8 +103,8 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
birthYear = newCustomer.birthYear,
fitnessLevel = newCustomer.fitnessLevel,
bodyType = newCustomer.bodyType,
goal = newCustomer.goal
//weight = newCustomer.weight
goal = newCustomer.goal,
dateChange = newCustomer.dateChange
)
} else {
updatedCustomer =
@@ -113,8 +116,8 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
birthYear = newCustomer.birthYear,
fitnessLevel = newCustomer.fitnessLevel,
bodyType = newCustomer.bodyType,
goal = newCustomer.goal
//weight = newCustomer.weight
goal = newCustomer.goal,
dateChange = newCustomer.dateChange
)
}
@@ -126,11 +129,16 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
fun registration(@Valid @RequestBody json: String): ResponseEntity<*> {
val customer = Customer()
val current = LocalDateTime.now()
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")
val nowFormatted = current.format(formatter)
val newUser: User = User().fromJson(json)
with (customer) {
email = newUser.username
password = serviceBeans!!.passwordEncoder().encode(newUser.password)
firebaseUid = newUser.firebaseUid
dateAdd = nowFormatted
}
val returnCustomer: Customer? = customerRepository.findByEmail(newUser.username).let {