package com.stylefeng.guns.modular.CharteredCar.controller;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.stylefeng.guns.modular.CharteredCar.dto.CharteredCarDto;
|
import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService;
|
import com.stylefeng.guns.modular.system.model.ServerCarModel;
|
import com.stylefeng.guns.modular.system.model.TCharteredService;
|
import com.stylefeng.guns.modular.system.service.IServerCarModelService;
|
import com.stylefeng.guns.modular.system.service.ITCharteredServiceService;
|
import com.stylefeng.guns.modular.system.service.IUserInfoService;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import io.swagger.annotations.Api;
|
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 javax.servlet.http.HttpServletRequest;
|
import java.util.Date;
|
import java.util.List;
|
|
@Api
|
@RestController
|
@RequestMapping("/api/orderCharteredCar")
|
public class OrderCharteredCarController {
|
|
@Autowired
|
private IOrderCharteredCarService orderCharteredCarService;
|
|
@Autowired
|
private IUserInfoService userInfoService;
|
|
@Autowired
|
private IServerCarModelService serverCarModelService;
|
@Autowired
|
private ITCharteredServiceService charteredService;
|
|
|
|
@ResponseBody
|
@RequestMapping(value = "/list", method = RequestMethod.POST)
|
@ApiOperation(value = "根据tag查询包车,全部传-1", tags = {"用户端-包车"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
@ApiImplicitParam(value = "服务车型id", name = "serverCarModelId", required = true, dataType = "int")
|
})
|
public ResultUtil<List<TCharteredService>> list(Integer serverCarModelId){
|
EntityWrapper<TCharteredService> tCharteredServiceEntityWrapper = new EntityWrapper<>();
|
tCharteredServiceEntityWrapper.eq("status",1);
|
if (serverCarModelId!=-1){
|
tCharteredServiceEntityWrapper.eq("serverCarModelId",serverCarModelId);
|
}
|
List<TCharteredService> tCharteredServices = charteredService.selectList(tCharteredServiceEntityWrapper);
|
for (TCharteredService tCharteredService : tCharteredServices) {
|
ServerCarModel serverCarModel = serverCarModelService.selectById(tCharteredService.getServerCarModelId());
|
if (serverCarModel!=null) {
|
tCharteredService.setServerCarModelName(serverCarModel.getName());
|
}
|
}
|
return ResultUtil.success(tCharteredServices);
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/tag", method = RequestMethod.POST)
|
@ApiOperation(value = "获取包车tag", tags = {"用户端-包车"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<ServerCarModel>> orderCharteredCar(){
|
List<ServerCarModel> serverCarModels = serverCarModelService.selectList(new EntityWrapper<ServerCarModel>().eq("type", 3).eq("state", 1));
|
return ResultUtil.success(serverCarModels);
|
}
|
|
|
|
@ResponseBody
|
@RequestMapping(value = "/orderCharteredCar", method = RequestMethod.POST)
|
@ApiOperation(value = "提交包车订单", tags = {"用户端-包车"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil orderCharteredCar(@RequestBody CharteredCarDto charteredCarDto, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
charteredCarDto.setUserId(uid);
|
return orderCharteredCarService.createOrder(charteredCarDto);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
}
|