Merge pull request 'API 1.0.57.2 get_customer package: deactivated customer: not found' (#3) from tibor into master
Reviewed-on: https://git.workouttest.org/bossanyit/aitrainer_server/pulls/3
This commit is contained in:
commit
938260b4de
@ -1,4 +1,4 @@
|
|||||||
#aitrainer server API v1.0.54
|
#aitrainer server API v1.0.57
|
||||||
|
|
||||||
connects the MYSQL Database
|
connects the MYSQL Database
|
||||||
provide a RESTful API for the mobile app
|
provide a RESTful API for the mobile app
|
||||||
@ -25,5 +25,6 @@ provide a RESTful API for the mobile app
|
|||||||
* exercise_device
|
* exercise_device
|
||||||
* exercise_device_translation
|
* exercise_device_translation
|
||||||
* exercise_type_device
|
* exercise_type_device
|
||||||
|
* deactivate customer
|
||||||
|
|
||||||
with automatic database update
|
with automatic database update
|
||||||
|
@ -33,8 +33,9 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
|||||||
.setPrettyPrinting()
|
.setPrettyPrinting()
|
||||||
.create()
|
.create()
|
||||||
|
|
||||||
val customer: Customer = customerRepository.findById(customerId).orElse(null)
|
val customer: Customer = customerRepository.findByCustomerIdAndActive(customerId, "Y")
|
||||||
?: return ResponseEntity.notFound().build()
|
?: return ResponseEntity.notFound().build()
|
||||||
|
|
||||||
val customerJson: String = gson.toJson(customer)
|
val customerJson: String = gson.toJson(customer)
|
||||||
|
|
||||||
val listCustomerExerciseDevices = customerExerciseDeviceRepository.findByCustomerId(customerId)
|
val listCustomerExerciseDevices = customerExerciseDeviceRepository.findByCustomerId(customerId)
|
||||||
|
@ -14,4 +14,6 @@ interface CustomerRepository : JpaRepository<Customer, Long> {
|
|||||||
fun findByTrainerId( trainerId: Long ): List<Customer>
|
fun findByTrainerId( trainerId: Long ): List<Customer>
|
||||||
|
|
||||||
fun findByFirebaseUid(firebaseUid: String?): Customer?
|
fun findByFirebaseUid(firebaseUid: String?): Customer?
|
||||||
|
|
||||||
|
fun findByCustomerIdAndActive(customerId: Long, active: String): Customer?
|
||||||
}
|
}
|
||||||
|
@ -7,4 +7,7 @@ import org.springframework.data.repository.query.Param
|
|||||||
interface CustomerService {
|
interface CustomerService {
|
||||||
@Query("FROM customer WHERE active = :active ")
|
@Query("FROM customer WHERE active = :active ")
|
||||||
fun findByActive(@Param("active") active: String? ): List<Customer>
|
fun findByActive(@Param("active") active: String? ): List<Customer>
|
||||||
|
|
||||||
|
@Query("FROM customer WHERE active = :active AND id = :customerId")
|
||||||
|
fun findByCustomerIdAndActive(@Param("customerId") customerId: Long?, @Param("active") active: String? ): Customer
|
||||||
}
|
}
|
@ -132,6 +132,10 @@ class AppCustomerPackageTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deactivated customer
|
||||||
|
response = controller.getCustomerPackageData(1)
|
||||||
|
assertEquals(response.statusCode, HttpStatus.NOT_FOUND)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user