Skip to content

Commit 1d50aca

Browse files
arbingbinarywang
authored andcommitted
🐛 #1331 修复小程序获取订阅消息公共模板标题Result不匹配的问题
1 parent 45f3e54 commit 1d50aca

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cn.binarywang.wx.miniapp.api;
22

3-
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryListResult;
3+
import cn.binarywang.wx.miniapp.bean.template.WxMaPubTemplateTitleListResult;
44
import lombok.Data;
55
import me.chanjar.weixin.common.error.WxErrorException;
66

@@ -57,7 +57,7 @@ public interface WxMaSubscribeService {
5757
* @return .
5858
* @throws WxErrorException .
5959
*/
60-
WxMaTemplateLibraryListResult getPubTemplateTitleList(String[] ids, int start, int limit) throws WxErrorException;
60+
WxMaPubTemplateTitleListResult 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import cn.binarywang.wx.miniapp.api.WxMaService;
44
import cn.binarywang.wx.miniapp.api.WxMaSubscribeService;
5-
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryListResult;
5+
import cn.binarywang.wx.miniapp.bean.template.WxMaPubTemplateTitleListResult;
66
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
77
import com.google.common.base.Joiner;
88
import com.google.common.collect.ImmutableMap;
@@ -24,12 +24,12 @@ public class WxMaSubscribeServiceImpl implements WxMaSubscribeService {
2424
private WxMaService wxMaService;
2525

2626
@Override
27-
public WxMaTemplateLibraryListResult getPubTemplateTitleList(String[] ids, int start, int limit) throws WxErrorException {
27+
public WxMaPubTemplateTitleListResult getPubTemplateTitleList(String[] ids, int start, int limit) throws WxErrorException {
2828
ImmutableMap<String, ? extends Serializable> params = ImmutableMap.of("ids", StringUtils.join(ids, ","),
2929
"start", start, "limit", limit);
3030
String responseText = this.wxMaService.get(GET_PUB_TEMPLATE_TITLE_LIST_URL,
3131
Joiner.on("&").withKeyValueSeparator("=").join(params));
32-
return WxMaTemplateLibraryListResult.fromJson(responseText);
32+
return WxMaPubTemplateTitleListResult.fromJson(responseText);
3333
}
3434

3535
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package cn.binarywang.wx.miniapp.bean.template;
2+
3+
import lombok.Data;
4+
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
5+
6+
import java.io.Serializable;
7+
import java.util.List;
8+
9+
@Data
10+
public class WxMaPubTemplateTitleListResult implements Serializable {
11+
private static final long serialVersionUID = -7718911668757837527L;
12+
13+
private int count;
14+
15+
private List<TemplateItem> data;
16+
17+
public static WxMaPubTemplateTitleListResult fromJson(String json) {
18+
return WxGsonBuilder.create().fromJson(json, WxMaPubTemplateTitleListResult.class);
19+
}
20+
21+
@Data
22+
public static class TemplateItem {
23+
24+
private Integer type;
25+
26+
private Integer tid;
27+
28+
private String categoryId;
29+
30+
private String title;
31+
}
32+
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import cn.binarywang.wx.miniapp.api.WxMaService;
44
import cn.binarywang.wx.miniapp.api.WxMaSubscribeService;
5+
import cn.binarywang.wx.miniapp.bean.template.WxMaPubTemplateTitleListResult;
56
import cn.binarywang.wx.miniapp.test.ApiTestModule;
67
import com.google.common.collect.Lists;
78
import com.google.inject.Inject;
@@ -27,7 +28,9 @@ public class WxMaSubscribeServiceImplTest {
2728

2829
@Test
2930
public void testGetPubTemplateTitleList() throws WxErrorException {
30-
this.wxService.getSubscribeService().getPubTemplateTitleList(new String[]{"2", "616"}, 0, 1);
31+
WxMaPubTemplateTitleListResult result = this.wxService.getSubscribeService().getPubTemplateTitleList(new String[]{"2", "616"}, 0, 30);
32+
System.out.println(result);
33+
3134
}
3235

3336
@Test

0 commit comments

Comments
 (0)