@RequestMapping(value = "/me", method = RequestMethod.GET) public @ResponseBody RouteExecution getMy() { String token = request.getHeader("authToken"); Truck truck = truckRepository.getTruckByToken(token); return repository.getCurrentRouteExecution(truck); }
@RequestMapping(value = "/updatePosition", method = RequestMethod.POST) public @ResponseBody RouteExecutionPoint updatePosition( @RequestBody RouteExecutionPoint routeExecutionPoint) { String token = request.getHeader("authToken"); Truck truck = truckRepository.getTruckByToken(token); RouteExecutionPeriod routeExecutionPeriod = repository.getCurrentRouteExecutionPeriod(truck); repository.addPointToRouteExecutionPeriod(routeExecutionPeriod, routeExecutionPoint); return routeExecutionPoint; }
@RequestMapping(value = "/stop", method = RequestMethod.POST) public @ResponseBody RouteExecutionPeriod stop(@RequestBody Date executionDate) { String token = request.getHeader("authToken"); Truck truck = truckRepository.getTruckByToken(token); RouteExecutionPeriod routeExecutionPeriod = repository.getCurrentRouteExecutionPeriod(truck); routeExecutionPeriod.setEndDate(executionDate); repository.update(routeExecutionPeriod); return routeExecutionPeriod; }
@RequestMapping(value = "/start", method = RequestMethod.POST) public @ResponseBody RouteExecutionPeriod start(@RequestBody Date executionDate) { String token = request.getHeader("authToken"); Truck truck = truckRepository.getTruckByToken(token); RouteExecution routeExecution = repository.getCurrentRouteExecution(truck); RouteExecutionPeriod routeExecutionPeriod = new RouteExecutionPeriod(); routeExecutionPeriod.setStartDate(executionDate); repository.addPeriodToRouteExecution(routeExecution, routeExecutionPeriod); return routeExecutionPeriod; }