package com.gkhy.safePlatform.safeCheck.util; 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("${safecheckqiniuymes.accesskey}") private String accesskey; @Value("${safecheckqiniuymes.secretkey}") private String secretkey; @Value("${safecheckqiniuymes.templateid}") private String templateid; /** * 发送短信提示 */ @Async("SocketTaskExecutor") public Boolean sendMessageCheck(String[] phone, Map 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 { return false; } } catch (QiniuException e) { log.info("发生短信异常 =======================" ,e); } return false; } }