package com.dsh.course.controller;
|
|
import com.dsh.course.model.dto.CarServerRes;
|
import com.dsh.course.model.vo.BaseListWarpper;
|
import com.dsh.course.model.vo.BaseWarpper;
|
import com.dsh.course.model.vo.CarInfoRes;
|
import com.dsh.course.service.ICarService;
|
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.*;
|
import com.dsh.guns.modular.system.util.ResultUtil;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
import com.dsh.course.util.TokenUtil;
|
@RestController
|
@RequestMapping("")
|
public class CarController {
|
|
@Autowired
|
private ICarService carService;
|
|
@Autowired
|
private TokenUtil tokenUtil;
|
|
|
/**
|
* 根据id获取车辆信息
|
* @param id
|
* @return
|
*/
|
@PostMapping("/car/queryCarById")
|
public CarInfoRes queryCarById(@RequestBody Integer id){
|
try {
|
return carService.queryCarById(id);
|
}catch (Exception e){
|
e.printStackTrace();
|
return null;
|
}
|
}
|
@PostMapping("/car/getCarServer")
|
public CarServerRes getCarServer(@RequestBody String carId){
|
try {
|
return carService.getCarServer(carId);
|
}catch (Exception e){
|
e.printStackTrace();
|
return null;
|
}
|
}
|
|
|
/**
|
* 获取所有车辆品牌
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/car/queryAllBrand")
|
@ApiOperation(value = "Obtain all vehicle brands获取所有车辆品牌", tags = {"Driver side - Personal center司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
@ApiImplicitParam(name = "language", value = "language", required = true, dataType = "int")
|
})
|
public ResultUtil queryAllBrand(Integer language){
|
try {
|
List<Map<String, Object>> list = carService.queryAllBrand(language);
|
return ResultUtil.success(list);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 查询车辆品牌型号
|
* @param brandId
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/car/queryCarModel")
|
@ApiOperation(value = "Query the vehicle brand and model查询车辆品牌型号", tags = {"Driver side - Personal center司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "Vehicle brand id车辆品牌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 = "Addition of vehicle添加车辆", tags = {"Driver side - Personal center司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "Vehicle type id车辆型号id", name = "modelId", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "Vehicle color车辆颜色", name = "color", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "License plate number车牌号", name = "licensePlate", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "Annual audit date (need to be formatted)年审日期(需要格式化)", name = "time", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "Driving license photo行驶证照片", name = "drivingLicensePhoto", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "Photograph of vehicle车辆照片", name = "carPhoto", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "Insurance photograph保险照片", name = "insurancePhoto", required = true, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil addCar(Integer modelId, String color, String licensePlate, Date time, String drivingLicensePhoto,
|
String carPhoto, String insurancePhoto, HttpServletRequest request){
|
try {
|
Integer uid = tokenUtil.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
return carService.addCar(modelId, color, licensePlate, time, drivingLicensePhoto, carPhoto, insurancePhoto, uid);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
/**
|
* 获取空闲车辆
|
* @param companyId
|
* @return
|
*/
|
@PostMapping("/car/queryIdleData")
|
public BaseListWarpper queryIdleData(Integer companyId){
|
try {
|
List<BaseWarpper> list = carService.queryIdleData(companyId);
|
BaseListWarpper listWarpper = new BaseListWarpper();
|
listWarpper.setList(list);
|
return listWarpper;
|
}catch (Exception e){
|
e.printStackTrace();
|
return null;
|
}
|
}
|
}
|