| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private IEditionService editionService; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @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()); |
| | | } |
| | | } |
| | | } |