puzhibing
2023-08-01 98bc380ae322eaac2ee7e21d0c565e30eacce2b5
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
package com.stylefeng.guns.modular.CharteredCar.controller;
 
import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
 
@Api
@RestController
@RequestMapping("/api/orderCharteredCar")
public class OrderCharteredCarController {
 
    @Autowired
    private IOrderCharteredCarService orderCharteredCarService;
 
    @Autowired
    private IUserInfoService userInfoService;
 
 
 
    @ResponseBody
    @RequestMapping(value = "/orderCharteredCar", method = RequestMethod.POST)
    @ApiOperation(value = "提交包车订单", tags = {"用户端-包车"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "出行时间(2020-09-21 16:00:00)", name = "travelTime", required = true, dataType = "string"),
            @ApiImplicitParam(value = "用车时长", name = "carTime", required = true, dataType = "int"),
            @ApiImplicitParam(value = "服务车型id", name = "serverCarModelId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "车型用途", name = "modelUse", required = true, dataType = "string"),
            @ApiImplicitParam(value = "出行人数", name = "peopleNumber", required = true, dataType = "int"),
            @ApiImplicitParam(value = "联系人", name = "contactPerson", required = true, dataType = "string"),
            @ApiImplicitParam(value = "联系电话", name = "contactPhone", required = true, dataType = "string"),
            @ApiImplicitParam(value = "下单地点经纬度(103.1233,30.135412)", name = "placeLonLat", required = true, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil orderCharteredCar(Date travelTime, Integer carTime, Integer serverCarModelId, String modelUse, Integer peopleNumber,
                                        String contactPerson, String contactPhone, String placeLonLat, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return orderCharteredCarService.orderCharteredCar(travelTime, carTime, serverCarModelId, modelUse, peopleNumber, contactPerson, contactPhone, placeLonLat, uid);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
}