4
4
import cn .binarywang .wx .miniapp .api .WxMaSubscribeService ;
5
5
import cn .binarywang .wx .miniapp .bean .template .WxMaTemplateLibraryListResult ;
6
6
import cn .binarywang .wx .miniapp .util .json .WxMaGsonBuilder ;
7
+ import com .google .common .base .Joiner ;
7
8
import com .google .common .collect .ImmutableMap ;
8
9
import com .google .gson .JsonParser ;
9
10
import com .google .gson .reflect .TypeToken ;
10
11
import lombok .AllArgsConstructor ;
11
12
import me .chanjar .weixin .common .error .WxErrorException ;
12
13
import org .apache .commons .lang3 .StringUtils ;
13
14
15
+ import java .io .Serializable ;
14
16
import java .util .List ;
15
17
16
18
/**
@@ -22,15 +24,18 @@ public class WxMaSubscribeServiceImpl implements WxMaSubscribeService {
22
24
private WxMaService wxMaService ;
23
25
24
26
@ Override
25
- public WxMaTemplateLibraryListResult getPubTemplateTitleList (Integer [] ids , int start , int limit ) throws WxErrorException {
26
- return WxMaTemplateLibraryListResult .fromJson (this .wxMaService .post (GET_PUB_TEMPLATE_TITLE_LIST_URL ,
27
- ImmutableMap .of ("ids" , StringUtils .join (ids , "," ),
28
- "start" , start , "limit" , limit )));
27
+ public WxMaTemplateLibraryListResult getPubTemplateTitleList (String [] ids , int start , int limit ) throws WxErrorException {
28
+ ImmutableMap <String , ? extends Serializable > params = ImmutableMap .of ("ids" , StringUtils .join (ids , "," ),
29
+ "start" , start , "limit" , limit );
30
+ String responseText = this .wxMaService .get (GET_PUB_TEMPLATE_TITLE_LIST_URL ,
31
+ Joiner .on ("&" ).withKeyValueSeparator ("=" ).join (params ));
32
+ return WxMaTemplateLibraryListResult .fromJson (responseText );
29
33
}
30
34
31
35
@ Override
32
36
public List <PubTemplateKeyword > getPubTemplateKeyWordsById (String id ) throws WxErrorException {
33
- String responseText = this .wxMaService .post (GET_PUB_TEMPLATE_KEY_WORDS_BY_ID_URL , ImmutableMap .of ("tid" , id ));
37
+ String responseText = this .wxMaService .get (GET_PUB_TEMPLATE_KEY_WORDS_BY_ID_URL ,
38
+ Joiner .on ("&" ).withKeyValueSeparator ("=" ).join (ImmutableMap .of ("tid" , id )));
34
39
return WxMaGsonBuilder .create ().fromJson (new JsonParser ().parse (responseText ).getAsJsonObject ()
35
40
.getAsJsonArray ("data" ), new TypeToken <List <PubTemplateKeyword >>() {
36
41
}.getType ());
0 commit comments