API 1.0.31 sports
This commit is contained in:
@@ -111,6 +111,12 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
|
||||
if (newCustomer.dataPolicyAllowed != null) {
|
||||
updatedCustomer.dataPolicyAllowed = newCustomer.dataPolicyAllowed
|
||||
}
|
||||
if (newCustomer.sportId != null) {
|
||||
updatedCustomer.sportId = newCustomer.sportId
|
||||
}
|
||||
if (newCustomer.emailSubscription != null) {
|
||||
updatedCustomer.emailSubscription = newCustomer.emailSubscription
|
||||
}
|
||||
updatedCustomer.sex = newCustomer.sex
|
||||
updatedCustomer.birthYear = newCustomer.birthYear
|
||||
updatedCustomer.fitnessLevel = newCustomer.fitnessLevel
|
||||
|
||||
@@ -20,7 +20,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
private val exerciseDeviceRepository: ExerciseDeviceRepository,
|
||||
private val exerciseTreeParentsRepository: ExerciseTreeParentsRepository,
|
||||
private val exercisePlanTemplateRepository: ExercisePlanTemplateRepository,
|
||||
private val evaluationRepository: EvaluationRepository
|
||||
private val evaluationRepository: EvaluationRepository,
|
||||
private val sportRepository: SportRepository
|
||||
) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@@ -59,6 +60,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
val listEvaluations = evaluationRepository.findAll()
|
||||
val listEvaluationJson: String = gson.toJson(listEvaluations)
|
||||
|
||||
val listSports = sportRepository.getSports()
|
||||
val listSportsJson: String = gson.toJson((listSports))
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(ExerciseDevice::class.simpleName, listDevicesJson) +
|
||||
@@ -69,7 +72,8 @@ class PackageController(private val exerciseAbilityRepository: ExerciseAbilityRe
|
||||
"|||" + getClassRecord(ExerciseAbility::class.simpleName, listExerciseAbilityJson) +
|
||||
"|||" + getClassRecord(ExerciseTreeParents::class.simpleName, listExerciseTreeParentsJson) +
|
||||
"|||" + getClassRecord(ExercisePlanTemplate::class.simpleName, listPlanTemplateJson) +
|
||||
"|||" + getClassRecord(Evaluation::class.simpleName, listEvaluationJson)
|
||||
"|||" + getClassRecord(Evaluation::class.simpleName, listEvaluationJson) +
|
||||
"|||" + getClassRecord(Sport::class.simpleName, listSportsJson)
|
||||
|
||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(packageJson)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.Sport
|
||||
import com.aitrainer.api.repository.SportRepository
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class SportController(private val sportRepository: SportRepository) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@GetMapping("/sports")
|
||||
fun getSportsWithTranslation(): ResponseEntity<List<Sport>> {
|
||||
val list = sportRepository.getSports()
|
||||
|
||||
logger.info(" -- Get All sports $list")
|
||||
return if (list.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(list)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user