短信发送方法签名重构

This commit is contained in:
ZZ 2021-08-11 17:18:56 +08:00
parent c597826849
commit 7bfc31e2a0
2 changed files with 12 additions and 11 deletions

View File

@ -22,13 +22,14 @@ public interface IXhpcSmsService {
List<Map<String, Object>> getList(Integer status,String phone); List<Map<String, Object>> getList(Integer status,String phone);
/** /**
* 公共调用方法 * 发送短信通用方法
*
* @param phone 手机号 * @param phone 手机号
* @param content 内容 * @param content 内容
* @param random 验证码6位 * @param random 验证码6位 不为空则是获取验证码
* @return * @return
*/ */
AjaxResult getPhoneCode(String phone,String content,String random); AjaxResult send(String phone, String content, String random);
} }

View File

@ -44,7 +44,7 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService{
public AjaxResult getLogonPhoneCode(String phone) { public AjaxResult getLogonPhoneCode(String phone) {
String random = getRandom(); String random = getRandom();
String conten ="【小华充电】您的验证码是:"+random+"有效期为5分钟。如非本人操作可不用理会。"; String conten ="【小华充电】您的验证码是:"+random+"有效期为5分钟。如非本人操作可不用理会。";
return getPhoneCode(phone,conten,random); return send(phone, conten, random);
} }
@Override @Override
@ -54,15 +54,15 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService{
} }
@Override @Override
public AjaxResult getPhoneCode(String phone, String content,String random) { public AjaxResult send(String phone, String content, String random) {
//调用接口 //调用接口
String pattern ="^([1][0-9]{10})"; String pattern = "^([1][0-9]{10})";
Pattern compile = Pattern.compile(pattern); Pattern compile = Pattern.compile(pattern);
Matcher m =compile.matcher(phone); Matcher m = compile.matcher(phone);
boolean isMatch = m.matches(); boolean isMatch = m.matches();
if(!isMatch){ if (!isMatch) {
return AjaxResult.error("1003","请输入正确的手机号"); return AjaxResult.error("1003", "请输入正确的手机号");
} }
//添加短信记录 //添加短信记录
XhpcSms xhpcSms =new XhpcSms(); XhpcSms xhpcSms =new XhpcSms();