登录获取验证码以及验证码的配置

This commit is contained in:
2023-02-23 11:00:39 +08:00
parent 57eb42abcf
commit 9fbfae5486
11 changed files with 274 additions and 45 deletions

View File

@@ -0,0 +1,105 @@
package com.zscat.mallplus.enums;
import lombok.Getter;
/**
* @Author dimengzhe
* @Date 2023/2/23 9:01
* @Description
*/
public class SmsEnum {
/**
* 手机短信登录验证码时效(秒)
*/
public static final Long APP_LOGIN_CODE_TIME_LIMIT = 300L;
/**
* 发送验证码
*/
@Getter
public static enum SendEnum {
/**
* 登录
*/
LOGIN("1", "loginCode","登录"),
;
/**
* code值
*/
private final String code;
/**
* 备注
*/
private final String remarks;
/**
* 缓存识别码
*/
private final String redisKey;
/**
* 构造器
*
* @param code code值
* @param redisKey 缓存识别码
* @param remarks 备注
*/
private SendEnum(String code, String redisKey,String remarks) {
this.code = code;
this.remarks = remarks;
this.redisKey = redisKey;
}
}
@Getter
public static enum SmsReturnEnum {
/**
* 发送短信返回参数
*/
ZERO("1", "提交成功"),
ONE("-1", "账号未注册"),
TWO("-2", "网络访问超时,请稍后再试"),
three("-3", "帐号或密码错误"),
FOUR("-4", "只支持单发"),
FIVE("-5", "余额不足,请充值"),
SIX("-6", "定时发送时间不是有效的时间格式"),
SEVEN("-7", "提交信息末尾未加签名请添加中文的企业签名【 】或未采用gb2312编码"),
EIGHT("-8", "发送内容需在1到300字之间"),
NINE("-9", "发送号码为空"),
TEN("-10", "定时时间不能小于系统当前时间"),
ELEVEN("-11", "屏蔽手机号码"),
ONEZEROONE("-101", "调用接口速度太快"),
;
/**
* code值
*/
private final String code;
/**
* 备注
*/
private final String remarks;
/**
* 构造器
*
* @param code code值
* @param remarks 备注
*/
private SmsReturnEnum(String code, String remarks) {
this.code = code;
this.remarks = remarks;
}
public static String getValueByKey(String code) {
SmsReturnEnum[] sysReturnEnum = values();
for (SmsReturnEnum returnEnum: sysReturnEnum) {
if (returnEnum.getCode().equals(code)) {
return returnEnum.getRemarks();
}
}
return null;
}
}
}

View File

@@ -25,8 +25,8 @@ import java.util.Map;
public interface SmsDao {
@Options(useGeneratedKeys = true, keyProperty = "id")
@Insert("insert into sys_sms(phone, signName, templateCode, params, day, createTime, updateTime) "
+ "values(#{phone}, #{signName}, #{templateCode}, #{params}, #{day}, #{createTime}, #{updateTime})")
@Insert("insert into sys_sms(phone, signName, templateCode, params, day, createTime, updateTime,bizId,code,message) "
+ "values(#{phone}, #{signName}, #{templateCode}, #{params}, #{day}, #{createTime}, #{updateTime},#{bizId},#{code},#{message})")
int save(Sms sms);
@Select("select * from sys_sms t where t.id = #{id}")