InBoxSendSmsService.java
1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.yohoufo.inboxclient.sdk;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.service.model.msgcenter.sms.McSmsByMobileBO;
import com.yoho.service.model.sms.response.CommonRspBO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by chenchao on 2018/10/19.
*/
@Service
public class InBoxSendSmsService {
private static Logger log = LoggerFactory.getLogger(InBoxSendSmsService.class);
@Autowired
private ServiceCaller serviceCaller;
@Value("${yoho.message.controller.url}")
private String messageUrl;
public void smsSendByMobile(String content, List<String> mobileList) {
log.info("InBoxSendSmsService smsSendByMobile start, content {}, mobileList {}", content, mobileList);
if(StringUtils.isEmpty(content) || CollectionUtils.isEmpty(mobileList)) {
log.warn("InBoxSendSmsService smsSendByMobile fail! content is null or mobileList is empty");
return;
}
McSmsByMobileBO[] boArray = new McSmsByMobileBO[mobileList.size()];
for(int i=0; i<mobileList.size(); i++) {
McSmsByMobileBO smsBo = new McSmsByMobileBO();
smsBo.setMobile(mobileList.get(i));
smsBo.setContent(content);
//"smsProviderCode" : "3"
smsBo.setSmsProviderCode("3");
smsBo.setIsNoDisturb(0);//是否免打扰, 1-是 0-否
boArray[i] = smsBo;
}
String url = messageUrl + "/mcSMS/smsSendByMobile";
log.info("InBoxSendSmsService sendMessage url is {}", url);
serviceCaller.post("message.sendMessage", url, boArray, CommonRspBO.class, null);
}
}