Commit e93888d8 authored by liqin's avatar liqin 💬

Merge branch 'master' of http://111.203.232.171:8888/licc/shop-mall into master

parents 9258ced6 cc1a4120
...@@ -131,36 +131,36 @@ public class LoginController { ...@@ -131,36 +131,36 @@ public class LoginController {
@ApiImplicitParam(name = "sms", value = "验证码",required = true, dataType = "String") @ApiImplicitParam(name = "sms", value = "验证码",required = true, dataType = "String")
}) })
@RequestMapping("/register") @RequestMapping("/register")
public Map register(@RequestParam String userId,@RequestParam String beInvitedCode, @RequestParam String sms) { public Map register(@RequestParam String userId,@RequestParam String beInvitedCode, @RequestParam String sms)throws Exception {
User users=null; User users=null;
String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,userId,Constants.Sms.CodeType.LOGIN_OR_REGISTER+""); String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,userId,Constants.Sms.CodeType.LOGIN_OR_REGISTER+"");
String redisCode=redisUtils.getValue(key); String redisCode=redisUtils.getValue(key);
if(StringUtil.isBlank(redisCode) || !sms.equals(redisCode)){ if(StringUtil.isBlank(redisCode) || !sms.equals(redisCode)){
try { // try {
throw new BaseException(ResultEnum.FAIL_VERIFY); // throw new BaseException(ResultEnum.FAIL_VERIFY);
//
} catch (BaseException e) { // } catch (BaseException e) {
Map map=new HashMap(); Map map=new HashMap();
map.put("code","1003"); map.put("code","1003");
map.put("msg","验证码错误"); map.put("msg","验证码错误");
// throw new BaseException(ResultEnum.FAIL_VERIFY); // throw new BaseException(ResultEnum.FAIL_VERIFY);
return map; return map;
} // }
} }
redisUtils.delete(key); redisUtils.delete(key);
//判断phone是否符合输入类型 //判断phone是否符合输入类型
if(!userId.matches(Constants.RegConstant.PHONE_REGSTR)){ if(!userId.matches(Constants.RegConstant.PHONE_REGSTR)){
try { // try {
throw new BaseException(ResultEnum.PHONE_ERROR); // throw new BaseException(ResultEnum.PHONE_ERROR);
} catch (BaseException e) { // } catch (BaseException e) {
e.printStackTrace(); // e.printStackTrace();
Map map=new HashMap(); Map map=new HashMap();
map.put("code","1008"); map.put("code","1008");
map.put("msg","手机号码格式不正确"); map.put("msg","手机号码格式不正确");
// throw new BaseException(ResultEnum.FAIL_VERIFY); // throw new BaseException(ResultEnum.FAIL_VERIFY);
return map; return map;
} // }
} }
return usersService.userByZx(userId,beInvitedCode); return usersService.userByZx(userId,beInvitedCode);
......
package cn.wisenergy.web.admin.controller.app; package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.enums.ResultEnum;
import cn.wisenergy.common.utils.*; import cn.wisenergy.common.utils.*;
import cn.wisenergy.web.sms.BaseException;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
...@@ -19,7 +17,7 @@ import java.util.Map; ...@@ -19,7 +17,7 @@ import java.util.Map;
@Api(tags = "发送手机验证码 codeType 0注册/登录验证 1修改密码 2订单通知信息") @Api(tags = "发送手机验证码 codeType 0注册/登录验证 1修改密码 2订单通知信息")
@Slf4j @Slf4j
@RequestMapping("/api/sms") @RequestMapping("/api/sms/")
@RestController @RestController
public class SmsController { public class SmsController {
...@@ -46,25 +44,14 @@ public class SmsController { ...@@ -46,25 +44,14 @@ public class SmsController {
Map map=new HashMap(); Map map=new HashMap();
//判断phone和codeType是否符合输入类型 //判断phone和codeType是否符合输入类型
if(!phone.matches(Constants.RegConstant.PHONE_REGSTR)){ if(!phone.matches(Constants.RegConstant.PHONE_REGSTR)){
try {
throw new BaseException(ResultEnum.PHONE_ERROR); return ResultUtils.returnFail ("手机号码格式不正确","1009") ;
} catch (BaseException e) {
e.printStackTrace();
map.put("code","1005");
map.put("msg","账号不存在,请注册");
return (Result) map;
}
} }
if(codeType!=Constants.Sms.CodeType.LOGIN_OR_REGISTER && codeType!=Constants.Sms.CodeType.PASS_UPDATE && codeType!=Constants.Sms.CodeType.ORDER_NOTICE){ if(codeType!=Constants.Sms.CodeType.LOGIN_OR_REGISTER && codeType!=Constants.Sms.CodeType.PASS_UPDATE && codeType!=Constants.Sms.CodeType.ORDER_NOTICE){
try {
throw new BaseException(ResultEnum.CODETYPE_ERROR); return ResultUtils.returnFail ("输入codeType不正确!","1008") ;
} catch (BaseException e) {
e.printStackTrace();
map.put("code","1009");
map.put("msg","手机号码格式不正确");
return (Result) map;
}
} }
String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,phone,codeType+""); String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,phone,codeType+"");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment