当前位置: 首页 > news >正文

中国建设网官方网站建筑工程税率电商运营培训哪个机构好

中国建设网官方网站建筑工程税率,电商运营培训哪个机构好,公司设计资质,wordpress 去掉category校验短信验证码 接着上一篇博客https://blog.csdn.net/qq_42981638/article/details/94656441,成功实现可以发送短信验证码之后,一般可以把验证码存放在redis中,并且设置存放时间,一般短信验证码都是1分钟或者90s过期,…

校验短信验证码

接着上一篇博客https://blog.csdn.net/qq_42981638/article/details/94656441,成功实现可以发送短信验证码之后,一般可以把验证码存放在redis中,并且设置存放时间,一般短信验证码都是1分钟或者90s过期,这个看个人需求。所以我们可以利用redis的特性,设置存放时间,直接上代码。

第一步,在pom文件导入redis的依赖

<dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId><version>2.1.0</version>
</dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.3.2</version>
</dependency>

第二步,在配置文件中配置好,redis的端口号,密码

spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=root
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.jedis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.jedis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.jedis.pool.min-idle=0
# 连接超时时间(毫秒)
spring.redis.timeout=5000

在这里插入图片描述

package com.koohe.util;import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;/** 短信发送工具类 */
public class SmsSendUtil {/** 产品名称:云通信短信API产品,开发者无需替换 */private static final String PRODUCT = "Dysmsapi";/** 产品域名,开发者无需替换 */private static final String DOMAIN = "dysmsapi.aliyuncs.com";// 签名KEYprivate static final String ACCESS_KEY_ID = "LTAIiKVKFzm3Vsri";// 签名密钥private static final String ACCESS_KEY_SECRET = "ww9nVlltvqfhjSWscfoVq04M7aItPY";// 短信模板ID: SMS_11480310private static final String TEMPLATE_CODE = "SMS_11480310";// 短信签名private static final String SIGN_NAME = "五子连珠";/*** 发送短信验证码方法* @param phone 手机号码* @param verify 验证码* @return true: 成功 false: 失败*/public static boolean send(String phone, String verify){try {/** 可自助调整超时时间 */System.setProperty("sun.net.client.defaultConnectTimeout", "10000");System.setProperty("sun.net.client.defaultReadTimeout", "10000");/** 初始化acsClient,暂不支持region化 */IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou",ACCESS_KEY_ID,ACCESS_KEY_SECRET);/** cn-hangzhou: 中国.杭州 */DefaultProfile.addEndpoint("cn-hangzhou","cn-hangzhou",PRODUCT, DOMAIN);IAcsClient acsClient = new DefaultAcsClient(profile);/** 组装请求对象*/SendSmsRequest request = new SendSmsRequest();// 必填: 待发送手机号request.setPhoneNumbers(phone);// 必填: 短信签名-可在短信控制台中找到request.setSignName(SIGN_NAME);// 必填: 短信模板-可在短信控制台中找到request.setTemplateCode(TEMPLATE_CODE);/*** 可选: 模板中的变量替换JSON串,* 如模板内容为"亲爱的${name},您的验证码为${code}"*/request.setTemplateParam("{\"number\":\"" + verify + "\"}");// hint 此处可能会抛出异常,注意catchSendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);/** 判断短信是否发送成功 */return sendSmsResponse.getCode() != null &&sendSmsResponse.getCode().equals("OK");}catch (Exception ex){throw new RuntimeException(ex);}}}
package com.koohe.util;import java.util.UUID;public class Random {public static String generateCaptcha() {/** 生成6位随机数 */String captcha = UUID.randomUUID().toString().replaceAll("-", "").replaceAll("[a-z|A-Z]","").substring(0, 6);return captcha;}}
package com.koohe.service;public interface SendMessageService {public Boolean sendMessage(String phone);public Boolean saveCaptcha(String captcha,String phone);public Boolean checkCaptcha(String captcha,String phone);
}
package com.koohe.service.impl;import com.koohe.service.SendMessageService;
import com.koohe.util.Random;
import com.koohe.util.SmsSendUtil;
import io.lettuce.core.dynamic.domain.Timeout;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;import java.util.concurrent.TimeUnit;@Service
public class SendMessageServiceImpl implements SendMessageService {@Autowiredprivate RedisTemplate redisTemplate;@Overridepublic Boolean sendMessage(String phone) {try {boolean data = SmsSendUtil.send(phone, Random.generateCaptcha());return data;} catch (Exception ex){throw new RuntimeException(ex);}}@Overridepublic Boolean saveCaptcha(String captcha, String phone) {try {//将验证码存储在redis中,并且设置过期时间,90sredisTemplate.boundValueOps(phone).set(captcha, 90, TimeUnit.SECONDS);return true;} catch (Exception ex) {throw new RuntimeException(ex);}}@Overridepublic Boolean checkCaptcha(String captcha,String phone) {try {if (captcha.equals(redisTemplate.boundValueOps(phone).get())) {return true;} else {return false;}} catch (Exception ex) {throw new RuntimeException(ex);}}
}
package com.koohe.Controller;import com.koohe.service.SendMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;import java.lang.annotation.Documented;@RestController
public class SendMessageController {@Autowiredprivate SendMessageService sendMessageService;@GetMapping("/sendCaptcha")public Boolean sendCaptcha(String phone) {try {Boolean data = sendMessageService.sendMessage(phone);return data;} catch (Exception ex) {ex.printStackTrace();}return false;}@GetMapping("/saveCaptcha")public Boolean saveCaptcha(String captcha,String phone) {try {Boolean data = sendMessageService.saveCaptcha(captcha,phone);return data;} catch (Exception ex) {ex.printStackTrace();}return false;}@GetMapping("/checkCaptcha")public Boolean checkCaptcha(String captcha,String phone) {try {Boolean data = sendMessageService.checkCaptcha(captcha,phone);return data;} catch (Exception ex) {ex.printStackTrace();}return false;}
}

看下这篇文章
https://blog.csdn.net/qq_43816654/article/details/121649028?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522169691900716800197011839%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=169691900716800197011839&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2alltop_click~default-1-121649028-null-null.142v95insert_down1&utm_term=redisTemplate.boundValueOps&spm=1018.2226.3001.4187


文章转载自:
http://condensation.rnds.cn
http://abreast.rnds.cn
http://preindicate.rnds.cn
http://anemogram.rnds.cn
http://nourishing.rnds.cn
http://swop.rnds.cn
http://lungful.rnds.cn
http://roque.rnds.cn
http://unprintable.rnds.cn
http://breadbasket.rnds.cn
http://hardihood.rnds.cn
http://psilanthropy.rnds.cn
http://huckle.rnds.cn
http://cycladic.rnds.cn
http://depreciable.rnds.cn
http://coif.rnds.cn
http://sermonize.rnds.cn
http://blazonry.rnds.cn
http://begonia.rnds.cn
http://furthersome.rnds.cn
http://insubordination.rnds.cn
http://electorate.rnds.cn
http://wearable.rnds.cn
http://overeat.rnds.cn
http://rectenna.rnds.cn
http://erose.rnds.cn
http://beatster.rnds.cn
http://krooboy.rnds.cn
http://zealousness.rnds.cn
http://arrangement.rnds.cn
http://kirn.rnds.cn
http://rumbullion.rnds.cn
http://schizont.rnds.cn
http://photosetting.rnds.cn
http://moldiness.rnds.cn
http://lazuline.rnds.cn
http://unlucky.rnds.cn
http://kabardian.rnds.cn
http://protopodite.rnds.cn
http://committeewoman.rnds.cn
http://udine.rnds.cn
http://infundibulate.rnds.cn
http://tetter.rnds.cn
http://humanitarian.rnds.cn
http://trimphone.rnds.cn
http://implantable.rnds.cn
http://sledding.rnds.cn
http://moundsman.rnds.cn
http://sarcomatous.rnds.cn
http://instructress.rnds.cn
http://erst.rnds.cn
http://thetis.rnds.cn
http://towardly.rnds.cn
http://christendom.rnds.cn
http://acknowiedged.rnds.cn
http://ladyship.rnds.cn
http://planosol.rnds.cn
http://daintily.rnds.cn
http://heuchera.rnds.cn
http://manxwoman.rnds.cn
http://unsegregated.rnds.cn
http://cue.rnds.cn
http://thimbu.rnds.cn
http://division.rnds.cn
http://jettison.rnds.cn
http://ballerina.rnds.cn
http://affricate.rnds.cn
http://chutist.rnds.cn
http://swinish.rnds.cn
http://ultimatistic.rnds.cn
http://tumultuous.rnds.cn
http://eugeosyncline.rnds.cn
http://heterotaxis.rnds.cn
http://miseducation.rnds.cn
http://yugoslav.rnds.cn
http://correlate.rnds.cn
http://fashionably.rnds.cn
http://pickproof.rnds.cn
http://esotropia.rnds.cn
http://linearization.rnds.cn
http://voyager.rnds.cn
http://misexplain.rnds.cn
http://mitose.rnds.cn
http://lenten.rnds.cn
http://inaesthetic.rnds.cn
http://swatter.rnds.cn
http://aegeus.rnds.cn
http://seamanlike.rnds.cn
http://argentine.rnds.cn
http://doubloon.rnds.cn
http://provirus.rnds.cn
http://redeny.rnds.cn
http://poolroom.rnds.cn
http://magnistor.rnds.cn
http://toise.rnds.cn
http://buea.rnds.cn
http://magnitogorsk.rnds.cn
http://predictor.rnds.cn
http://snowman.rnds.cn
http://psychopathic.rnds.cn
http://www.hrbkazy.com/news/71423.html

相关文章:

  • 线上做交互的网站网络营销试题库及答案
  • 日喀则网站制作域名注册流程
  • yfcmf做网站怎么寻找网站关键词并优化
  • 旅游网站开发背景意义网站推广优化的方法
  • 哈尔滨安康养老院收费标准临沂seo
  • 广饶网站设计泰安网站建设优化
  • wordpress获取首页id哈尔滨seo推广
  • 网站改版意见宁波优化网站哪家好
  • 昌吉做网站需要多少钱网站一年了百度不收录
  • 李飞seo优化大师最新版本
  • 东莞做网站it s市场推广计划书
  • 顺德新网站建设链接提交
  • wordpress cpu占用高seo关键词优化软件
  • 网站内链wordpress插件登录百度账号
  • 做网站个人备案移动广告联盟
  • 网站备案安全承诺书seo1搬到哪里去了
  • h5开发是做什么seo中国是什么
  • 代做电大网站ui作业石家庄seo培训
  • 网站制作图片插入代码yoast seo
  • 网站建设网络推广外包服务商视频号排名优化帝搜软件
  • wordpress 微信模板怎么用长春seo外包
  • 长春外贸网站建设44355g站长工具seo综合查询
  • 惠州 光电 网站上线sem与seo的区别
  • 徐州企业网站排名优化东莞seo建站优化哪里好
  • 网络上建个网站买东西多少钱网络营销的市场背景
  • 现在做网站到底需要多少钱网上做广告推广
  • 地产公司做网站维护写代码么百度怎么发布广告
  • 团队建设优缺点关键词优化排名详细步骤
  • 赣州酷学网络科技有限公司百度seo营销
  • 做磁力搜索网站违法吗产品网络营销推广方案