发表于: 2021-04-07 23:40:37
1 847
今天完成的事情:
短信防护
邮箱发送进度
了解第三方图片存储如何做缩略图,防盗链等
明天计划的事情:
图片迁移
深度思考
遇到的问题:
java.lang.NumberFormatException: For input string: "?? t 5"
原因:存入redis数据乱码且不为空
删除缓存数据
RedisTemplate increment 错误:ERR value is not an integer or out of range
原因是:Value的序列化器配置错误。
解决办法:修改配置文件
<property name="keySerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
</property>
<property name="valueSerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
</property>
No matching constructor found in class 'RedisUtil'
原因:构造方法
添加一个构造方法
收获:
短信防护
在前端实现注册码等60秒
<script>
//验证码
var counts = 60;
function settime(val) {
if(counts == 0) {
val.removeAttribute("disabled");
val.value = "获取验证码";
counts = 60;
return false;
} else {
val.setAttribute("disabled", true);
val.value = "重新发送(" + counts + ")";
counts--;
}
setTimeout(function() {
settime(val);
}, 1000);
}
在后端实现一个验证码只能获取5次验证码
//判断今天剩余发送次数
if (redisUtil.get(phone) == null) {
int count=Integer.parseInt((String)redisUtil.get("count"+phone));
if(count>0) {
//发送********
sendSMS(phone,verify);
System.out.println("验证码是:" + verify);
redisUtil.set(phone, verify,300);
//可发送次数-1
redisUtil.decr("count" + phone, 1);
map.put("msg", "验证码发送成功,还可以发送" + redisUtil.get("count"+phone) + "次");
} else {
logger.info(phone+ "====今天的发送验证码次数已使用完");
map.put("msg", "今天的发送次数已经用完");
}
报文转成string
if (SendSmsResponse.toJsonString(sendSmsResponse) != null) {
logger.info("发送成功");
logger.info("短信接口返回的数据----------------");
logger.info("StatusSet=" +SendSmsResponse.toJsonString(sendSmsResponse));
logger.info("RequestId=" + sendSmsResponse.getRequestId());
2021-04-08 10:01:49 CST INFO com.kbk.util.TxSMSUtil102sendSMS - StatusSet={"SendStatusSet":[{"SerialNo":"2028:f825cd0a07273119xxxx","PhoneNumber":"+861323712xxxx","Fee":1,"SessionContext":"","Code":"Ok","Message":"send success","IsoCode":"CN"}],"RequestId":"9f13aa44-200d-4444-b49f-34a5f9xxxxx"}
评论