package com.supersavedriving.driver.modular.system.api;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.supersavedriving.driver.modular.system.model.JoiningRequirements;
|
import com.supersavedriving.driver.modular.system.service.IJoiningRequirementsService;
|
import com.supersavedriving.driver.modular.system.warpper.*;
|
import com.supersavedriving.driver.core.common.annotion.ServiceLog;
|
import com.supersavedriving.driver.core.util.ToolUtil;
|
import com.supersavedriving.driver.modular.system.service.IBranchOfficeService;
|
import com.supersavedriving.driver.modular.system.service.IDriverService;
|
import com.supersavedriving.driver.modular.system.util.RedisUtil;
|
import com.supersavedriving.driver.modular.system.util.ResultUtil;
|
import com.supersavedriving.driver.modular.system.util.SMSUtil;
|
import com.supersavedriving.driver.modular.system.util.UUIDUtil;
|
import com.supersavedriving.driver.modular.system.warpper.*;
|
import com.supersavedriving.driver.modular.system.warpper.DriverPositionWarpper;
|
import com.supersavedriving.driver.modular.system.warpper.DriverRegisterWarpper;
|
import com.supersavedriving.driver.modular.system.warpper.PromotionWarpper;
|
import com.supersavedriving.driver.modular.system.warpper.TokenWarpper;
|
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.stream.Collectors;
|
|
/**
|
* 司机控制器
|
* @author pzb
|
* @Date 2023/2/3 14:10
|
*/
|
@RestController
|
@RequestMapping("")
|
public class DriverController {
|
|
@Autowired
|
private IBranchOfficeService branchOfficeService;
|
|
@Autowired
|
private IDriverService driverService;
|
|
@Autowired
|
private RedisUtil redisUtil;
|
|
@Autowired
|
private IJoiningRequirementsService joiningRequirementsService;
|
|
|
|
|
|
@ResponseBody
|
@PostMapping("/base/driver/queryCityList")
|
// @ServiceLog(name = "获取开通的省市数据", url = "/base/driver/queryCityList")
|
@ApiOperation(value = "获取开通的省市数据", tags = {"司机端-登录注册"}, notes = "")
|
@ApiImplicitParams({
|
})
|
public ResponseWarpper<List<OpenCityWarpper>> queryCityList(){
|
try {
|
List<OpenCityWarpper> list = branchOfficeService.queryOpenCity();
|
return ResponseWarpper.success(list);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
|
@ResponseBody
|
@PostMapping("/base/driver/queryOpenDistrict")
|
// @ServiceLog(name = "根据城市code获取开通区域", url = "/base/driver/queryOpenDistrict")
|
@ApiOperation(value = "根据城市code获取开通区域", tags = {"司机端-登录注册"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "城市code", name = "cityCode", required = true, dataType = "string"),
|
})
|
public ResponseWarpper<List<OpenCityWarpper>> queryOpenDistrict(String cityCode){
|
if(ToolUtil.isEmpty(cityCode)){
|
return ResponseWarpper.success(ResultUtil.paranErr("cityCode"));
|
}
|
try {
|
List<OpenCityWarpper> list = branchOfficeService.queryOpenDistrict(cityCode);
|
return ResponseWarpper.success(list);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
|
@ResponseBody
|
@PostMapping("/base/driver/driverRegister")
|
// @ServiceLog(name = "司机注册申请", url = "/base/driver/driverRegister")
|
@ApiOperation(value = "司机注册申请", tags = {"司机端-登录注册"}, notes = "")
|
@ApiImplicitParams({
|
})
|
public ResponseWarpper driverRegister(DriverRegisterWarpper driverRegisterWarpper){
|
try {
|
ResultUtil resultUtil = driverService.driverRegister(driverRegisterWarpper);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
|
@ResponseBody
|
@PostMapping("/base/driver/getVerificationCode")
|
// @ServiceLog(name = "获取短信验证码", url = "/base/driver/getVerificationCode")
|
@ApiOperation(value = "获取短信验证码", tags = {"司机端-登录注册"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "string"),
|
})
|
public ResponseWarpper getVerificationCode(String receiver, String phone){
|
if(ToolUtil.isEmpty(receiver)){
|
return ResponseWarpper.success(ResultUtil.paranErr("receiver"));
|
}
|
if(ToolUtil.isEmpty(phone)){
|
return ResponseWarpper.success(ResultUtil.paranErr("phone"));
|
}
|
try {
|
String numberRandom = UUIDUtil.getNumberRandom(6);
|
SMSUtil.send_huawei_sms("", receiver + phone, "[\"" + numberRandom + "\"]");
|
redisUtil.setStrValue(receiver + phone, numberRandom, 300);//5分钟有效期
|
return ResponseWarpper.success(ResultUtil.success());
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
|
@ResponseBody
|
@PostMapping("/base/driver/driverCodeLogin")
|
// @ServiceLog(name = "司机短信验证码登录", url = "/base/driver/driverCodeLogin")
|
@ApiOperation(value = "司机短信验证码登录", tags = {"司机端-登录注册"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "string"),
|
})
|
public ResponseWarpper<TokenWarpper> driverCodeLogin(String receiver, String phone, String code){
|
if(ToolUtil.isEmpty(receiver)){
|
return ResponseWarpper.success(ResultUtil.paranErr("receiver"));
|
}
|
if(ToolUtil.isEmpty(phone)){
|
return ResponseWarpper.success(ResultUtil.paranErr("phone"));
|
}
|
try {
|
ResultUtil<TokenWarpper> tokenWarpper = driverService.driverLogin(receiver, phone, code);
|
return ResponseWarpper.success(tokenWarpper);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/base/driver/driverPassLogin")
|
// @ServiceLog(name = "司机密码登录", url = "/base/driver/driverPassLogin")
|
@ApiOperation(value = "司机密码登录", tags = {"司机端-登录注册"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "密码", name = "password", required = true, dataType = "string"),
|
})
|
public ResponseWarpper<TokenWarpper> driverPassLogin(String receiver, String phone, String password){
|
if(ToolUtil.isEmpty(receiver)){
|
return ResponseWarpper.success(ResultUtil.paranErr("receiver"));
|
}
|
if(ToolUtil.isEmpty(phone)){
|
return ResponseWarpper.success(ResultUtil.paranErr("phone"));
|
}
|
if(ToolUtil.isEmpty(password)){
|
return ResponseWarpper.success(ResultUtil.paranErr("password"));
|
}
|
try {
|
ResultUtil<TokenWarpper> tokenWarpper = driverService.driverPassLogin(receiver, phone, password);
|
return ResponseWarpper.success(tokenWarpper);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
// @ResponseBody
|
// @PostMapping("/api/driver/flushedToken")
|
// @ServiceLog(name = "刷新token", url = "/api/driver/flushedToken")
|
// @ApiOperation(value = "刷新token", tags = {"司机端-登录注册"}, notes = "")
|
// @ApiImplicitParams({
|
// @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
// })
|
// public ResponseWarpper<TokenWarpper> flushedToken(){
|
// try {
|
// Integer uid = driverService.getUserByRequest();
|
// if(null == uid){
|
// return ResponseWarpper.tokenErr();
|
// }
|
// ResultUtil<TokenWarpper> tokenWarpper = driverService.flushedToken(uid);
|
// return ResponseWarpper.success(tokenWarpper);
|
// }catch (Exception e){
|
// e.printStackTrace();
|
// return new ResponseWarpper(500, e.getMessage());
|
// }
|
// }
|
|
|
|
@ResponseBody
|
@PostMapping("/api/driver/setPassword")
|
// @ServiceLog(name = "司机设置密码", url = "/api/driver/setPassword")
|
@ApiOperation(value = "司机设置密码", tags = {"司机端-首页"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "密码", name = "password", required = true, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper setPassword(String password){
|
if(ToolUtil.isEmpty(password)){
|
return ResponseWarpper.success(ResultUtil.paranErr("password"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
driverService.setPassword(uid, password);
|
return ResponseWarpper.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/driver/queryDriverPosition")
|
// @ServiceLog(name = "获取5公里范围内的司机", url = "/api/driver/queryDriverPosition")
|
@ApiOperation(value = "获取5公里范围内的司机", tags = {"司机端-首页"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper<List<String>> queryDriverPosition(){
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil<List<String>> listResultUtil = driverService.queryDriverPosition(uid);
|
return ResponseWarpper.success(listResultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
|
|
@ResponseBody
|
@PostMapping("/base/driver/addDriverPosition")
|
// @ServiceLog(name = "存储司机实时位置", url = "/base/driver/addDriverPosition")
|
public ResponseWarpper addDriverPosition(DriverPositionWarpper driverPositionWarpper) {
|
try {
|
driverService.addDriverPosition(driverPositionWarpper);
|
return ResponseWarpper.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/driver/queryPromotionQRCode")
|
// @ServiceLog(name = "获取司机推广二维码", url = "/api/driver/queryPromotionQRCode")
|
@ApiOperation(value = "获取司机推广二维码", tags = {"司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper<PromotionWarpper> queryPromotionQRCode() {
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if (null == uid) {
|
return ResponseWarpper.tokenErr();
|
}
|
PromotionWarpper promotionWarpper = driverService.queryPromotionQRCode(uid);
|
return ResponseWarpper.success(promotionWarpper);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/base/driver/queryJoiningRequirements")
|
// @ServiceLog(name = "获取加盟要求", url = "/base/driver/queryJoiningRequirements")
|
@ApiOperation(value = "获取加盟要求", tags = {"司机端-登录注册"}, notes = "")
|
@ApiImplicitParams({
|
})
|
public ResponseWarpper<List<String>> queryJoiningRequirements(){
|
try {
|
List<JoiningRequirements> joiningRequirements = joiningRequirementsService.selectList(new EntityWrapper<JoiningRequirements>().eq("status", 1).orderBy("sort"));
|
List<String> collect = joiningRequirements.stream().map(JoiningRequirements::getContent).collect(Collectors.toList());
|
return ResponseWarpper.success(collect);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/driver/queryDriverInfo")
|
// @ServiceLog(name = "获取司机个人信息", url = "/api/driver/queryDriverInfo")
|
@ApiOperation(value = "获取司机个人信息", tags = {"司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper<DriverInfoWarpper> queryDriverInfo(){
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
DriverInfoWarpper driverInfo = driverService.queryDriverInfo(uid);
|
return ResponseWarpper.success(driverInfo);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
|
@ResponseBody
|
@PostMapping("/api/driver/saveDriverInfo")
|
// @ServiceLog(name = "修改司机个人信息", url = "/api/driver/saveDriverInfo")
|
@ApiOperation(value = "修改司机个人信息", tags = {"司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper saveDriverInfo(DriverInfo driverInfo){
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil resultUtil = driverService.saveDriverInfo(uid, driverInfo);
|
return ResponseWarpper.success(resultUtil);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
}
|