@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 = "/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; }