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

【企业微信】增加在线会议接口 #2924

Merged
merged 4 commits into from
Feb 7, 2023
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
@@ -0,0 +1,97 @@
package me.chanjar.weixin.cp.api;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting;
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult;
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult;

import java.util.List;

/**
* 企业微信日程接口.
* 企业和开发者通过会议接口可以便捷地预定及管理会议,用于小组周会、部门例会等场景。
* 调用接口的应用自动成为会议创建者,也可指定成员作为会议管理员辅助管理。
* 官方文档:https://developer.work.weixin.qq.com/document/path/93626
*
* @author <a href="https://github.com/wangmeng3486">wangmeng3486</a> created on 2023-01-31
*/
public interface WxCpMeetingService {
/**
* 创建预约会议
* <p>
* 该接口用于创建一个预约会议。
* <p>
* 请求方式: POST(HTTPS)
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/create?access_token=ACCESS_TOKEN
*
* @param meeting the meeting
* @return 会议ID string
* @throws WxErrorException the wx error exception
*/
String create(WxCpMeeting meeting) throws WxErrorException;

/**
* 修改预约会议
* <p>
* 该接口用于修改一个指定的预约会议。。
* <p>
* 请求方式: POST(HTTPS)
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/update?access_token=ACCESS_TOKEN
*
* @param meeting the meeting
* @return wx cp meeting update result
* @throws WxErrorException the wx error exception
*/
WxCpMeetingUpdateResult update(WxCpMeeting meeting) throws WxErrorException;


/**
* 取消预约会议
* 该接口用于取消一个指定的预约会议。
* <p>
* 请求方式: POST(HTTPS)
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/cancel?access_token=ACCESS_TOKEN
*
* @param meetingId 会议ID
* @throws WxErrorException the wx error exception
*/
void cancel(String meetingId) throws WxErrorException;

/**
* 获取会议详情
* <p>
* 该接口用于获取指定会议的详情内容。
* <p>
* 请求方式: POST(HTTPS)
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meeting/get?access_token=ACCESS_TOKEN
*
* @param meetingId the meeting ids
* @return the details
* @throws WxErrorException the wx error exception
*/
WxCpMeeting getDetail(String meetingId) throws WxErrorException;

/**
* 获取成员会议ID列表
* 该接口用于获取指定成员指定时间内的会议ID列表。
* <p>
* 权限说明:
* 只能拉取该应用创建的会议ID
* 自建应用需要配置在“可调用接口的应用”列表
* 第三方服务商创建应用的时候,需要开启“会议接口权限”
* 代开发自建应用需要授权“会议接口权限”
* <p>
* 请求方式: POST(HTTPS)
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/get_user_meetingid?access_token=ACCESS_TOKEN
*
* @param userId 企业成员的userid
* @param cursor 上一次调用时返回的cursor,初次调用可以填"0"
* @param limit 每次拉取的数据量,默认值和最大值都为100
* @param beginTime 开始时间
* @param endTime 结束时间,时间跨度不超过180天。如果begin_time和end_time都没填的话,默认end_time为当前时间
* @return result of listUserMeetingIds
* @throws WxErrorException the wx error exception
*/
WxCpUserMeetingIdResult getUserMeetingIds(String userId, String cursor, Integer limit,
Long beginTime, Long endTime) throws WxErrorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -562,4 +562,11 @@ public interface WxCpService extends WxService {
* @param exportService 异步导出服务
*/
void setExportService(WxCpExportService exportService);

/**
* 相关接口的服务类对象
*
* @return the meeting service
*/
WxCpMeetingService getMeetingService();
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH

private WxCpExportService exportService = new WxCpExportServiceImpl(this);

private final WxCpMeetingService meetingService = new WxCpMeetingServiceImpl(this);

/**
* 全局的是否正在刷新access token的锁.
*/
Expand Down Expand Up @@ -665,4 +667,9 @@ public WxCpExportService getExportService() {
public void setExportService(WxCpExportService exportService) {
this.exportService = exportService;
}

@Override
public WxCpMeetingService getMeetingService() {
return meetingService;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package me.chanjar.weixin.cp.api.impl;

import com.google.common.collect.ImmutableMap;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpMeetingService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting;
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult;
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

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

import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*;

/**
* 企业微信日程接口.
* 企业和开发者通过会议接口可以便捷地预定及管理会议,用于小组周会、部门例会等场景。
* 调用接口的应用自动成为会议创建者,也可指定成员作为会议管理员辅助管理。
* 官方文档:https://developer.work.weixin.qq.com/document/path/93626
*
* @author <a href="https://github.com/wangmeng3486">wangmeng3486</a> created on 2023-01-31
*/
@RequiredArgsConstructor
public class WxCpMeetingServiceImpl implements WxCpMeetingService {
private final WxCpService cpService;

@Override
public String create(WxCpMeeting meeting) throws WxErrorException {
return this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_ADD),
WxCpGsonBuilder.create().toJson(meeting));
}

@Override
public WxCpMeetingUpdateResult update(WxCpMeeting meeting) throws WxErrorException {
final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_UPDATE),
WxCpGsonBuilder.create().toJson(meeting));
return WxCpGsonBuilder.create().fromJson(response, WxCpMeetingUpdateResult.class);
}

@Override
public void cancel(String meetingId) throws WxErrorException {
this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_CANCEL),
WxCpGsonBuilder.create().toJson(ImmutableMap.of("meetingid", meetingId)));
}

@Override
public WxCpMeeting getDetail(String meetingId) throws WxErrorException {
final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_DETAIL),
WxCpGsonBuilder.create().toJson(ImmutableMap.of("meetingid", meetingId)));
return WxCpGsonBuilder.create().fromJson(response, WxCpMeeting.class);
}

@Override
public WxCpUserMeetingIdResult getUserMeetingIds(String userId, String cursor, Integer limit,
Long beginTime, Long endTime) throws WxErrorException {
final Map<String, Object> param = new HashMap<>(3);
param.put("userid", userId);
if (cursor != null) {
param.put("cursor", cursor);
}
if (limit != null) {
param.put("limit", limit);
}
if (limit != null) {
param.put("begin_time", beginTime);
}
if (limit != null) {
param.put("end_time", endTime);
}
final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_MEETING_ID),
WxCpGsonBuilder.create().toJson(param));
return WxCpGsonBuilder.create().fromJson(response, WxCpUserMeetingIdResult.class);
}
}
Loading