增加手机号校验功能
This commit is contained in:
parent
dcd5eb1a83
commit
ca7932c8ca
|
|
@ -8,7 +8,9 @@ import com.bonus.sgzb.common.core.exception.ServiceException;
|
||||||
import com.bonus.sgzb.common.core.utils.GlobalConstants;
|
import com.bonus.sgzb.common.core.utils.GlobalConstants;
|
||||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.sgzb.common.redis.service.RedisService;
|
import com.bonus.sgzb.common.redis.service.RedisService;
|
||||||
|
import com.bonus.sgzb.system.api.domain.SysUser;
|
||||||
import com.bonus.sgzb.system.config.TencentSmsConfig;
|
import com.bonus.sgzb.system.config.TencentSmsConfig;
|
||||||
|
import com.bonus.sgzb.system.mapper.SysUserMapper;
|
||||||
import com.bonus.sgzb.system.service.ISysSmsService;
|
import com.bonus.sgzb.system.service.ISysSmsService;
|
||||||
import com.tencentcloudapi.common.Credential;
|
import com.tencentcloudapi.common.Credential;
|
||||||
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||||
|
|
@ -46,6 +48,8 @@ public class SysSmsServiceImpl implements ISysSmsService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
@Resource
|
||||||
|
private SysUserMapper sysUserMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TencentSmsConfig tencentSmsConfig;
|
private TencentSmsConfig tencentSmsConfig;
|
||||||
|
|
@ -139,6 +143,11 @@ public class SysSmsServiceImpl implements ISysSmsService {
|
||||||
if (phone == null || phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) {
|
if (phone == null || phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) {
|
||||||
return AjaxResult.error("手机号格式错误,请输入11位数字号码");
|
return AjaxResult.error("手机号格式错误,请输入11位数字号码");
|
||||||
}
|
}
|
||||||
|
// 校验是否存在该手机号
|
||||||
|
SysUser sysUser = sysUserMapper.checkPhoneUnique(phone);
|
||||||
|
if (sysUser == null) {
|
||||||
|
return AjaxResult.error("该手机号未绑定用户,请重新确认");
|
||||||
|
}
|
||||||
// 检查发送次数是否超限
|
// 检查发送次数是否超限
|
||||||
if (isOverLimit(phone)) {
|
if (isOverLimit(phone)) {
|
||||||
throw new ServiceException("当天此手机号发送验证码次数超过限制", 1001);
|
throw new ServiceException("当天此手机号发送验证码次数超过限制", 1001);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue