API 1.0.57.2 get_customer package: deactivated customer: not found

This commit is contained in:
Tibor Bossanyi (Freelancer) 2022-11-25 20:33:31 +01:00
parent 9dc32bffd3
commit 839d3a85a5
5 changed files with 13 additions and 2 deletions

View File

@ -1,4 +1,4 @@
#aitrainer server API v1.0.54
#aitrainer server API v1.0.57
connects the MYSQL Database
provide a RESTful API for the mobile app
@ -25,5 +25,6 @@ provide a RESTful API for the mobile app
* exercise_device
* exercise_device_translation
* exercise_type_device
* deactivate customer
with automatic database update

View File

@ -33,8 +33,9 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
.setPrettyPrinting()
.create()
val customer: Customer = customerRepository.findById(customerId).orElse(null)
val customer: Customer = customerRepository.findByCustomerIdAndActive(customerId, "Y")
?: return ResponseEntity.notFound().build()
val customerJson: String = gson.toJson(customer)
val listCustomerExerciseDevices = customerExerciseDeviceRepository.findByCustomerId(customerId)

View File

@ -14,4 +14,6 @@ interface CustomerRepository : JpaRepository<Customer, Long> {
fun findByTrainerId( trainerId: Long ): List<Customer>
fun findByFirebaseUid(firebaseUid: String?): Customer?
fun findByCustomerIdAndActive(customerId: Long, active: String): Customer?
}

View File

@ -7,4 +7,7 @@ import org.springframework.data.repository.query.Param
interface CustomerService {
@Query("FROM customer WHERE active = :active ")
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
}

View File

@ -132,6 +132,10 @@ class AppCustomerPackageTest {
}
}
// deactivated customer
response = controller.getCustomerPackageData(1)
assertEquals(response.statusCode, HttpStatus.NOT_FOUND)
}
}