🆕 #1686 微信公众号增加对话能力(原导购助手)部分接口,如修改顾问、删除顾问、获取顾问列表等

This commit is contained in:
Binary Wang
2020-10-07 20:00:59 +08:00
parent 6948044ab9
commit 9c91aeba6e
7 changed files with 143 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideInfo;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideList;
/**
* 微信导购助手(现在叫对话能力)接口.
@@ -37,6 +38,18 @@ public interface WxMpGuideService {
*/
void addGuide(WxMpGuideInfo guideInfo) throws WxErrorException;
/**
* 修改顾问的昵称或头像
* <pre>
* 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/updateguideacct?access_token=ACCESS_TOKEN
* 文档地址https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/guide-account/shopping-guide.updateGuideAcct.html
* </pre>
*
* @param guideInfo 顾问信息
* @throws WxErrorException .
*/
void updateGuide(WxMpGuideInfo guideInfo) throws WxErrorException;
/**
* 获取顾问信息
*
@@ -51,4 +64,33 @@ public interface WxMpGuideService {
* @throws WxErrorException .
*/
WxMpGuideInfo getGuide(String account, String openid) throws WxErrorException;
/**
* 删除顾问
*
* <pre>
* 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguideacct?access_token=ACCESS_TOKEN
* 文档地址https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/guide-account/shopping-guide.delGuideAcct.html
* </pre>
*
* @param account 顾问微信号guide_account和guide_openid二选一若同时请求默认为guide_account
* @param openid 顾问openid或者unionidguide_account和guide_openid二选一
* @throws WxErrorException .
*/
void delGuide(String account, String openid) throws WxErrorException;
/**
* 获取服务号顾问列表
*
* <pre>
* 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguideacctlist?access_token=ACCESS_TOKEN
* 文档地址https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/guide-account/shopping-guide.getGuideAcctList.html
* </pre>
*
* @param page 分页页数从0开始
* @param num 每页数量
* @return 顾问信息列表
* @throws WxErrorException .
*/
WxMpGuideList listGuide(int page, int num) throws WxErrorException;
}

View File

@@ -6,6 +6,7 @@ import me.chanjar.weixin.common.util.json.GsonHelper;
import me.chanjar.weixin.mp.api.WxMpGuideService;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideInfo;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideList;
import me.chanjar.weixin.mp.enums.WxMpApiUrl;
/**
@@ -35,9 +36,31 @@ public class WxMpGuideServiceImpl implements WxMpGuideService {
OPENID, guideInfo.getOpenid()));
}
@Override
public void updateGuide(WxMpGuideInfo guideInfo) throws WxErrorException {
this.mpService.post(WxMpApiUrl.Guide.UPDATE_GUIDE,
GsonHelper.buildJsonObject(ACCOUNT, guideInfo.getAccount(),
"guide_headimgurl", guideInfo.getHeadImgUrl(),
"guide_nickname", guideInfo.getNickName(),
OPENID, guideInfo.getOpenid()));
}
@Override
public WxMpGuideInfo getGuide(String account, String openid) throws WxErrorException {
return WxMpGuideInfo.fromJson(this.mpService.post(WxMpApiUrl.Guide.GET_GUIDE,
GsonHelper.buildJsonObject(ACCOUNT, account, OPENID, openid)));
}
@Override
public void delGuide(String account, String openid) throws WxErrorException {
this.mpService.post(WxMpApiUrl.Guide.DEL_GUIDE,
GsonHelper.buildJsonObject(ACCOUNT, account, OPENID, openid));
}
@Override
public WxMpGuideList listGuide(int page, int num) throws WxErrorException {
return WxMpGuideList.fromJson(this.mpService.post(WxMpApiUrl.Guide.LIST_GUIDE,
GsonHelper.buildJsonObject("page", page, "num", num)));
}
}