package com.gkhy.huataiFourierSpecialGasMonitor.utils;
|
|
import com.qiniu.common.QiniuException;
|
import com.qiniu.http.Response;
|
import com.qiniu.sms.SmsManager;
|
import com.qiniu.util.Auth;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Map;
|
|
@Component
|
public class SendMessageUtil {
|
|
private static final Logger log = LoggerFactory.getLogger(SendMessageUtil.class);
|
|
@Value("${qiniuymes.accesskey}")
|
private String accesskey;
|
|
@Value("${qiniuymes.secretkey}")
|
private String secretkey;
|
|
@Value("${qiniuymes.templateid}")
|
private String templateid;
|
|
/**
|
* 发送短信提示
|
*/
|
@Async("SocketTaskExecutor")
|
public Boolean sendMessageCheck(String[] phone, Map<String, String> map){
|
Auth auth = Auth.create(accesskey, secretkey);
|
SmsManager smsManager = new SmsManager(auth);
|
try {
|
Response resp = smsManager.sendMessage(templateid, phone , map);
|
if(resp.statusCode == 200){
|
return true;
|
}else {
|
log.info("短信发送状态码非200:【"+resp.statusCode+"】");
|
return false;
|
}
|
} catch (QiniuException e) {
|
log.info("发生短信异常 =======================" ,e);
|
}
|
return false;
|
}
|
}
|