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

湖北网站建设服务价格定制网站和模板建站

湖北网站建设服务价格,定制网站和模板建站,门户网站如何做性能测试,wordpress 前端登录阿里云开通三网106短信 ①、在阿里云市场搜索“短信”,开通三网短信,并可以查看其中的请求示例(java PHP^) 并在个人中心的管理控制台中查到,获取其中的AppKey AppCode ②、接口开发 service-user模块中依赖spr…

阿里云开通三网106短信

①、在阿里云市场搜索“短信”,开通三网短信,并可以查看其中的请求示例(java PHP^)

并在个人中心的管理控制台中查到,获取其中的AppKey AppCode
在这里插入图片描述
在这里插入图片描述

②、接口开发
在这里插入图片描述

service-user模块中依赖spring-boot-stater-data-redis(配置文件中连接redis的信息)
cmmon-utils模块中依赖httpclient,httpcore,commons.lang,jetty-util

@RestController
@RequestMapping("api/user/sms")
public class SmsController{@Autowiredprivate SmsService smsService;@GetMapping(value="/sendCode/{phone}")public Result sendValidateCode(@PathVariable String phone){smsService.sendValidateCode(phone);return Reuslt.build(null,ResultCodeEnum.SUCCESS);}
}
@Service
public class SmsServiceImpl implements SmsService{@Autowiredprivate RedisTemplate<String,String> redisTemplate;@Overridepublic void sendCode(String phone){//生成验证码(通过common.lang工具生成4位验证码)String code = RandomStringUtils.randomNumeric(4);//将验证码放到redis,并设置过期时间redisTemplate.opsForValue().set(phone,code,5,TimeUnit.MINUTES);//向手机号发送短信验证码sendMessage(phone,code);}private void sendMessage(String phone,String code){String host = "https://dfsns.market.alicloudapi.com";String path = "/data/send_sms";String method = "POST";String appcode = "开通阿里云短信服务时的code";Map<String,String> headers = new HashMap<>();headers.put("Authorization","APPCODE" + appcode);headers.put("Content-Type","application/x-www-form-urlencoded";charset-UTF-8);Map<String,String> querys = new HashMap<>();Map<String,String> bodys = new HashMap<>();bodys.put("content","code:"+code);bodys.put("template_id","CST-ptdie100");bodys.put("phone_number",phone);try{//通过HttpUtils工具类进行短信的发送HttpResponse response = HttpUtils.doPost(host,path,method,headers,querys,body);System.out.println(response.toString())}catch(Exception e){e.printStackTrace()}}
}

HttpUtils工具类及其依赖,从github中aliyun下载

public class HttpUtils{public static HttpRespose doGet(String host,String path,String method,Map<String,String> headers,Map<String,String> querys) throws Exception{HttpClient httpClient = wrapClient(host);HttpGet request = new HttpGet(buildUrl(host,path,querys));for(Map.Entry<String,String> e:headers.entrySet){request.addHeader(e.getKey(),e.getValue());}return httpClient.execute(request);}public static HttpResponse doPost(String host,String path,String method,Map<String,String> headers,Map<String,String> querys,Map<String,String> bodys)throws Exception{HttpClient httpClient = wrapClient(host);HttpPost request = new HttpPost(buildUrl(host,path,querys));for(Map.Entry<String,String> e:headers.entrySet()){request.addHeader(e.getKey(),e.getValue());}}
}

====================================================================

①、依赖

<dependency><groupId>com.github.qcloudsms</groupId><artifactId>qcloudsms</artifactId><version>1.0.6</version>
</dependency>

②、

public interface SmsService {/*** 发送还款短信通知* @param mobile 还款人手机号* @param date 日期* @param amount 应还金额*/void sendRepaymentNotify(String mobile, String date, BigDecimal amount);
}
@Service
@Slf4j
public class QCloudSmsServiceImpl implements SmsService{@Value("${sms.qcloud.appId}")private int appId;@Value("${sms.qcloud.appKey}")private String appKey;@Value("{sms.qcloud.templateId}")private int templateId;@Value("{sms.qcloud.sign}")private String sign;@Overridepublic void sendRepaymentNotify(String mobile, String date, BigDecimal amount){log.info("给手机号{},发送还款提醒:{},金额:{}",mobile,date,amount);SmsSingleSender ssender = new SmsSingleSender(appId, appKey);//qcloudsms-1.0.6try{ssender.sendWithParam("86", mobile,templateId, new String[]{date, amount.toString()}, sign, "", "");}catch(Exception ex){log.error("发送失败:{}",ex .getMessage());}}
}

③、业务服务调用

@Override
public void sendRepaymentNotify(String date){//1.查询到期的还款计划List<RepaymentPlan> repaymentPlanList = selectDueRepayment(date);//2.遍历还款计划repaymentPlanList.forEach(repaymentPlan -> {//3.得到还款人的信息RestResponse<BorrowerDTO> consumerReponse = consumerApiAgent.getBorrowerMobile(repaymentPlan.getConsumerId());//4.得到还款人的手机号String mobile = consumerReponse.getResult().getMobile();//5.发送还款短信smsService.sendRepaymentNotify(mobile,date,repaymentPlan.getAmount());});
}
http://www.dtcms.com/wzjs/235697.html

相关文章:

  • 网站建设沧州seo零基础视频教程
  • 黑河做网站网站推广在线推广
  • 政务系统网站南京seo优化公司
  • 中国互联网协会成员网站seo专员
  • 互联网推广有哪些方式长尾词seo排名优化
  • 哪个汽车网站好seo优化服务公司
  • 免费网站建设 百度一下推广方式有哪些
  • 做网站是要收费的吗搜索引擎收录查询
  • html5 企业 网站坚持
  • 桂林北站有核酸检测点吗新业务在线软件下载
  • aspnet网站开发案例软文推广方案
  • 用php做的网站软件凡科建站教程
  • 潍坊哪个网站建设公司好电脑学校培训
  • seo信息是什么济南做seo排名
  • 深圳营销网站建设模板东莞网络营销平台
  • 门户网站安全建设方案百度快照推广排名
  • html5 网站 源码百度站长提交
  • 宜昌最新消息今天优化设计三要素
  • 怎么做网站大图片滚动seo关键词优化外包
  • 电商网站的流程图网站关键词优化排名推荐
  • wordpress elisionseo工资
  • 如何快速找到公司网站seo交流网
  • 境外电商平台排行榜山东服务好的seo公司
  • 如何自制自己的网站疫情防控最新政策
  • 浙江省建设信息港查seo哪个软件好
  • 镇江建设质量监督站网站手机百度2020最新版
  • 医疗器械做网站到哪里先备案平台代运营是什么意思
  • 苏州网站建设新手自己建网站要多少钱
  • 网站建设先做前台还是后台口碑营销什么意思
  • 怎么做网站的页眉百度网讯科技有限公司官网