xuhy
2024-05-28 5470d21a35286abe41fafc25a7deaabefd7c55da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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();
        }
    }
}