mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-24 16:18:51 +08:00
#252 添加图文消息留言管理中打开已群发文章评论的接口
This commit is contained in:
parent
9c149bb1e2
commit
be78d8c125
@ -0,0 +1,22 @@
|
|||||||
|
package me.chanjar.weixin.mp.api;
|
||||||
|
|
||||||
|
import me.chanjar.weixin.common.error.WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论数据管理.
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
|
* @date 2019-06-16
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
@ -526,4 +526,13 @@ public interface WxMpService {
|
|||||||
void setAiOpenService(WxMpAiOpenService aiOpenService);
|
void setAiOpenService(WxMpAiOpenService aiOpenService);
|
||||||
|
|
||||||
void setMarketingService(WxMpMarketingService marketingService);
|
void setMarketingService(WxMpMarketingService marketingService);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回评论数据管理接口方法的实现类对象,以方便调用其各个接口.
|
||||||
|
*
|
||||||
|
* @return WxMpWifiService
|
||||||
|
*/
|
||||||
|
WxMpCommentService getCommentService();
|
||||||
|
|
||||||
|
void setCommentService(WxMpCommentService commentService);
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
|
|||||||
private WxMpAiOpenService aiOpenService = new WxMpAiOpenServiceImpl(this);
|
private WxMpAiOpenService aiOpenService = new WxMpAiOpenServiceImpl(this);
|
||||||
private WxMpWifiService wifiService = new WxMpWifiServiceImpl(this);
|
private WxMpWifiService wifiService = new WxMpWifiServiceImpl(this);
|
||||||
private WxMpMarketingService marketingService = new WxMpMarketingServiceImpl(this);
|
private WxMpMarketingService marketingService = new WxMpMarketingServiceImpl(this);
|
||||||
|
private WxMpCommentService commentService = new WxMpCommentServiceImpl(this);
|
||||||
|
|
||||||
private Map<String, WxMpConfigStorage> configStorageMap;
|
private Map<String, WxMpConfigStorage> configStorageMap;
|
||||||
|
|
||||||
@ -608,4 +609,14 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
|
|||||||
public void setMarketingService(WxMpMarketingService marketingService) {
|
public void setMarketingService(WxMpMarketingService marketingService) {
|
||||||
this.marketingService = marketingService;
|
this.marketingService = marketingService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxMpCommentService getCommentService() {
|
||||||
|
return this.commentService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCommentService(WxMpCommentService commentService) {
|
||||||
|
this.commentService = commentService;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package me.chanjar.weixin.mp.api.impl;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
|
* @date 2019-06-16
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class WxMpCommentServiceImpl implements WxMpCommentService {
|
||||||
|
private final WxMpService wxMpService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void open(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(WxMpApiUrl.Comment.OPEN, json.toString());
|
||||||
|
}
|
||||||
|
}
|
@ -807,7 +807,6 @@ public interface WxMpApiUrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
enum User implements WxMpApiUrl {
|
enum User implements WxMpApiUrl {
|
||||||
/**
|
/**
|
||||||
@ -839,4 +838,20 @@ public interface WxMpApiUrl {
|
|||||||
return buildUrl(config.getHostConfig(), prefix, path);
|
return buildUrl(config.getHostConfig(), prefix, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
enum Comment implements WxMpApiUrl {
|
||||||
|
/**
|
||||||
|
* 打开已群发文章评论.
|
||||||
|
*/
|
||||||
|
OPEN(API_DEFAULT_HOST_URL, "/cgi-bin/comment/open");
|
||||||
|
|
||||||
|
private String prefix;
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUrl(WxMpConfigStorage config) {
|
||||||
|
return buildUrl(config.getHostConfig(), prefix, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package me.chanjar.weixin.mp.api.impl;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import me.chanjar.weixin.common.error.WxErrorException;
|
||||||
|
import me.chanjar.weixin.mp.api.WxMpService;
|
||||||
|
import me.chanjar.weixin.mp.api.test.ApiTestModule;
|
||||||
|
import org.testng.annotations.Guice;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试类.
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
|
* @date 2019-06-16
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Guice(modules = ApiTestModule.class)
|
||||||
|
public class WxMpCommentServiceImplTest {
|
||||||
|
@Inject
|
||||||
|
private WxMpService wxService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOpen() throws WxErrorException {
|
||||||
|
this.wxService.getCommentService().open(1, null);
|
||||||
|
this.wxService.getCommentService().open(1, 0);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user