浏览代码

:bug: 修复图文消息留言管理接口中msgDataId类型与群发消息接口的消息id类型不一致问题

Binary Wang 5 年之前
父节点
当前提交
71ba078768

+ 4 - 4
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCommentService.java

@@ -5,7 +5,7 @@ import me.chanjar.weixin.mp.bean.comment.WxMpCommentListVo;
 
 /**
  * 图文消息留言管理接口.
- * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1494572718_WzHIY
+ * https://developers.weixin.qq.com/doc/offiaccount/Comments_management/Image_Comments_Management_Interface.html
  *
  * @author <a href="https://github.com/binarywang">Binary Wang</a>
  * @date 2019-06-16
@@ -19,7 +19,7 @@ public interface WxMpCommentService {
    * @param index     多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文
    * @throws WxErrorException 异常
    */
-  void open(Integer msgDataId, Integer index) throws WxErrorException;
+  void open(String msgDataId, Integer index) throws WxErrorException;
 
   /**
    * 关闭已群发文章评论.
@@ -29,7 +29,7 @@ public interface WxMpCommentService {
    * @param index     多图文时,用来指定第几篇图文,从0开始,不带默认操作该msg_data_id的第一篇图文
    * @throws WxErrorException 异常
    */
-  void close(Integer msgDataId, Integer index) throws WxErrorException;
+  void close(String msgDataId, Integer index) throws WxErrorException;
 
   /**
    * 查看指定文章的评论数据.
@@ -43,5 +43,5 @@ public interface WxMpCommentService {
    * @return 评论列表数据
    * @throws WxErrorException 异常
    */
-  WxMpCommentListVo list(Integer msgDataId, Integer index, int begin, int count, int type) throws WxErrorException;
+  WxMpCommentListVo list(String msgDataId, Integer index, int begin, int count, int type) throws WxErrorException;
 }

+ 3 - 3
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCommentServiceImpl.java

@@ -18,7 +18,7 @@ public class WxMpCommentServiceImpl implements WxMpCommentService {
   private final WxMpService wxMpService;
 
   @Override
-  public void open(Integer msgDataId, Integer index) throws WxErrorException {
+  public void open(String msgDataId, Integer index) throws WxErrorException {
     JsonObject json = new JsonObject();
     json.addProperty("msg_data_id", msgDataId);
     if (index != null) {
@@ -29,7 +29,7 @@ public class WxMpCommentServiceImpl implements WxMpCommentService {
   }
 
   @Override
-  public void close(Integer msgDataId, Integer index) throws WxErrorException {
+  public void close(String msgDataId, Integer index) throws WxErrorException {
     JsonObject json = new JsonObject();
     json.addProperty("msg_data_id", msgDataId);
     if (index != null) {
@@ -40,7 +40,7 @@ public class WxMpCommentServiceImpl implements WxMpCommentService {
   }
 
   @Override
-  public WxMpCommentListVo list(Integer msgDataId, Integer index, int begin, int count, int type) throws WxErrorException {
+  public WxMpCommentListVo list(String msgDataId, Integer index, int begin, int count, int type) throws WxErrorException {
     JsonObject json = new JsonObject();
     json.addProperty("msg_data_id", msgDataId);
     json.addProperty("begin", begin);

+ 5 - 5
weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpCommentServiceImplTest.java

@@ -31,14 +31,14 @@ public class WxMpCommentServiceImplTest {
 
   @Test
   public void testOpen() throws WxErrorException {
-    this.wxService.getCommentService().open(1, null);
-    this.wxService.getCommentService().open(1, 0);
+    this.wxService.getCommentService().open("1", null);
+    this.wxService.getCommentService().open("1", 0);
   }
 
   @Test
   public void testClose() throws WxErrorException {
-    this.wxService.getCommentService().close(1000000001, null);
-    this.wxService.getCommentService().close(1, 0);
+    this.wxService.getCommentService().close("1000000001", null);
+    this.wxService.getCommentService().close("1", 0);
   }
 
   @Test
@@ -66,7 +66,7 @@ public class WxMpCommentServiceImplTest {
     WxMpCommentService commentService = new WxMpCommentServiceImpl(wxService);
     doReturn(expectedResponse).when(wxService).post(anyString(), anyString());
 
-    final WxMpCommentListVo commentListVo = commentService.list(1, 1, 1, 1, 1);
+    final WxMpCommentListVo commentListVo = commentService.list("1", 1, 1, 1, 1);
     assertThat(commentListVo).isNotNull();
     System.out.println(commentListVo);
     assertThat(commentListVo.getTotal()).isEqualTo(1);