InBoxSDK.java
1.86 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
package com.yohoufo.inboxclient.sdk;
import com.yohoufo.inboxclient.common.UrlConstant;
import com.yohoufo.inboxclient.model.InBoxResponse;
import com.yohoufo.inboxclient.model.InboxReqVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
/**
* Created by shengguo.cai on 2018/9/19.
*/
@Service
public class InBoxSDK {
@Autowired
private RestTemplate restTemplate;
@Autowired
private UrlConstant urlConstant;
private final Logger log = LoggerFactory.getLogger(InBoxSDK.class);
/**
* @param reqVO
* reqVO中各个参数说明如下
* reqVO.type:详见枚举类 InboxBusinessTypeEnum
* reqVO.businessType:详见枚举类 InboxBusinessTypeEnum
* reqVO.params:用于替换模板消息的参数,多个参数用美式逗号分隔,例如:10000,abcd
*
* @return
*/
public InBoxResponse addInbox(InboxReqVO reqVO){
log.info("addInbox with param is {}", reqVO);
InBoxResponse result = restTemplate.getForObject(urlConstant.getInboxAddUrl()+"&uid={1}&type={2}&businessType={3}¶ms={4}",InBoxResponse.class,
reqVO.getUid(),reqVO.getType(),reqVO.getBusinessType(),reqVO.getParams());
log.info("addInbox call result is {}",result);
return result;
}
public InBoxResponse addBatchInbox(InboxReqVO reqVO){
log.info("addBatchInbox with param is {}", reqVO);
InBoxResponse result = restTemplate.getForObject(urlConstant.getInboxAddBatchUrl()+"&uids={1}&type={2}&businessType={3}¶ms={4}",InBoxResponse.class,
reqVO.getUids(),reqVO.getType(),reqVO.getBusinessType(),reqVO.getParams());
log.info("addBatchInbox call result is {}",result);
return result;
}
}