parent
6f791f4f97
commit
165dd405c1
@ -0,0 +1,38 @@
|
|||||||
|
package com.luoo.user.listener;
|
||||||
|
|
||||||
|
import com.aliyuncs.exceptions.ClientException;
|
||||||
|
import com.luoo.user.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,"{\"code\":\""+checkcode+"\"}");
|
||||||
|
} catch (ClientException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue