package com.stylefeng.guns.modular.api;
|
|
import com.stylefeng.guns.modular.system.model.Driver;
|
import com.stylefeng.guns.modular.system.service.IDriverService;
|
import com.stylefeng.guns.modular.system.service.IOrderEvaluateService;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import com.stylefeng.guns.modular.system.warpper.BaseWarpper;
|
import com.stylefeng.guns.modular.system.warpper.DriverInfoWarpper;
|
import com.stylefeng.guns.modular.system.warpper.OrderEvaluateWarpper;
|
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.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
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("")
|
public class DriverController {
|
|
@Autowired
|
private IDriverService driverService;
|
|
@Autowired
|
private IOrderEvaluateService orderEvaluateService;
|
|
|
|
|
|
|
/**
|
* 获取5公里范围内空闲司机数量
|
* @param type 业务类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/base/driver/queryIdleDriver")
|
@ApiOperation(value = "获取5公里范围内空闲司机数量", tags = {"用户端-首页"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "业务类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车 7=接送机)", name = "type", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "乘客当前定位经度", name = "lon", required = true, dataType = "double"),
|
@ApiImplicitParam(value = "乘客当前定位纬度", name = "lat", required = true, dataType = "double")
|
})
|
public ResultUtil<BaseWarpper> queryIdleDriver(Integer type, Double lon, Double lat){
|
try {
|
List<Driver> list = driverService.queryIdleDriver(type, lon, lat, 5D, null);
|
BaseWarpper baseWarpper = new BaseWarpper();
|
baseWarpper.setNumber(list.size());
|
return ResultUtil.success(baseWarpper);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
/**
|
* 获取司机详情
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/driver/queryDriverInfo")
|
@ApiOperation(value = "获取司机详情", tags = {"用户端-订单相关"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "司机id", name = "id", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<DriverInfoWarpper> queryDriverInfo(Integer id){
|
try {
|
Map<String, Object> map = driverService.queryDriverInfo(id);
|
String name = String.valueOf(map.get("name"));
|
map.put("name", name.substring(0, 1) + "师傅");
|
List<BaseWarpper> list = driverService.queryBusiness(id);
|
map.put("list", list);
|
return ResultUtil.success(DriverInfoWarpper.getDriverInfoWarpper(map));
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 获取司机的历史评价
|
* @param id
|
* @param pageNum
|
* @param size
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/driver/queryOrderEvaluate")
|
@ApiOperation(value = "获取司机的历史评价", tags = {"用户端-订单相关"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "司机id", name = "id", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<OrderEvaluateWarpper>> queryOrderEvaluate(Integer id, Integer pageNum, Integer size){
|
try {
|
List<Map<String, Object>> list = orderEvaluateService.queryOrderEvaluate(id, pageNum, size);
|
return ResultUtil.success(OrderEvaluateWarpper.getOrderEvaluateWarpper(list));
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
}
|