Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

小程序直播接口完善 #2567

Merged
merged 3 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,19 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList, String c
List<String> listFollowers() throws WxErrorException;

/**
* 企业和第三方可通过此接口,获取所有离职成员的客户列表,并可进一步调用离职成员的外部联系人再分配接口将这些客户重新分配给其他企业成员。
* 获取待分配的离职成员列表
* 企业和第三方可通过此接口,获取所有离职成员的客户列表,并可进一步调用分配离职成员的客户接口将这些客户重新分配给其他企业成员。
*
* @param page the page
* @param pageSize the page size
* @return wx cp user external unassign list
* @throws WxErrorException the wx error exception
* 请求方式:POST(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_unassigned_list?access_token=ACCESS_TOKEN
*
* @param pageId 分页查询,要查询页号,从0开始
* @param cursor 分页查询游标,字符串类型,适用于数据量较大的情况,如果使用该参数则无需填写page_id,该参数由上一次调用返回
* @param pageSize 每次返回的最大记录数,默认为1000,最大值为1000
* @return
* @throws WxErrorException
*/
WxCpUserExternalUnassignList listUnassignedList(Integer page, Integer pageSize) throws WxErrorException;
WxCpUserExternalUnassignList listUnassignedList(Integer pageId, String cursor, Integer pageSize) throws WxErrorException;

/**
* 企业可通过此接口,将已离职成员的外部联系人分配给另一个成员接替联系。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.ExternalContact.*;

/**
* @author 曹祖鹏 & yuanqixun & Mr.Pan
* @author 曹祖鹏 & yuanqixun & Mr.Pan & Wang_Wong
*/
@RequiredArgsConstructor
public class WxCpExternalContactServiceImpl implements WxCpExternalContactService {
Expand Down Expand Up @@ -245,10 +245,13 @@ public List<String> listFollowers() throws WxErrorException {
}

@Override
public WxCpUserExternalUnassignList listUnassignedList(Integer pageIndex, Integer pageSize) throws WxErrorException {
public WxCpUserExternalUnassignList listUnassignedList(Integer pageIndex, String cursor, Integer pageSize) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("page_id", pageIndex == null ? 0 : pageIndex);
json.addProperty("page_size", pageSize == null ? 100 : pageSize);
if(pageIndex != null){
json.addProperty("page_id", pageIndex);
}
json.addProperty("cursor", StringUtils.isEmpty(cursor) ? "" : cursor);
json.addProperty("page_size", pageSize == null ? 1000 : pageSize);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_UNASSIGNED_CONTACT);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalUnassignList.fromJson(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* 离职员工外部联系人列表
*
* @author yqx
* @author yqx & Wang_Wong
* @date 2020/3/15
*/
@Getter
Expand All @@ -25,6 +25,9 @@ public class WxCpUserExternalUnassignList extends WxCpBaseResp {
@SerializedName("is_last")
private boolean isLast;

@SerializedName("next_cursor")
private String nextCursor;

@Getter
@Setter
public static class UnassignInfo implements Serializable {
Expand Down Expand Up @@ -52,4 +55,9 @@ public static class UnassignInfo implements Serializable {
public static WxCpUserExternalUnassignList fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalUnassignList.class);
}

public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package me.chanjar.weixin.cp.api;

import com.google.common.collect.Lists;
import com.google.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.external.*;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactBatchInfo;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
import me.chanjar.weixin.cp.bean.external.msg.Attachment;
import me.chanjar.weixin.cp.bean.external.msg.Image;
import me.chanjar.weixin.cp.bean.external.msg.Video;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import org.testng.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import static org.testng.Assert.assertNotNull;

/**
* 离职继承测试类
*
* 官方文档:
* https://developer.work.weixin.qq.com/document/path/92124
*/
@Slf4j
@Guice(modules = ApiTestModule.class)
public class WxCpExternalContactTest {

@Inject
private WxCpService wxCpService;
@Inject
protected ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage;

@Test
public void testGetExternalContact() throws WxErrorException {
String externalUserId = this.configStorage.getExternalUserId();
WxCpUserExternalUnassignList unassignList = this.wxCpService.getExternalContactService().listUnassignedList(null, null, 100);
log.info(unassignList.toJson());

// test str
String result = "{\"errcode\":0,\"errmsg\":\"ok\",\"info\":[{\"handover_userid\":\"zhangsan\",\"external_userid\":\"woAJ2GCAAAd4uL12hdfsdasassdDmAAAAA\",\"dimission_time\":1550838571},{\"handover_userid\":\"lisi\",\"external_userid\":\"wmAJ2GCAAAzLTI123ghsdfoGZNqqAAAA\",\"dimission_time\":1550661468}],\"is_last\":false,\"next_cursor\":\"aSfwejksvhToiMMfFeIGZZ\"}";
WxCpUserExternalUnassignList json = WxCpUserExternalUnassignList.fromJson(result);
log.info(json.toJson());

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.chanjar.weixin.common.error.WxErrorException;

import java.util.List;
import java.util.Map;

/**
* <pre>
Expand Down Expand Up @@ -207,4 +208,190 @@ public interface WxMaLiveService {
* @throws WxErrorException .
*/
List<WxMaAssistantResult.Assistant> getAssistantList(Integer roomId) throws WxErrorException;

/**
* 添加主播副号
* <p>
* 调用接口添加主播副号
* <p>
* 调用额度:10000次/一天
* <p>
* http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/addsubanchor?access_token=ACCESS_TOKEN
* <pre>
* @param roomId 房间ID
* @param username 用户微信号
* @return 是否成功
* @throws WxErrorException .
*/
boolean addSubanchor(Integer roomId, String username) throws WxErrorException;

/**
* 修改主播副号
* <p>
* 调用接口修改主播副号
* <p>
* 调用频率: 10000次/一天
* <p>
* http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/modifyassistant?access_token=ACCESS_TOKEN
* <pre>
* @param roomId 房间ID
* @param username 小助手微信号
* @param username 用户微信号
* @return 是否成功
* @throws WxErrorException .
*/
boolean modifySubanchor(Integer roomId, String username) throws WxErrorException;

/**
* 删除主播副号
* <p>
* 调用频率: 10000次/一天
* <p>
* http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/deletesubanchor?access_token=ACCESS_TOKEN
* <pre>
* @param roomId 房间ID
* @return 是否成功
* @throws WxErrorException .
*/
boolean deleteSubanchor(Integer roomId) throws WxErrorException;

/**
* 获取主播副号
* <p>
* 调用额度:10000次/一天
* <p>
* http请求方式:GET https://api.weixin.qq.com/wxaapi/broadcast/room/getsubanchor?access_token=ACCESS_TOKEN
* </pre>
* @param roomId 直播间id
* @return .
* @throws WxErrorException .
*/
String getSubanchor(Integer roomId) throws WxErrorException;

/**
* 开启/关闭直播间官方收录
* <p>
* 调用额度:10000次/一天
* <p>
* http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatefeedpublic?access_token=ACCESS_TOKEN
* <pre>
* @param roomId 房间ID
* @param isFeedsPublic 是否开启官方收录 【1: 开启,0:关闭】
* @return 是否成功
* @throws WxErrorException .
*/
boolean updatefeedpublic(Integer roomId, Integer isFeedsPublic) throws WxErrorException;

/**
* 开启/关闭回放功能
* <p>
* 调用额度:10000次/一天
* <p>
* http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatereplay?access_token=ACCESS_TOKEN
* <pre>
* @param roomId 房间ID
* @param closeReplay 是否关闭回放 【0:开启,1:关闭】
* @return 是否成功
* @throws WxErrorException .
*/
boolean updatereplay(Integer roomId, Integer closeReplay) throws WxErrorException;

/**
* 开启/关闭客服功能
* <p>
* 调用额度:10000次/一天
* <p>
* http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatekf?access_token=ACCESS_TOKEN
* <pre>
* @param roomId 房间ID
* @param closeKf 是否关闭客服 【0:开启,1:关闭】
* @return 是否成功
* @throws WxErrorException .
*/
boolean updatekf(Integer roomId, Integer closeKf) throws WxErrorException;

/**
* 开启/关闭直播间全局禁言
* <p>
* 调用额度:10000次/一天
* <p>
* http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatecomment?access_token=ACCESS_TOKEN
* <pre>
* @param roomId 房间ID
* @param banComment 1-禁言,0-取消禁言
* @return 是否成功
* @throws WxErrorException .
*/
boolean updatecomment(Integer roomId, Integer banComment) throws WxErrorException;

/**
* 上下架商品
* <p>
* 调用额度:10000次/一天
* <p>
* http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/onsale?access_token=ACCESS_TOKEN
* <pre>
* @param roomId 房间ID
* @param goodsId 商品ID
* @param onSale 上下架 【0:下架,1:上架】
* @return 是否成功
* @throws WxErrorException .
*/
boolean onsale(Integer roomId, Integer goodsId, Integer onSale) throws WxErrorException;

/**
* 删除直播间商品
* <p>
* 调用额度:10000次/一天
* <p>
* http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token=ACCESS_TOKEN
* <pre>
* @param roomId 房间ID
* @param goodsId 商品ID
* @return 是否成功
* @throws WxErrorException .
*/
boolean deleteInRoom(Integer roomId, Integer goodsId) throws WxErrorException;

/**
* 推送商品
* <p>
* 调用额度:10000次/一天
* <p>
* http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/push?access_token=ACCESS_TOKEN
* <pre>
* @param roomId 房间ID
* @param goodsId 商品ID
* @return 是否成功
* @throws WxErrorException .
*/
boolean push(Integer roomId, Integer goodsId) throws WxErrorException;

/**
* 直播间商品排序
* <p>
* 调用额度:10000次/一天
* <p>
* http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/sort?access_token=ACCESS_TOKEN
* <pre>
* @param roomId 房间ID
* @param goods 商品ID列表, 例如: [{"goodsId":"123"}, {"goodsId":"234"}]
* @return 是否成功
* @throws WxErrorException .
*/
boolean sort(Integer roomId, List<Map<String,String>> goods) throws WxErrorException;

/**
* 下载商品讲解视频
* <p>
* 调用额度:10000次/一天
* <p>
* http请求方式:GET https://api.weixin.qq.com/wxaapi/broadcast/goods/getVideo?access_token=ACCESS_TOKEN
* </pre>
* @param roomId 直播间id
* @param goodsId 商品ID
* @return .
* @throws WxErrorException .
*/
String getVideo(Integer roomId, Integer goodsId) throws WxErrorException;
}
Loading