Merge branch 'zalan' into 'master'
find Real customer api (inconvinence) See merge request bossanyit/aitrainer_server!12
This commit is contained in:
commit
c2b2a68ce6
@ -23,7 +23,13 @@ class CustomerController ( private val customerRepository: CustomerRepository )
|
|||||||
return customerRepository.findById(customerId).map { customer ->
|
return customerRepository.findById(customerId).map { customer ->
|
||||||
ResponseEntity.ok(customer)
|
ResponseEntity.ok(customer)
|
||||||
}.orElse(ResponseEntity.notFound().build())
|
}.orElse(ResponseEntity.notFound().build())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/customers/real")
|
||||||
|
fun getRealCustomers(active: String): List<Customer> =
|
||||||
|
customerRepository.findRealCustomers(active)
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/customers/{id}")
|
@PutMapping("/customers/{id}")
|
||||||
fun updateCustomerById(@PathVariable(value = "id") customerId: Long,
|
fun updateCustomerById(@PathVariable(value = "id") customerId: Long,
|
||||||
|
@ -15,6 +15,7 @@ data class Customer (
|
|||||||
var email: String = "",
|
var email: String = "",
|
||||||
var age: Int = 0,
|
var age: Int = 0,
|
||||||
var sex: String = "m",
|
var sex: String = "m",
|
||||||
|
var active: String = "N",
|
||||||
|
|
||||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
val customer_id: Long = 0
|
val customer_id: Long = 0
|
||||||
|
@ -5,4 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository
|
|||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
interface CustomerRepository : JpaRepository<Customer, Long>
|
interface CustomerRepository : JpaRepository<Customer, Long>{
|
||||||
|
fun findRealCustomers(active: String):List<Customer>
|
||||||
|
}
|
10
src/main/kotlin/com/aitrainer/api/service/CustomerService.kt
Normal file
10
src/main/kotlin/com/aitrainer/api/service/CustomerService.kt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package com.aitrainer.api.service
|
||||||
|
|
||||||
|
import com.aitrainer.api.model.Customer
|
||||||
|
import org.springframework.data.jpa.repository.Query
|
||||||
|
import org.springframework.data.repository.query.Param
|
||||||
|
|
||||||
|
interface CustomerService {
|
||||||
|
@Query("FROM customer WHERE active = :active")
|
||||||
|
fun findRealCustomers(@Param("active") active: String): List<Customer>
|
||||||
|
}
|
@ -21,7 +21,7 @@ class ExerciseTypeTest {
|
|||||||
assertEquals( extype.name, "4x10m-es ingafutás")
|
assertEquals( extype.name, "4x10m-es ingafutás")
|
||||||
}
|
}
|
||||||
fun testInsert(){
|
fun testInsert(){
|
||||||
val newEx = ExerciseType( "Húzodszkodás", " A legtöbb húzodszkodás 24 óra alatt John Ort érte el 7600-al 2016-ban. ", null )
|
val newEx = ExerciseType( "Húzodszkodás", " A legtöbb húzodszkodást 24 óra alatt John Ort érte el 7600-al 2016-ban. ", null )
|
||||||
val savedEx: ExerciseType = exerciseTypeRepository.save(newEx)
|
val savedEx: ExerciseType = exerciseTypeRepository.save(newEx)
|
||||||
assertEquals(savedEx.name, "Húzodszkodás")
|
assertEquals(savedEx.name, "Húzodszkodás")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user