package com.stylefeng.guns.modular.crossCity.controller; import com.stylefeng.guns.modular.crossCity.server.ILineService; import com.stylefeng.guns.modular.crossCity.server.ILineShiftDriverService; import com.stylefeng.guns.modular.crossCity.server.ILineSiteService; import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; import com.stylefeng.guns.modular.crossCity.warpper.LineShiftWarpper; import com.stylefeng.guns.modular.crossCity.warpper.LineWarpper; import com.stylefeng.guns.modular.system.service.IDriverService; import com.stylefeng.guns.modular.system.util.ResultUtil; import com.stylefeng.guns.modular.system.warpper.BaseWarpper; 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.List; import java.util.Map; /** * 线路控制器 */ @Api @RestController @RequestMapping("/api/line") public class LineController { @Autowired private ILineService lineService; @Autowired private IDriverService driverService; @Autowired private ILineSiteService lineSiteService; @Autowired private ILineShiftDriverService lineShiftDriverService; @Autowired private IOrderCrossCityService orderCrossCityService; /** * 获取司机对应的线路 * @param request * @return */ @ResponseBody @RequestMapping(value = "/scanCodeQueryLines", 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> scanCodeQueryLines(HttpServletRequest request){ try { Integer driverId = driverService.getUserIdFormRedis(request); if(null == driverId){ return ResultUtil.tokenErr(); } List> list = lineService.scanCodeQueryLines(driverId); return ResultUtil.success(BaseWarpper.getBaseWarppers(list)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 根据选择的起点和终点获取线路 * @param startId * @param endId * @param driverId * @return */ @ResponseBody @RequestMapping(value = "/queryLines", method = RequestMethod.POST) @ApiOperation(value = "根据选择的起点和终点获取线路", tags = {"司机端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "起始站点id", name = "startId", required = true, dataType = "int"), @ApiImplicitParam(value = "终点站点id", name = "endId", required = true, dataType = "int"), @ApiImplicitParam(value = "司机id", name = "driverId", required = false, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryLines(Integer startId, Integer endId, Integer driverId){ try { List> list = lineService.queryLines(startId, endId, driverId); return ResultUtil.success(LineWarpper.getLineWarppers(list)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取线路的班次数据 * @param lineId * @param time * @param request * @return */ @ResponseBody @RequestMapping(value = "/queryLineShiftInfo", method = RequestMethod.POST) @ApiOperation(value = "获取线路的班次数据", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "线路id", name = "lineId", required = true, dataType = "int"), @ApiImplicitParam(value = "日期(2020-10-13)", name = "time", required = true, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryLineShiftInfo(Integer lineId, String time, HttpServletRequest request){ try { Integer driverId = driverService.getUserIdFormRedis(request); if(null == driverId){ return ResultUtil.tokenErr(); } List> list = lineSiteService.queryLineShiftInfo(lineId, time, driverId); return ResultUtil.success(LineShiftWarpper.getLineShiftWarppers(list)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @RequestMapping(value = "/reservation", method = RequestMethod.POST) @ApiOperation(value = "预约/取消预约", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "操作类型(1=预约,2=取消预约)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(value = "预约的班次id", name = "lineShiftId", required = true, dataType = "int"), @ApiImplicitParam(value = "日期(2020-10-13)", name = "time", required = true, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil reservation(Integer type, Integer lineShiftId, String time, HttpServletRequest request){ try { Integer driverId = driverService.getUserIdFormRedis(request); if(null == driverId){ return ResultUtil.tokenErr(); } return lineShiftDriverService.reservation(type, lineShiftId, time, driverId); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @RequestMapping(value = "/queryOrderMoney", method = RequestMethod.POST) @ApiOperation(value = "获取跨城的支付金额", tags = {"司机端-首页"}, notes = "distance:距离数(米),price:支付金额") @ApiImplicitParams({ @ApiImplicitParam(value = "起点坐标(103.32123,30.6232)", name = "startLonLat", required = true, dataType = "int"), @ApiImplicitParam(value = "终点坐标(103.32123,30.6232)", name = "endLonLat", required = true, dataType = "int"), @ApiImplicitParam(value = "乘车人数", name = "peopleNumber", required = true, dataType = "int"), @ApiImplicitParam(value = "出行方式(1=拼车,2=包车)", name = "travelMode", required = true, dataType = "int"), @ApiImplicitParam(value = "线路id", name = "lineId", required = true, dataType = "int"), @ApiImplicitParam(value = "服务车型id", name = "serverCarModelId", required = true, dataType = "int"), @ApiImplicitParam(value = "车辆总座位数", name = "totalSeat", required = true, dataType = "int"), @ApiImplicitParam(value = "座位编号(1,3,4)", name = "seatNumber", required = true, dataType = "int") }) public ResultUtil queryOrderMoney(String startLonLat, String endLonLat, Integer peopleNumber, Integer travelMode, Integer lineId, Integer serverCarModelId, Integer totalSeat, String seatNumber){ try { return orderCrossCityService.queryOrderMoney(startLonLat, endLonLat, peopleNumber, travelMode, lineId, serverCarModelId, totalSeat, seatNumber); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } }