|
@@ -5,12 +5,17 @@ import com.sqx.common.utils.Result;
|
|
|
import com.sqx.modules.app.annotation.Login;
|
|
|
import com.sqx.modules.car.entity.Car;
|
|
|
import com.sqx.modules.car.service.CarService;
|
|
|
+import com.sqx.modules.driver.entity.Driver;
|
|
|
+import com.sqx.modules.driver.service.DriverService;
|
|
|
import com.sqx.modules.emergencyContact.entity.EmergencyContact;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
@RestController
|
|
|
@Api(value = "车辆管理", tags = {"车辆管理"})
|
|
|
@RequestMapping("/app/car")
|
|
@@ -18,6 +23,8 @@ public class AppCarController {
|
|
|
|
|
|
@Autowired
|
|
|
private CarService carService;
|
|
|
+ @Resource
|
|
|
+ private DriverService driverService;
|
|
|
|
|
|
@Login
|
|
|
@GetMapping("/selectCarList")
|
|
@@ -31,7 +38,7 @@ public class AppCarController {
|
|
|
@ApiOperation("新增车辆")
|
|
|
public Result insertCar(@RequestAttribute("userId")Long userId, Car car){
|
|
|
car.setUserId(userId);
|
|
|
- car.setStatus(1L);
|
|
|
+ car.setStatus(1);
|
|
|
carService.insert(car);
|
|
|
return Result.success();
|
|
|
}
|
|
@@ -54,4 +61,32 @@ public class AppCarController {
|
|
|
return carService.deleteCar(carId);
|
|
|
}
|
|
|
|
|
|
+ @Login
|
|
|
+ @PostMapping("/updateChecked")
|
|
|
+ @ApiOperation("修改车辆选中")
|
|
|
+ public Result updateChecked(@RequestAttribute("userId")Long userId, Car car){
|
|
|
+ if (car.getStatus() != 2){
|
|
|
+ return Result.error(999,"未审核通过车辆禁止切换");
|
|
|
+ }
|
|
|
+ carService.updateCar(car);
|
|
|
+ Driver driver = driverService.selectDriverByUserId(userId);
|
|
|
+ driver.setDriverColor(car.getCarColor());
|
|
|
+ driver.setDriverPlate(car.getCarPlate());
|
|
|
+ driver.setDriverBrand(car.getCarBrand());
|
|
|
+ driver.setStatus(car.getStatus());
|
|
|
+ driverService.updateDriver(driver);
|
|
|
+ List<Car> carList = carService.list(new QueryWrapper<Car>().eq("user_id", userId));
|
|
|
+ if (carList.size() == 1){
|
|
|
+ return Result.success();
|
|
|
+ }else if (carList.size() > 1){
|
|
|
+ for (Car c : carList){
|
|
|
+ if (c.getCarId() != car.getCarId()){
|
|
|
+ c.setChecked(0);
|
|
|
+ carService.updateCar(c);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
}
|