#252 增加关闭已群发文章评论和查看指定文章的评论数据的接口

This commit is contained in:
Binary Wang
2019-08-30 16:48:55 +08:00
parent 86fe8209c7
commit 4a113c473d
5 changed files with 207 additions and 5 deletions

View File

@@ -1,9 +1,11 @@
package me.chanjar.weixin.mp.api;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.bean.comment.WxMpCommentListVo;
/**
* 评论数据管理.
* 图文消息留言管理接口.
* https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1494572718_WzHIY
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* @date 2019-06-16
@@ -12,11 +14,34 @@ public interface WxMpCommentService {
/**
* 打开已群发文章评论.
* https://api.weixin.qq.com/cgi-bin/comment/open?access_token=ACCESS_TOKEN
* 参数 是否必须 类型 说明
*
* @param msgDataId 群发返回的msg_data_id
* @param index 多图文时用来指定第几篇图文从0开始不带默认操作该msg_data_id的第一篇图文
* @throws WxErrorException 异常
*/
void open(Integer msgDataId, Integer index) throws WxErrorException;
/**
* 关闭已群发文章评论.
* https://api.weixin.qq.com/cgi-bin/comment/close?access_token=ACCESS_TOKEN
*
* @param msgDataId 群发返回的msg_data_id
* @param index 多图文时用来指定第几篇图文从0开始不带默认操作该msg_data_id的第一篇图文
* @throws WxErrorException 异常
*/
void close(Integer msgDataId, Integer index) throws WxErrorException;
/**
* 查看指定文章的评论数据.
* https://api.weixin.qq.com/cgi-bin/comment/list?access_token=ACCESS_TOKEN
*
* @param msgDataId 群发返回的msg_data_id
* @param index 多图文时用来指定第几篇图文从0开始不带默认操作该msg_data_id的第一篇图文
* @param begin 起始位置
* @param count 获取数目(>=50会被拒绝
* @param type type=0 普通评论&精选评论 type=1 普通评论 type=2 精选评论
* @return 评论列表数据
* @throws WxErrorException 异常
*/
WxMpCommentListVo list(Integer msgDataId, Integer index, int begin, int count, int type) throws WxErrorException;
}

View File

@@ -5,7 +5,9 @@ import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpCommentService;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.enums.WxMpApiUrl;
import me.chanjar.weixin.mp.bean.comment.WxMpCommentListVo;
import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Comment.*;
/**
* @author <a href="https://github.com/binarywang">Binary Wang</a>
@@ -22,6 +24,33 @@ public class WxMpCommentServiceImpl implements WxMpCommentService {
if (index != null) {
json.addProperty("index", index);
}
this.wxMpService.post(WxMpApiUrl.Comment.OPEN, json.toString());
this.wxMpService.post(OPEN, json.toString());
}
@Override
public void close(Integer msgDataId, Integer index) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("msg_data_id", msgDataId);
if (index != null) {
json.addProperty("index", index);
}
this.wxMpService.post(CLOSE, json.toString());
}
@Override
public WxMpCommentListVo list(Integer 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);
json.addProperty("count", count);
json.addProperty("type", type);
if (index != null) {
json.addProperty("index", index);
}
return WxMpCommentListVo.fromJson(this.wxMpService.post(LIST, json.toString()));
}
}