parent
5b11711965
commit
6c74c305c4
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>luoo_parent</artifactId>
|
||||
<groupId>com.luoo</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>luoo_sms</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>3.2.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -0,0 +1,11 @@
|
||||
package com.luoo.sms;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SmsApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SmsApplication.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.luoo.sms.listener;
|
||||
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.luoo.sms.util.SmsUtils;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@RabbitListener(queues = "sms")
|
||||
public class SmsListener {
|
||||
|
||||
@Autowired
|
||||
private SmsUtils smsUtils;
|
||||
|
||||
@Value("${aliyun.sms.template_code}")
|
||||
private String template_code;
|
||||
|
||||
@Value("${aliyun.sms.sign_name}")
|
||||
private String sign_name;
|
||||
|
||||
@RabbitHandler
|
||||
public void executeSms(Map<String,String> map) {
|
||||
String mobile = map.get("mobile");
|
||||
String checkcode= map.get("checkcode");
|
||||
System.out.println("手机号:"+map.get("mobile"));
|
||||
System.out.println("验证码:"+map.get("checkcode"));
|
||||
// try {
|
||||
// smsUtils.sendSms(mobile,template_code,sign_name,"{\"checkcode\":\""+checkcode+"\"}");
|
||||
// } catch (ClientException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
server:
|
||||
port: 9009
|
||||
spring:
|
||||
application:
|
||||
name: luoo-sms
|
||||
rabbitmq:
|
||||
host: 116.62.145.60
|
||||
aliyun:
|
||||
sms:
|
||||
accessKeyId: xxx
|
||||
accessKeySecret: xxx
|
||||
template_code: xxx
|
||||
sign_name: xxx
|
Loading…
Reference in new issue