From 0dc953b5cb037762fb3eeed15ecca0b925ebe148 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期四, 23 三月 2023 00:13:27 +0800 Subject: [PATCH] 新增加司机端接口 --- driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 115 insertions(+), 0 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 3089742..561762b 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,7 @@ package com.supersavedriving.driver.modular.system.api; import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.supersavedriving.driver.modular.system.model.Edition; import com.supersavedriving.driver.modular.system.model.JoiningRequirements; import com.supersavedriving.driver.modular.system.service.*; import com.supersavedriving.driver.modular.system.util.PayMoneyUtil; @@ -17,6 +18,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -71,6 +73,9 @@ @Autowired private PayMoneyUtil payMoneyUtil; + + @Autowired + private IEditionService editionService; @@ -729,4 +734,114 @@ } + @ResponseBody + @PostMapping("/api/driver/updatePassword") +// @ServiceLog(name = "修改密码", url = "/api/driver/updatePassword") + @ApiOperation(value = "修改密码", tags = {"司机端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "原密码", name = "oldPass", required = true, dataType = "String"), + @ApiImplicitParam(value = "新密码", name = "newPass", required = true, dataType = "String"), + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResponseWarpper updatePassword(String oldPass, String newPass){ + if(ToolUtil.isEmpty(oldPass)){ + return ResponseWarpper.success(ResultUtil.paranErr("oldPass")); + } + if(ToolUtil.isEmpty(newPass)){ + return ResponseWarpper.success(ResultUtil.paranErr("newPass")); + } + try { + Integer uid = driverService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.tokenErr(); + } + ResultUtil resultUtil = driverService.updatePassword(uid, oldPass, newPass); + return ResponseWarpper.success(resultUtil); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + @ResponseBody + @PostMapping("/api/driver/recoverPassword") +// @ServiceLog(name = "忘记密码", url = "/api/driver/recoverPassword") + @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 recoverPassword(String password){ + if(ToolUtil.isEmpty(password)){ + return ResponseWarpper.success(ResultUtil.paranErr("password")); + } + try { + Integer uid = driverService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.tokenErr(); + } + ResultUtil resultUtil = driverService.recoverPassword(uid, password); + return ResponseWarpper.success(resultUtil); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + + @ResponseBody + @PostMapping("/base/driver/verifySMSCode") +// @ServiceLog(name = "验证短信验证码", url = "/base/driver/verifySMSCode") + @ApiOperation(value = "验证短信验证码", tags = {"司机端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "String"), + @ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "String"), + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResponseWarpper verifySMSCode(String phone, String code){ + if(ToolUtil.isEmpty(phone)){ + return ResponseWarpper.success(ResultUtil.paranErr("phone")); + } + if(ToolUtil.isEmpty(phone)){ + return ResponseWarpper.success(ResultUtil.paranErr("code")); + } + try { + ResultUtil resultUtil = ResultUtil.success(); + phone = phone.indexOf("+86") < 0 ? "+86" + phone : phone; + String value = redisUtil.getValue(phone); + if(ToolUtil.isEmpty(value) || !value.equals(code)){ + resultUtil = ResultUtil.error("验证码无效"); + } + redisUtil.remove(phone); + return ResponseWarpper.success(resultUtil); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + @ResponseBody + @PostMapping("/api/driver/queryNewVersion") +// @ServiceLog(name = "获取最新版本", url = "/api/driver/queryNewVersion") + @ApiOperation(value = "获取最新版本", tags = {"司机端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResponseWarpper<EditionWarpper> queryNewVersion(){ + try { + Edition edition = editionService.selectOne(new EntityWrapper<Edition>().eq("editionPort", 2).eq("status", 1).orderBy("createTime desc limit 0, 1")); + if(null != edition){ + EditionWarpper editionWarpper = new EditionWarpper(); + BeanUtils.copyProperties(edition, editionWarpper); + return ResponseWarpper.success(editionWarpper); + } + return ResponseWarpper.success(); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } } -- Gitblit v1.7.1