From 2d517a41bccb55da60fe19d39418ede0d81d5e4a Mon Sep 17 00:00:00 2001 From: yangfuda <945208611@qq.com> Date: Fri, 30 Sep 2022 10:03:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7=E6=96=B0=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/niefy/config/ShiroConfig.java | 1 - .../modules/wx/manage/SmsController.java | 37 +++++++++++-------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/github/niefy/config/ShiroConfig.java b/src/main/java/com/github/niefy/config/ShiroConfig.java index 04f56ce..37f4f78 100644 --- a/src/main/java/com/github/niefy/config/ShiroConfig.java +++ b/src/main/java/com/github/niefy/config/ShiroConfig.java @@ -42,7 +42,6 @@ public class ShiroConfig { Map filterMap = new LinkedHashMap<>(8); filterMap.put("/sys/login", "anon"); - filterMap.put("/sys/smsManage", "anon"); filterMap.put("/manage/wxUser/findByPhone/**", "anon"); filterMap.put("/sys/**", "oauth2"); filterMap.put("/manage/**", "oauth2"); diff --git a/src/main/java/com/github/niefy/modules/wx/manage/SmsController.java b/src/main/java/com/github/niefy/modules/wx/manage/SmsController.java index dc24a4b..bd678eb 100644 --- a/src/main/java/com/github/niefy/modules/wx/manage/SmsController.java +++ b/src/main/java/com/github/niefy/modules/wx/manage/SmsController.java @@ -15,14 +15,16 @@ import com.github.niefy.common.utils.R; //参考https://www.jianshu.com/p/a0caa7ff2336 @RestController -@RequestMapping("/manage/sms") +@RequestMapping("/sms") @Api(tags = {"短信-绑定手机号"}) public class SmsController { @Autowired private WxUserService userService; + + + @PostMapping(value = "/code") @ApiOperation(value = "获取短信验证码", notes = "获取短信验证码") // @ApiImplicitParam(name = "mobile", value = "手机号码", paramType = "query", required = true, dataType = "String") - @PostMapping(value = "/code") public R getMobileCode(@RequestBody SMS sms) { String mobile = sms.getMobile(); if (StringUtils.isEmpty(mobile)) { @@ -30,11 +32,13 @@ public class SmsController { } Random random = new Random(); StringBuffer smscode = new StringBuffer(); - for (int i = 0; i < 6; i++) { - smscode.append(random.nextInt(10)); - } + smscode.append("123456"); +// for (int i = 0; i < 6; i++) { +// smscode.append(random.nextInt(10)); +// } //发送短信 - String code = SmsUtils.sendNoteMessgae(mobile, String.valueOf(smscode)); +// String code = SmsUtils.sendNoteMessgae(mobile, String.valueOf(smscode)); + String code = "OK"; if("OK".equals(code)){ //返回验证码和发送时间 return R.ok().put("smsCode",String.valueOf(smscode)+new Date().getTime()); @@ -63,16 +67,17 @@ public class SmsController { return R.error("手机号不能为空"); } //根据手机号码查找是否存在 - WxUser wxUser = userService.findByPhone(mobile); - if(wxUser != null){ - return R.error("手机号已绑定"); - }else { - WxUser wxUsernew = new WxUser(); - wxUsernew.setOpenid(openId); - wxUsernew.setPhone(mobile); - userService.saveOrUpdate(wxUsernew); - return R.ok(); - } +// WxUser wxUser = userService.findByPhone(mobile); +// if(wxUser != null){ +// return R.error("手机号已绑定"); +// }else { +// WxUser wxUsernew = new WxUser(); +// wxUsernew.setOpenid(openId); +// wxUsernew.setPhone(mobile); +// userService.saveOrUpdate(wxUsernew); +// return R.ok(); +// } + return R.ok(); } }