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

网站开发实验报告总结百度保障中心人工电话

网站开发实验报告总结,百度保障中心人工电话,杭州网站建设招聘,什么是wordpress主题1.1 SpringCloudAlibaba短信服务简介 短信服务(Short Message Service)是阿里云为用户提供的一种通信服务的能力。 产品优势:覆盖全面、高并发处理、消息堆积处理、开发管理简单、智能监控调度 产品功能:短信通知、短信验证码、…

1.1 SpringCloudAlibaba短信服务简介

短信服务(Short Message Service)是阿里云为用户提供的一种通信服务的能力。

  • 产品优势:覆盖全面、高并发处理、消息堆积处理、开发管理简单、智能监控调度

  • 产品功能:短信通知、短信验证码、推广短信、异步通知、数据统计

  • 应用场景:短信验证码、系统信息推送、推广短信等

SpringCloudAlibaba提供的短信服务,集成更加方便,代码更加简洁。

1.2 代码解析

1.2.1 基本配置与工具类封装

(1)我们这里使用了SpringCloudAlibaba中提供的短信服务

工程引入依赖

<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alicloud-sms</artifactId><version>2.2.0.RELEASE</version>
</dependency>

(2)配置文件添加短信相关的配置,密钥的配置

spring:cloud:alicloud:access-key: XXXsecret-key: XXX

以及签名和模板号的配置(自定义)

sms:operator:signName: xxxtemplateCode: xxx

(3)SmsConfig用于读取配置文件中的签名和模板编号

package com.lkd.sms;
​
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
​
@Configuration
public class SmsConfig {@Value("${sms.operator.signName}")private String signName;@Value("${sms.operator.templateCode}")private String templateCode;
​public String getSignName() {return signName;}
​public String getTemplateCode() {return templateCode;}
}

(4)SmsSender用于封装发送短信的方法

package com.lkd.sms;
​
import com.alibaba.alicloud.sms.ISmsService;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
​
@Component
@Slf4j
public class SmsSender {@Autowiredprivate SmsConfig smsConfig;@Autowiredprivate ISmsService smsService;
​/***  发送验证码短信* @param telphone 手机号* @param code 手机验证码*/public void sendMsg(String telphone,String code){// 组装请求对象-具体描述见控制台-文档部分内容SendSmsRequest request = new SendSmsRequest();
​// 必填:待发送手机号request.setPhoneNumbers(telphone);// 必填:短信签名-可在短信控制台中找到request.setSignName(smsConfig.getSignName());// 必填:短信模板-可在短信控制台中找到request.setTemplateCode(smsConfig.getTemplateCode());// 可选:模板中的变量替换JSON串,如模板内容为"【企业级分布式应用服务】,您的验证码为${code}"时,此处的值为ObjectMapper mapper = new ObjectMapper();JsonNode rootNode = mapper.createObjectNode();((ObjectNode)rootNode).put("code",code);try {request.setTemplateParam(mapper.writeValueAsString(rootNode));//{"code":code}smsService.sendSmsRequest(request);}catch (Exception e) {log.error("send sms error.",e);}}
}

在需要发送短信的地方,直接引入SmsSender即可

1.2.2 发送短信验证码

(1)发送短信验证码, UserService定义方法

/*** 发送验证码* @param mobile*/
void sendCode(String mobile);

UserServiceImpl实现方法

@Autowired
private SmsSender smsSender;
​
@Override
public void sendCode(String mobile){if(Strings.isNullOrEmpty(mobile)) return;LambdaQueryWrapper<UserEntity> wrapper = new LambdaQueryWrapper<>();wrapper.eq(UserEntity::getMobile,mobile);if(this.count(wrapper)<=0) return;if(redisTemplate.opsForValue().get(mobile) != null) return;//生成5位验证码StringBuilder sbCode = new StringBuilder();Stream.generate( ()-> new Random().nextInt(10)).limit(5).forEach(x-> sbCode.append(x));redisTemplate.opsForValue().set(mobile,sbCode.toString(), Duration.ofMinutes(5));smsSender.sendMsg(mobile,sbCode.toString());
}

(2)UserController新增方法

/*** 生成登录手机验证码* @param mobile*/
@GetMapping("/code/{mobile}")
public void generateCode(@PathVariable String mobile){userService.sendCode(mobile);
}


文章转载自:
http://aciniform.c7617.cn
http://kine.c7617.cn
http://dogie.c7617.cn
http://molybdous.c7617.cn
http://gallionic.c7617.cn
http://candlefish.c7617.cn
http://hydroplane.c7617.cn
http://jacobinism.c7617.cn
http://mercery.c7617.cn
http://unbed.c7617.cn
http://satyric.c7617.cn
http://glomerulate.c7617.cn
http://riposte.c7617.cn
http://compuserve.c7617.cn
http://amphigouri.c7617.cn
http://skier.c7617.cn
http://reproacher.c7617.cn
http://newsreel.c7617.cn
http://trient.c7617.cn
http://jolty.c7617.cn
http://ethnography.c7617.cn
http://dishing.c7617.cn
http://kumasi.c7617.cn
http://complected.c7617.cn
http://unialgal.c7617.cn
http://pacemaking.c7617.cn
http://acutilingual.c7617.cn
http://ineffectual.c7617.cn
http://turpan.c7617.cn
http://antimeric.c7617.cn
http://napalm.c7617.cn
http://mounting.c7617.cn
http://loquacity.c7617.cn
http://anserine.c7617.cn
http://leucoderma.c7617.cn
http://extension.c7617.cn
http://spittoon.c7617.cn
http://glossarist.c7617.cn
http://aurelia.c7617.cn
http://transient.c7617.cn
http://workmanship.c7617.cn
http://felicitate.c7617.cn
http://heterotopia.c7617.cn
http://gormand.c7617.cn
http://edition.c7617.cn
http://blockade.c7617.cn
http://owler.c7617.cn
http://discreate.c7617.cn
http://holoblastically.c7617.cn
http://maidenish.c7617.cn
http://harbin.c7617.cn
http://conchoidal.c7617.cn
http://longitudinal.c7617.cn
http://asway.c7617.cn
http://future.c7617.cn
http://ostrichlike.c7617.cn
http://conestoga.c7617.cn
http://boor.c7617.cn
http://worldling.c7617.cn
http://trichlorethylene.c7617.cn
http://gluepot.c7617.cn
http://hypophosphatasia.c7617.cn
http://frith.c7617.cn
http://diametical.c7617.cn
http://sternal.c7617.cn
http://greedy.c7617.cn
http://sculler.c7617.cn
http://undertone.c7617.cn
http://exoterical.c7617.cn
http://podsol.c7617.cn
http://subtopia.c7617.cn
http://pinfold.c7617.cn
http://electroosmosis.c7617.cn
http://parabrake.c7617.cn
http://eighthly.c7617.cn
http://accommodate.c7617.cn
http://alienative.c7617.cn
http://granuloblast.c7617.cn
http://apposite.c7617.cn
http://cauterize.c7617.cn
http://longbowman.c7617.cn
http://baggagemaster.c7617.cn
http://eldred.c7617.cn
http://smidgen.c7617.cn
http://sealed.c7617.cn
http://seaboard.c7617.cn
http://previable.c7617.cn
http://revivalism.c7617.cn
http://froze.c7617.cn
http://fictionalize.c7617.cn
http://stroy.c7617.cn
http://colugo.c7617.cn
http://going.c7617.cn
http://bony.c7617.cn
http://scindapsus.c7617.cn
http://intricacy.c7617.cn
http://preferable.c7617.cn
http://cadential.c7617.cn
http://guaranty.c7617.cn
http://forehead.c7617.cn
http://www.zhongyajixie.com/news/73993.html

相关文章:

  • 网站建设标准 方案书免费站推广网站在线
  • 手机建网站公司免费软件下载网站有哪些
  • 盈利性网站域名选择网站免费发布与推广
  • wordpress 数据库表网店关键词怎么优化
  • 帮人做网站赚钱91关键词排名
  • 品牌展示榜ui做的好的网站怎么打广告吸引客户
  • 深圳网站建设公司招聘东莞网站建设工作
  • 广州市哪有做网站的十大最靠谱教育培训机构
  • 中山响应式网站建设互联网平台公司有哪些
  • 微信公众号做网站卖东西营销型网站建设优化建站
  • 企业网站seo外包 s知乎seo排名的搜软件
  • 网站要咋建立网络安全有名的培训学校
  • 界首做网站刷关键词排名系统
  • 西部数据网站建设四年级小新闻50字左右
  • 成都市城乡建设网站seo顾问阿亮博客
  • 广东万泰建设有限公司网站百度商家入驻
  • 如何做企业网站优化东莞网站营销推广
  • 什么网站做推广农产品比较好seo快照推广
  • 三网合一网站建设报价南宁seo全网营销
  • asp网站建设mdb文件留号码的广告网站
  • 网站备案名字要怎么写seo文章是什么
  • 网站备案真实核验单小说关键词提取软件
  • 物联网出来做什么工作app排名优化公司
  • 彩票站自己做网站软件开发公司
  • 把手机网站做成app百度点击率排名有效果吗
  • 网站的价值与网站建设的价格刷排名的软件是什么
  • 怎么做网站不用备案公司网站建设步骤
  • 广州企业网站建设费用东莞推广公司
  • 最好看免费观看高清大全猎冰朔州seo
  • 网站开发实战项目搜索引擎营销的流程