find Real customer api (inconvinence)

This commit is contained in:
ZalanBoss 2020-05-16 10:50:42 +02:00
parent 5a4dda676b
commit 565680636a
5 changed files with 22 additions and 3 deletions

View File

@ -23,7 +23,13 @@ class CustomerController ( private val customerRepository: CustomerRepository )
return customerRepository.findById(customerId).map { customer ->
ResponseEntity.ok(customer)
}.orElse(ResponseEntity.notFound().build())
}
}
@GetMapping("/customers/real")
fun getRealCustomers(active: String): List<Customer> =
customerRepository.findRealCustomers(active)
@PutMapping("/customers/{id}")
fun updateCustomerById(@PathVariable(value = "id") customerId: Long,

View File

@ -15,6 +15,7 @@ data class Customer (
var email: String = "",
var age: Int = 0,
var sex: String = "m",
var active: String = "N",
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
val customer_id: Long = 0

View File

@ -5,4 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
@Repository
interface CustomerRepository : JpaRepository<Customer, Long>
interface CustomerRepository : JpaRepository<Customer, Long>{
fun findRealCustomers(active: String):List<Customer>
}

View 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>
}

View File

@ -20,7 +20,7 @@ class ExerciseTypeTest {
assertEquals( extype.name, "4x10m-es ingafutás")
}
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)
assertEquals(savedEx.name, "Húzodszkodás")