From 41e84c3bf3baa9f9f91bbb5343945f0032ae960d Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期六, 11 三月 2023 17:36:43 +0800 Subject: [PATCH] 新增加司机端接口 --- driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java | 159 +++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 112 insertions(+), 47 deletions(-) diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java index 6d6a58b..b6ad26a 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java @@ -1,6 +1,9 @@ package com.supersavedriving.driver.modular.system.api; -import com.alibaba.fastjson.JSON; +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; @@ -10,16 +13,14 @@ 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.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.mongodb.core.geo.GeoJsonPoint; -import org.springframework.data.mongodb.core.query.Criteria; -import org.springframework.data.mongodb.core.query.Query; -import org.springframework.data.mongodb.core.query.Update; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -27,7 +28,7 @@ import javax.servlet.http.HttpServletRequest; import java.util.List; -import java.util.Objects; +import java.util.stream.Collectors; /** * 司机控制器 @@ -47,13 +48,16 @@ @Autowired private RedisUtil redisUtil; + @Autowired + private IJoiningRequirementsService joiningRequirementsService; + @ResponseBody @PostMapping("/base/driver/queryCityList") - @ServiceLog(name = "获取开通的省市数据", url = "/base/driver/queryCityList") +// @ServiceLog(name = "获取开通的省市数据", url = "/base/driver/queryCityList") @ApiOperation(value = "获取开通的省市数据", tags = {"司机端-登录注册"}, notes = "") @ApiImplicitParams({ }) @@ -72,7 +76,7 @@ @ResponseBody @PostMapping("/base/driver/queryOpenDistrict") - @ServiceLog(name = "根据城市code获取开通区域", url = "/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"), @@ -95,7 +99,7 @@ @ResponseBody @PostMapping("/base/driver/driverRegister") - @ServiceLog(name = "司机注册申请", url = "/base/driver/driverRegister") +// @ServiceLog(name = "司机注册申请", url = "/base/driver/driverRegister") @ApiOperation(value = "司机注册申请", tags = {"司机端-登录注册"}, notes = "") @ApiImplicitParams({ }) @@ -114,7 +118,7 @@ @ResponseBody @PostMapping("/base/driver/getVerificationCode") - @ServiceLog(name = "获取短信验证码", url = "/base/driver/getVerificationCode") +// @ServiceLog(name = "获取短信验证码", url = "/base/driver/getVerificationCode") @ApiOperation(value = "获取短信验证码", tags = {"司机端-登录注册"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"), @@ -143,7 +147,7 @@ @ResponseBody @PostMapping("/base/driver/driverCodeLogin") - @ServiceLog(name = "司机短信验证码登录", url = "/base/driver/driverCodeLogin") +// @ServiceLog(name = "司机短信验证码登录", url = "/base/driver/driverCodeLogin") @ApiOperation(value = "司机短信验证码登录", tags = {"司机端-登录注册"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"), @@ -169,7 +173,7 @@ @ResponseBody @PostMapping("/base/driver/driverPassLogin") - @ServiceLog(name = "司机密码登录", url = "/base/driver/driverPassLogin") +// @ServiceLog(name = "司机密码登录", url = "/base/driver/driverPassLogin") @ApiOperation(value = "司机密码登录", tags = {"司机端-登录注册"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"), @@ -197,45 +201,45 @@ - @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(HttpServletRequest request){ - try { - Integer uid = driverService.getUserByRequset(request); - if(null == uid){ - return ResponseWarpper.success(ResultUtil.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/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") +// @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, HttpServletRequest request){ + public ResponseWarpper setPassword(String password){ if(ToolUtil.isEmpty(password)){ return ResponseWarpper.success(ResultUtil.paranErr("password")); } try { - Integer uid = driverService.getUserByRequset(request); + Integer uid = driverService.getUserByRequest(); if(null == uid){ - return ResponseWarpper.success(ResultUtil.tokenErr()); + return ResponseWarpper.tokenErr(); } driverService.setPassword(uid, password); return ResponseWarpper.success(); @@ -249,16 +253,16 @@ @ResponseBody @PostMapping("/api/driver/queryDriverPosition") - @ServiceLog(name = "获取5公里范围内的司机", url = "/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(HttpServletRequest request){ + public ResponseWarpper<List<String>> queryDriverPosition(){ try { - Integer uid = driverService.getUserByRequset(request); + Integer uid = driverService.getUserByRequest(); if(null == uid){ - return ResponseWarpper.success(ResultUtil.tokenErr()); + return ResponseWarpper.tokenErr(); } ResultUtil<List<String>> listResultUtil = driverService.queryDriverPosition(uid); return ResponseWarpper.success(listResultUtil); @@ -274,7 +278,7 @@ @ResponseBody @PostMapping("/base/driver/addDriverPosition") - @ServiceLog(name = "存储司机实时位置", url = "/base/driver/addDriverPosition") +// @ServiceLog(name = "存储司机实时位置", url = "/base/driver/addDriverPosition") public ResponseWarpper addDriverPosition(DriverPositionWarpper driverPositionWarpper) { try { driverService.addDriverPosition(driverPositionWarpper); @@ -289,16 +293,16 @@ @ResponseBody @PostMapping("/api/driver/queryPromotionQRCode") - @ServiceLog(name = "获取司机推广二维码", url = "/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(HttpServletRequest request) { + public ResponseWarpper<PromotionWarpper> queryPromotionQRCode() { try { - Integer uid = driverService.getUserByRequset(request); + Integer uid = driverService.getUserByRequest(); if (null == uid) { - return ResponseWarpper.success(ResultUtil.tokenErr()); + return ResponseWarpper.tokenErr(); } PromotionWarpper promotionWarpper = driverService.queryPromotionQRCode(uid); return ResponseWarpper.success(promotionWarpper); @@ -310,6 +314,67 @@ + @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()); + } + } } -- Gitblit v1.7.1