Skip to content

Commit 8c514a7

Browse files
arbingbinarywang
authored andcommitted
🐛 #1327 修复小程序获取订阅消息公共模板标题和获取关键词库两个接口问题
1 parent 9c58930 commit 8c514a7

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaSubscribeService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public interface WxMaSubscribeService {
5757
* @return .
5858
* @throws WxErrorException .
5959
*/
60-
WxMaTemplateLibraryListResult getPubTemplateTitleList(Integer[] ids, int start, int limit) throws WxErrorException;
60+
WxMaTemplateLibraryListResult getPubTemplateTitleList(String[] ids, int start, int limit) throws WxErrorException;
6161

6262
/**
6363
* <pre>

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImpl.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
import cn.binarywang.wx.miniapp.api.WxMaSubscribeService;
55
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryListResult;
66
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
7+
import com.google.common.base.Joiner;
78
import com.google.common.collect.ImmutableMap;
89
import com.google.gson.JsonParser;
910
import com.google.gson.reflect.TypeToken;
1011
import lombok.AllArgsConstructor;
1112
import me.chanjar.weixin.common.error.WxErrorException;
1213
import org.apache.commons.lang3.StringUtils;
1314

15+
import java.io.Serializable;
1416
import java.util.List;
1517

1618
/**
@@ -22,15 +24,18 @@ public class WxMaSubscribeServiceImpl implements WxMaSubscribeService {
2224
private WxMaService wxMaService;
2325

2426
@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);
2933
}
3034

3135
@Override
3236
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)));
3439
return WxMaGsonBuilder.create().fromJson(new JsonParser().parse(responseText).getAsJsonObject()
3540
.getAsJsonArray("data"), new TypeToken<List<PubTemplateKeyword>>() {
3641
}.getType());

weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaSubscribeServiceImplTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ public class WxMaSubscribeServiceImplTest {
2727

2828
@Test
2929
public void testGetPubTemplateTitleList() throws WxErrorException {
30-
this.wxService.getSubscribeService().getPubTemplateTitleList(new Integer[]{578}, 1, 1);
30+
this.wxService.getSubscribeService().getPubTemplateTitleList(new String[]{"2", "616"}, 0, 1);
3131
}
3232

3333
@Test
3434
public void testGetPubTemplateKeyWordsById() throws WxErrorException {
35-
final List<WxMaSubscribeService.PubTemplateKeyword> result = this.wxService.getSubscribeService().getPubTemplateKeyWordsById("578");
35+
final List<WxMaSubscribeService.PubTemplateKeyword> result = this.wxService.getSubscribeService().getPubTemplateKeyWordsById("99");
3636
System.out.println(result);
3737
}
3838

3939
@Test
4040
public void testAddTemplate() throws WxErrorException {
41-
final String templateId = this.wxService.getSubscribeService().addTemplate("1", Lists.newArrayList(1), "hhaa");
41+
final String templateId = this.wxService.getSubscribeService().addTemplate("401", Lists.newArrayList(1, 2), "测试数据");
4242
System.out.println(templateId);
4343
}
4444

0 commit comments

Comments
 (0)