package com.stylefeng.guns.modular.api;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.stylefeng.guns.modular.system.model.TCarColor;
|
import com.stylefeng.guns.modular.system.service.ICarService;
|
import com.stylefeng.guns.modular.system.service.IDriverService;
|
import com.stylefeng.guns.modular.system.service.ITCarColorService;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import com.stylefeng.guns.modular.system.warpper.BaseWarpper;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 车辆相关控制器
|
*/
|
@RestController
|
@RequestMapping("")
|
public class CarController {
|
|
@Autowired
|
private ICarService carService;
|
|
@Autowired
|
private IDriverService driverService;
|
|
@Autowired
|
private ITCarColorService tCarColorService;
|
|
|
|
|
|
|
/**
|
* 获取所有车辆品牌
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/car/queryAllBrand")
|
@ApiOperation(value = "获取所有车辆品牌", tags = {"司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil queryAllBrand(){
|
try {
|
List<Map<String, Object>> list = carService.queryAllBrand();
|
return ResultUtil.success(list);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 查询车辆品牌型号
|
* @param brandId
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/car/queryCarModel")
|
@ApiOperation(value = "查询车辆品牌型号", tags = {"司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "车辆品牌id", name = "brandId", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil queryCarModel(Integer brandId){
|
try {
|
List<Map<String, Object>> list = carService.queryCarModel(brandId);
|
return ResultUtil.success(list);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
/**
|
* 添加车辆
|
* @param modelId
|
* @param color
|
* @param licensePlate
|
* @param time
|
* @param drivingLicensePhoto
|
* @param carPhoto
|
* @param insurancePhoto
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/car/addCar")
|
@ApiOperation(value = "添加车辆【1.0】", tags = {"司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "车辆型号id", name = "modelId", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "车辆id", name = "id", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "车辆颜色", name = "color", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "车牌号", name = "licensePlate", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "年审日期(需要格式化)", name = "time", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "行驶证号", name = "drivingLicenseNumber", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "行驶证照片", name = "drivingLicensePhoto", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "行驶证到期时间(yyyy-MM-dd)", name = "drivingLicenseEndTime", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "车辆照片", name = "carPhoto", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "保险照片", name = "insurancePhoto", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "保险到期时间(yyyy-MM-dd)", name = "commercialInsuranceTime", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "人车合影照片", name = "peopleAndCarsPhone", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "其他品牌", name = "otherBrand", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "其他型号", name = "otherModel", required = false, dataType = "string"),
|
// @ApiImplicitParam(value = "其他颜色", name = "otherColor", required = false, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = false, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil addCar(Integer modelId, String color, String licensePlate, Date time, String drivingLicenseNumber, String drivingLicensePhoto,
|
String drivingLicenseEndTime, String carPhoto, String insurancePhoto, String commercialInsuranceTime,
|
String peopleAndCarsPhone, HttpServletRequest request,Integer id, Integer language,String otherBrand,String otherModel){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
return carService.addCar(modelId, color, licensePlate, time, drivingLicenseNumber, drivingLicensePhoto, drivingLicenseEndTime, carPhoto, insurancePhoto
|
, commercialInsuranceTime, uid,id, peopleAndCarsPhone, language,otherBrand,otherModel);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/base/car/queryAllCarColor")
|
@ApiOperation(value = "获取车辆颜色", tags = {"司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
})
|
public ResultUtil<List<TCarColor>> queryAllCarColor(){
|
try {
|
List<TCarColor> state = tCarColorService.selectList(new EntityWrapper<TCarColor>().eq("state", 1));
|
return ResultUtil.success(state);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
}
|