API 1.0.57.3 get_user_by_email for deactivated: HTTP not found
This commit is contained in:
@@ -52,7 +52,7 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
|
||||
@Secured
|
||||
@GetMapping("/customers/find_by_email/{email}")
|
||||
fun getCustomerByEmail(@PathVariable(value = "email") email: String): ResponseEntity<Customer> {
|
||||
val customer: Customer? = customerRepository.findByEmail(email)
|
||||
val customer: Customer? = customerRepository.findByEmailAndActive(email, "Y")
|
||||
return if (customer == null) ResponseEntity.notFound().build() else ResponseEntity.ok().body(customer)
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
|
||||
email = newUser.username
|
||||
}
|
||||
|
||||
val returnCustomer: Customer? = customerRepository.findByEmail(newUser.username).let {
|
||||
val returnCustomer: Customer? = customerRepository.findByEmailAndActive(newUser.username, "Y").let {
|
||||
if ( it == null) {
|
||||
customerRepository.save(customer)
|
||||
} else {
|
||||
@@ -192,7 +192,7 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
|
||||
email = newUser.username
|
||||
password = newUser.password
|
||||
}
|
||||
val returnCustomer: Customer? = customerRepository.findByEmail(newUser.username).let {
|
||||
val returnCustomer: Customer? = customerRepository.findByEmailAndActive(newUser.username, "Y").let {
|
||||
if ( it == null) {
|
||||
null
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.aitrainer.api.repository
|
||||
|
||||
import com.aitrainer.api.model.Customer
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Query
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
@@ -10,6 +9,7 @@ interface CustomerRepository : JpaRepository<Customer, Long> {
|
||||
fun findByActive( active: String? ): List<Customer>
|
||||
|
||||
fun findByEmail(email: String?): Customer?
|
||||
fun findByEmailAndActive(email: String, active: String): Customer?
|
||||
|
||||
fun findByTrainerId( trainerId: Long ): List<Customer>
|
||||
|
||||
|
||||
@@ -10,4 +10,7 @@ interface CustomerService {
|
||||
|
||||
@Query("FROM customer WHERE active = :active AND id = :customerId")
|
||||
fun findByCustomerIdAndActive(@Param("customerId") customerId: Long?, @Param("active") active: String? ): Customer
|
||||
|
||||
@Query("FROM customer WHERE active = :active AND email = :email")
|
||||
fun findByEmailAndActive(@Param("email") email: String, @Param("active") active: String ): Customer
|
||||
}
|
||||
Reference in New Issue
Block a user