mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-06-01 14:40:10 +08:00
feat 增加绑定手机
feat 增加修改手机号码 feat 增加收藏文章功能
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.mdd.common.enums;
|
||||
|
||||
/**
|
||||
* 相册枚举
|
||||
*/
|
||||
public enum LoginEnum {
|
||||
|
||||
ACCOUNT_PASSWORD(1, "账号/手机号密码登录"),
|
||||
MOBILE_CAPTCHA(2, "手机验证码登录"),
|
||||
|
||||
THIRD_LOGIN(3, "第三方登录");
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*/
|
||||
private final int code;
|
||||
private final String msg;
|
||||
LoginEnum(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态码
|
||||
*
|
||||
* @author fzr
|
||||
* @return Long
|
||||
*/
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提示
|
||||
*
|
||||
* @author fzr
|
||||
* @return String
|
||||
*/
|
||||
public String getMsg() {
|
||||
return this.msg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,12 @@ package com.mdd.common.plugin.notice;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.common.entity.notice.NoticeRecord;
|
||||
import com.mdd.common.entity.server.Sys;
|
||||
import com.mdd.common.entity.smsLog.SmsLog;
|
||||
import com.mdd.common.enums.NoticeEnum;
|
||||
import com.mdd.common.enums.SmsEnum;
|
||||
import com.mdd.common.enums.YesNoEnum;
|
||||
import com.mdd.common.mapper.notice.NoticeRecordMapper;
|
||||
import com.mdd.common.mapper.smsLog.SmsLogMapper;
|
||||
import com.mdd.common.util.SpringUtils;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
|
||||
@@ -14,28 +19,40 @@ import javax.annotation.Resource;
|
||||
*/
|
||||
public class NoticeCheck {
|
||||
|
||||
public static Boolean verify(Integer scene, Object code) {
|
||||
NoticeRecordMapper noticeRecordMapper = SpringUtils.getBean(NoticeRecordMapper.class);
|
||||
public static Boolean verify(Integer sceneId, String code, String mobile) {
|
||||
|
||||
NoticeRecord noticeRecord = noticeRecordMapper.selectOne(new QueryWrapper<NoticeRecord>()
|
||||
.eq("scene", scene)
|
||||
.eq("status", 1)
|
||||
.eq("is_read", 0)
|
||||
.eq("is_captcha", 1)
|
||||
.eq("is_delete", 0)
|
||||
.eq("code", code.toString().toLowerCase())
|
||||
.last("limit 1"));
|
||||
SmsLogMapper smsLogMapper = SpringUtils.getBean(SmsLogMapper.class);
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("mobile", mobile);
|
||||
queryWrapper.eq("send_status", SmsEnum.SEND_SUCCESS.getCode());
|
||||
queryWrapper.in("scene_id", NoticeEnum.getSmsScene());
|
||||
queryWrapper.eq("is_verify", YesNoEnum.NO.getCode());
|
||||
if (sceneId.equals(0) == false) {
|
||||
queryWrapper.eq("scene_id", sceneId);
|
||||
}
|
||||
queryWrapper.orderByDesc("send_time");
|
||||
queryWrapper.last("limit 1");
|
||||
SmsLog smsLog = smsLogMapper.selectOne(queryWrapper);
|
||||
|
||||
if (StringUtils.isNull(noticeRecord)) {
|
||||
if (StringUtils.isNull(smsLog)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean result = noticeRecord.getCreateTime() > ((System.currentTimeMillis() / 1000) - (5 * 60)); //5分钟有效
|
||||
// 没有验证码 或 最新验证码已校验 或 已过期(有效期:5分钟)
|
||||
if (smsLog.getIsVerify().equals(1) || smsLog.getSendTime() < System.currentTimeMillis() / 1000 - (5*60)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
noticeRecord.setRead(1);
|
||||
noticeRecord.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
noticeRecordMapper.updateById(noticeRecord);
|
||||
return result;
|
||||
// 更新校验状态
|
||||
smsLog.setCheckNum(smsLog.getCheckNum() + 1);
|
||||
if (smsLog.getCode().equals(code)) {
|
||||
smsLog.setIsVerify(YesNoEnum.YES.getCode());
|
||||
smsLogMapper.updateById(smsLog);
|
||||
return true;
|
||||
} else {
|
||||
smsLogMapper.updateById(smsLog);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user