exercise_plan_detail_id in exercises
This commit is contained in:
parent
efe7dea584
commit
3f8eb6ef00
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
|
||||
provide a RESTful API for the mobile app
|
||||
@ -7,7 +7,14 @@ provide a RESTful API for the mobile app
|
||||
|
||||
* customers
|
||||
* exercise_type
|
||||
* exercise_image
|
||||
* exercise_translation
|
||||
* exercise_tree
|
||||
* exercise_tree_image
|
||||
* exercise_tree_translation
|
||||
* exercise
|
||||
* customer_information
|
||||
* exercise_plan
|
||||
* exercise_plan_detail
|
||||
|
||||
with automatic database update
|
||||
|
@ -54,11 +54,10 @@ class ExercisePlanController( private val exercisePlanRepository: ExercisePlanRe
|
||||
|
||||
@Secured
|
||||
@PostMapping("/exercise_plan/delete/{exercisePlanId}")
|
||||
fun deleteExercisePlanById(@PathVariable(value = "exercisePlanId") exercisePlanId: Int,
|
||||
@Valid @RequestBody exercisePlan: ExercisePlan)
|
||||
fun deleteExercisePlanById(@PathVariable(value = "exercisePlanId") exercisePlanId: Int)
|
||||
:ResponseEntity<HttpStatus> {
|
||||
val returnPlan = exercisePlanRepository.findById(exercisePlanId).orElse(null)
|
||||
?: return ResponseEntity.ok().body(HttpStatus.NOT_FOUND)
|
||||
?: return ResponseEntity.notFound().build()
|
||||
try {
|
||||
exercisePlanRepository.delete(returnPlan)
|
||||
} catch (e: IllegalArgumentException ) {
|
||||
|
@ -22,15 +22,6 @@ class ExercisePlanDetailController( private val exercisePlanDetailRepository: Ex
|
||||
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}")
|
||||
fun getExercisePlanByExercisePlanId(@PathVariable(value = "exercisePlanId") exercisePlanId: Int): ResponseEntity<List<ExercisePlanDetail>> {
|
||||
val list: List<ExercisePlanDetail> = exercisePlanDetailRepository.findByExercisePlanId(exercisePlanId)
|
||||
@ -61,11 +52,10 @@ class ExercisePlanDetailController( private val exercisePlanDetailRepository: Ex
|
||||
|
||||
@Secured
|
||||
@PostMapping("/exercise_plan_detail/delete/{exercisePlanDetailId}")
|
||||
fun deleteExercisePlanDetailById(@PathVariable(value = "exercisePlanDetailId") exercisePlanDetailId: Long,
|
||||
@Valid @RequestBody exercisePlanDetail: ExercisePlanDetail)
|
||||
fun deleteExercisePlanDetailById(@PathVariable(value = "exercisePlanDetailId") exercisePlanDetailId: Long)
|
||||
:ResponseEntity<HttpStatus> {
|
||||
val returnPlanDetail = exercisePlanDetailRepository.findById(exercisePlanDetailId).orElse(null)
|
||||
?: return ResponseEntity.ok().body(HttpStatus.NOT_FOUND)
|
||||
?: return ResponseEntity.notFound().build()
|
||||
try {
|
||||
exercisePlanDetailRepository.delete(returnPlanDetail)
|
||||
} catch (e: IllegalArgumentException ) {
|
||||
|
@ -16,6 +16,7 @@ data class Exercises (
|
||||
@get: Null var restTime: Int?, // in seconds
|
||||
@get: NonNull var unit: String? = null,
|
||||
@get: NonNull var unitQuantity: Double? = null,
|
||||
@get: NonNull var exercisePlanDetailId: Int = 0,
|
||||
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val exerciseId: Long = 0
|
||||
|
@ -16,6 +16,6 @@ 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
|
||||
application.version=1.0.9
|
||||
|
||||
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
|
||||
|
||||
# if the database structure has been changed, increment this version number
|
||||
application.version=1.0.8
|
||||
application.version=1.0.9
|
||||
|
||||
jwt.secret=aitrainer
|
@ -100,11 +100,11 @@ class ExercisePlanDetailTest {
|
||||
val planDetailToDelete: ExercisePlanDetail = exercisePlanDetailRepository.findById(newPlanDetailId).orElse(null)
|
||||
assertNotNull(planDetailToDelete)
|
||||
|
||||
val response: ResponseEntity<*> = planDetailController.deleteExercisePlanDetailById(newPlanDetailId, planDetailToDelete)
|
||||
assertEquals(response.body, HttpStatus.OK)
|
||||
val response: ResponseEntity<*> = planDetailController.deleteExercisePlanDetailById(newPlanDetailId)
|
||||
assertEquals(response.statusCode, HttpStatus.OK)
|
||||
|
||||
val response2: ResponseEntity<*> = planDetailController.deleteExercisePlanDetailById(9999, planDetailToDelete)
|
||||
assertEquals(response2.body, HttpStatus.NOT_FOUND)
|
||||
val response2: ResponseEntity<*> = planDetailController.deleteExercisePlanDetailById(9999)
|
||||
assertEquals(response2.statusCode, HttpStatus.NOT_FOUND)
|
||||
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ class ExercisePlanTest {
|
||||
assertEquals(savedPlan.customerId, 92)
|
||||
|
||||
val planController = ExercisePlanController(exercisePlanRepository)
|
||||
val response3: ResponseEntity<*> = planController.deleteExercisePlanById(exercisePlan.exercisePlanId, exercisePlan)
|
||||
val response3: ResponseEntity<*> = planController.deleteExercisePlanById(exercisePlan.exercisePlanId)
|
||||
assertEquals(response3.body, HttpStatus.OK)
|
||||
|
||||
val searchPlan = exercisePlanRepository.findById(exercisePlan.exercisePlanId)
|
||||
|
@ -49,10 +49,12 @@ class ExerciseTest {
|
||||
dateAdd = "2020-07-05 04:32:00",
|
||||
unit = "repeat",
|
||||
unitQuantity = 32.6,
|
||||
restTime = null
|
||||
restTime = null,
|
||||
exercisePlanDetailId = 6
|
||||
)
|
||||
exerciseNew = exerciseRepository.save(exercise)
|
||||
assertTrue(exerciseNew.exerciseId > 3)
|
||||
assertEquals(exerciseNew.exercisePlanDetailId, 6)
|
||||
exerciseRepository.delete(exercise)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user