Merge branch 'tibor' into 'master'
exercise_plan_detail_id in exercises See merge request bossanyit/aitrainer_server!17
This commit is contained in:
commit
bab94238e9
4
data/db/update_1_0_9.sql
Normal file
4
data/db/update_1_0_9.sql
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE `exercises`
|
||||||
|
ADD COLUMN `exercise_plan_detail_id` INT(11) NOT NULL DEFAULT 0 AFTER `rest_time`;
|
||||||
|
|
||||||
|
UPDATE configuration set config_value = "1.0.9", date_change=CURRENT_DATE WHERE config_key = "db_version";
|
@ -1,4 +1,4 @@
|
|||||||
#aitrainer server API v1.0.4
|
#aitrainer server API v1.0.9
|
||||||
|
|
||||||
connects the MYSQL Database
|
connects the MYSQL Database
|
||||||
provide a RESTful API for the mobile app
|
provide a RESTful API for the mobile app
|
||||||
@ -7,7 +7,14 @@ provide a RESTful API for the mobile app
|
|||||||
|
|
||||||
* customers
|
* customers
|
||||||
* exercise_type
|
* exercise_type
|
||||||
|
* exercise_image
|
||||||
|
* exercise_translation
|
||||||
|
* exercise_tree
|
||||||
|
* exercise_tree_image
|
||||||
|
* exercise_tree_translation
|
||||||
* exercise
|
* exercise
|
||||||
* customer_information
|
* customer_information
|
||||||
|
* exercise_plan
|
||||||
|
* exercise_plan_detail
|
||||||
|
|
||||||
with automatic database update
|
with automatic database update
|
||||||
|
@ -54,11 +54,10 @@ class ExercisePlanController( private val exercisePlanRepository: ExercisePlanRe
|
|||||||
|
|
||||||
@Secured
|
@Secured
|
||||||
@PostMapping("/exercise_plan/delete/{exercisePlanId}")
|
@PostMapping("/exercise_plan/delete/{exercisePlanId}")
|
||||||
fun deleteExercisePlanById(@PathVariable(value = "exercisePlanId") exercisePlanId: Int,
|
fun deleteExercisePlanById(@PathVariable(value = "exercisePlanId") exercisePlanId: Int)
|
||||||
@Valid @RequestBody exercisePlan: ExercisePlan)
|
|
||||||
:ResponseEntity<HttpStatus> {
|
:ResponseEntity<HttpStatus> {
|
||||||
val returnPlan = exercisePlanRepository.findById(exercisePlanId).orElse(null)
|
val returnPlan = exercisePlanRepository.findById(exercisePlanId).orElse(null)
|
||||||
?: return ResponseEntity.ok().body(HttpStatus.NOT_FOUND)
|
?: return ResponseEntity.notFound().build()
|
||||||
try {
|
try {
|
||||||
exercisePlanRepository.delete(returnPlan)
|
exercisePlanRepository.delete(returnPlan)
|
||||||
} catch (e: IllegalArgumentException ) {
|
} catch (e: IllegalArgumentException ) {
|
||||||
|
@ -22,15 +22,6 @@ class ExercisePlanDetailController( private val exercisePlanDetailRepository: Ex
|
|||||||
return ResponseEntity.ok().body(exercisePlanDetailRepository.save(exercisePlanDetail))
|
return ResponseEntity.ok().body(exercisePlanDetailRepository.save(exercisePlanDetail))
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @GetMapping("/exercise_plan_detail/last/{customerId}")
|
|
||||||
fun getExercisePlanByCustomerId(@PathVariable(value = "customerId") customerId: Long): ResponseEntity<List<ExercisePlanDetail>> {
|
|
||||||
val list: List<ExercisePlanDetail> = exercisePlanDetailRepository.getLastExercisePlanDetail(customerId)
|
|
||||||
logger.info("-- getExercisePlanByCustomerId id: $customerId -- $list")
|
|
||||||
return ResponseEntity.ok().body(list)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/exercise_plan_detail/{exercisePlanId}")
|
@GetMapping("/exercise_plan_detail/{exercisePlanId}")
|
||||||
fun getExercisePlanByExercisePlanId(@PathVariable(value = "exercisePlanId") exercisePlanId: Int): ResponseEntity<List<ExercisePlanDetail>> {
|
fun getExercisePlanByExercisePlanId(@PathVariable(value = "exercisePlanId") exercisePlanId: Int): ResponseEntity<List<ExercisePlanDetail>> {
|
||||||
val list: List<ExercisePlanDetail> = exercisePlanDetailRepository.findByExercisePlanId(exercisePlanId)
|
val list: List<ExercisePlanDetail> = exercisePlanDetailRepository.findByExercisePlanId(exercisePlanId)
|
||||||
@ -61,11 +52,10 @@ class ExercisePlanDetailController( private val exercisePlanDetailRepository: Ex
|
|||||||
|
|
||||||
@Secured
|
@Secured
|
||||||
@PostMapping("/exercise_plan_detail/delete/{exercisePlanDetailId}")
|
@PostMapping("/exercise_plan_detail/delete/{exercisePlanDetailId}")
|
||||||
fun deleteExercisePlanDetailById(@PathVariable(value = "exercisePlanDetailId") exercisePlanDetailId: Long,
|
fun deleteExercisePlanDetailById(@PathVariable(value = "exercisePlanDetailId") exercisePlanDetailId: Long)
|
||||||
@Valid @RequestBody exercisePlanDetail: ExercisePlanDetail)
|
|
||||||
:ResponseEntity<HttpStatus> {
|
:ResponseEntity<HttpStatus> {
|
||||||
val returnPlanDetail = exercisePlanDetailRepository.findById(exercisePlanDetailId).orElse(null)
|
val returnPlanDetail = exercisePlanDetailRepository.findById(exercisePlanDetailId).orElse(null)
|
||||||
?: return ResponseEntity.ok().body(HttpStatus.NOT_FOUND)
|
?: return ResponseEntity.notFound().build()
|
||||||
try {
|
try {
|
||||||
exercisePlanDetailRepository.delete(returnPlanDetail)
|
exercisePlanDetailRepository.delete(returnPlanDetail)
|
||||||
} catch (e: IllegalArgumentException ) {
|
} catch (e: IllegalArgumentException ) {
|
||||||
|
@ -16,6 +16,7 @@ data class Exercises (
|
|||||||
@get: Null var restTime: Int?, // in seconds
|
@get: Null var restTime: Int?, // in seconds
|
||||||
@get: NonNull var unit: String? = null,
|
@get: NonNull var unit: String? = null,
|
||||||
@get: NonNull var unitQuantity: Double? = null,
|
@get: NonNull var unitQuantity: Double? = null,
|
||||||
|
@get: NonNull var exercisePlanDetailId: Int = 0,
|
||||||
|
|
||||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
val exerciseId: Long = 0
|
val exerciseId: Long = 0
|
||||||
|
@ -16,6 +16,6 @@ logging.config=classpath:logback-spring.xml
|
|||||||
logging.file=logs
|
logging.file=logs
|
||||||
|
|
||||||
# if the database structure has been changed, increment this version number
|
# if the database structure has been changed, increment this version number
|
||||||
application.version=1.0.8
|
application.version=1.0.9
|
||||||
|
|
||||||
jwt.secret=aitrainer
|
jwt.secret=aitrainer
|
@ -1,21 +0,0 @@
|
|||||||
spring.profiles.active=prod
|
|
||||||
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
|
|
||||||
spring.datasource.url = jdbc:mysql://62.171.188.119:33060/aitrainer_test?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&allowMultiQueries=true
|
|
||||||
spring.datasource.username = aitrainer
|
|
||||||
spring.datasource.password = andio2009
|
|
||||||
|
|
||||||
|
|
||||||
## Hibernate Properties
|
|
||||||
|
|
||||||
|
|
||||||
# The SQL dialect makes Hibernate generate better SQL for the chosen database
|
|
||||||
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
|
|
||||||
|
|
||||||
|
|
||||||
logging.config=classpath:logback-spring.xml
|
|
||||||
logging.file=logs
|
|
||||||
|
|
||||||
# if the database structure has been changed, increment this version number
|
|
||||||
application.version=1.0.8
|
|
||||||
|
|
||||||
jwt.secret=aitrainer
|
|
@ -16,6 +16,6 @@ logging.config=classpath:logback-spring.xml
|
|||||||
logging.file=logs
|
logging.file=logs
|
||||||
|
|
||||||
# if the database structure has been changed, increment this version number
|
# if the database structure has been changed, increment this version number
|
||||||
application.version=1.0.8
|
application.version=1.0.9
|
||||||
|
|
||||||
jwt.secret=aitrainer
|
jwt.secret=aitrainer
|
@ -100,11 +100,11 @@ class ExercisePlanDetailTest {
|
|||||||
val planDetailToDelete: ExercisePlanDetail = exercisePlanDetailRepository.findById(newPlanDetailId).orElse(null)
|
val planDetailToDelete: ExercisePlanDetail = exercisePlanDetailRepository.findById(newPlanDetailId).orElse(null)
|
||||||
assertNotNull(planDetailToDelete)
|
assertNotNull(planDetailToDelete)
|
||||||
|
|
||||||
val response: ResponseEntity<*> = planDetailController.deleteExercisePlanDetailById(newPlanDetailId, planDetailToDelete)
|
val response: ResponseEntity<*> = planDetailController.deleteExercisePlanDetailById(newPlanDetailId)
|
||||||
assertEquals(response.body, HttpStatus.OK)
|
assertEquals(response.statusCode, HttpStatus.OK)
|
||||||
|
|
||||||
val response2: ResponseEntity<*> = planDetailController.deleteExercisePlanDetailById(9999, planDetailToDelete)
|
val response2: ResponseEntity<*> = planDetailController.deleteExercisePlanDetailById(9999)
|
||||||
assertEquals(response2.body, HttpStatus.NOT_FOUND)
|
assertEquals(response2.statusCode, HttpStatus.NOT_FOUND)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class ExercisePlanTest {
|
|||||||
assertEquals(savedPlan.customerId, 92)
|
assertEquals(savedPlan.customerId, 92)
|
||||||
|
|
||||||
val planController = ExercisePlanController(exercisePlanRepository)
|
val planController = ExercisePlanController(exercisePlanRepository)
|
||||||
val response3: ResponseEntity<*> = planController.deleteExercisePlanById(exercisePlan.exercisePlanId, exercisePlan)
|
val response3: ResponseEntity<*> = planController.deleteExercisePlanById(exercisePlan.exercisePlanId)
|
||||||
assertEquals(response3.body, HttpStatus.OK)
|
assertEquals(response3.body, HttpStatus.OK)
|
||||||
|
|
||||||
val searchPlan = exercisePlanRepository.findById(exercisePlan.exercisePlanId)
|
val searchPlan = exercisePlanRepository.findById(exercisePlan.exercisePlanId)
|
||||||
|
@ -49,10 +49,12 @@ class ExerciseTest {
|
|||||||
dateAdd = "2020-07-05 04:32:00",
|
dateAdd = "2020-07-05 04:32:00",
|
||||||
unit = "repeat",
|
unit = "repeat",
|
||||||
unitQuantity = 32.6,
|
unitQuantity = 32.6,
|
||||||
restTime = null
|
restTime = null,
|
||||||
|
exercisePlanDetailId = 6
|
||||||
)
|
)
|
||||||
exerciseNew = exerciseRepository.save(exercise)
|
exerciseNew = exerciseRepository.save(exercise)
|
||||||
assertTrue(exerciseNew.exerciseId > 3)
|
assertTrue(exerciseNew.exerciseId > 3)
|
||||||
|
assertEquals(exerciseNew.exercisePlanDetailId, 6)
|
||||||
exerciseRepository.delete(exercise)
|
exerciseRepository.delete(exercise)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user