Skip to content

Commit 3def66b

Browse files
authored
🆕 #2924【企业微信】增加会议相关的接口
1 parent bef1540 commit 3def66b

File tree

9 files changed

+690
-0
lines changed

9 files changed

+690
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package me.chanjar.weixin.cp.api;
2+
3+
import me.chanjar.weixin.common.error.WxErrorException;
4+
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting;
5+
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult;
6+
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult;
7+
8+
import java.util.List;
9+
10+
/**
11+
* 企业微信日程接口.
12+
* 企业和开发者通过会议接口可以便捷地预定及管理会议,用于小组周会、部门例会等场景。
13+
* 调用接口的应用自动成为会议创建者,也可指定成员作为会议管理员辅助管理。
14+
* 官方文档:https://developer.work.weixin.qq.com/document/path/93626
15+
*
16+
* @author <a href="https://github.com/wangmeng3486">wangmeng3486</a> created on 2023-01-31
17+
*/
18+
public interface WxCpMeetingService {
19+
/**
20+
* 创建预约会议
21+
* <p>
22+
* 该接口用于创建一个预约会议。
23+
* <p>
24+
* 请求方式: POST(HTTPS)
25+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/create?access_token=ACCESS_TOKEN
26+
*
27+
* @param meeting the meeting
28+
* @return 会议ID string
29+
* @throws WxErrorException the wx error exception
30+
*/
31+
String create(WxCpMeeting meeting) throws WxErrorException;
32+
33+
/**
34+
* 修改预约会议
35+
* <p>
36+
* 该接口用于修改一个指定的预约会议。。
37+
* <p>
38+
* 请求方式: POST(HTTPS)
39+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/update?access_token=ACCESS_TOKEN
40+
*
41+
* @param meeting the meeting
42+
* @return wx cp meeting update result
43+
* @throws WxErrorException the wx error exception
44+
*/
45+
WxCpMeetingUpdateResult update(WxCpMeeting meeting) throws WxErrorException;
46+
47+
48+
/**
49+
* 取消预约会议
50+
* 该接口用于取消一个指定的预约会议。
51+
* <p>
52+
* 请求方式: POST(HTTPS)
53+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/cancel?access_token=ACCESS_TOKEN
54+
*
55+
* @param meetingId 会议ID
56+
* @throws WxErrorException the wx error exception
57+
*/
58+
void cancel(String meetingId) throws WxErrorException;
59+
60+
/**
61+
* 获取会议详情
62+
* <p>
63+
* 该接口用于获取指定会议的详情内容。
64+
* <p>
65+
* 请求方式: POST(HTTPS)
66+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meeting/get?access_token=ACCESS_TOKEN
67+
*
68+
* @param meetingId the meeting ids
69+
* @return the details
70+
* @throws WxErrorException the wx error exception
71+
*/
72+
WxCpMeeting getDetail(String meetingId) throws WxErrorException;
73+
74+
/**
75+
* 获取成员会议ID列表
76+
* 该接口用于获取指定成员指定时间内的会议ID列表。
77+
* <p>
78+
* 权限说明:
79+
* 只能拉取该应用创建的会议ID
80+
* 自建应用需要配置在“可调用接口的应用”列表
81+
* 第三方服务商创建应用的时候,需要开启“会议接口权限”
82+
* 代开发自建应用需要授权“会议接口权限”
83+
* <p>
84+
* 请求方式: POST(HTTPS)
85+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/meeting/get_user_meetingid?access_token=ACCESS_TOKEN
86+
*
87+
* @param userId 企业成员的userid
88+
* @param cursor 上一次调用时返回的cursor,初次调用可以填"0"
89+
* @param limit 每次拉取的数据量,默认值和最大值都为100
90+
* @param beginTime 开始时间
91+
* @param endTime 结束时间,时间跨度不超过180天。如果begin_time和end_time都没填的话,默认end_time为当前时间
92+
* @return result of listUserMeetingIds
93+
* @throws WxErrorException the wx error exception
94+
*/
95+
WxCpUserMeetingIdResult getUserMeetingIds(String userId, String cursor, Integer limit,
96+
Long beginTime, Long endTime) throws WxErrorException;
97+
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,4 +562,11 @@ public interface WxCpService extends WxService {
562562
* @param exportService 异步导出服务
563563
*/
564564
void setExportService(WxCpExportService exportService);
565+
566+
/**
567+
* 相关接口的服务类对象
568+
*
569+
* @return the meeting service
570+
*/
571+
WxCpMeetingService getMeetingService();
565572
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
7070

7171
private WxCpExportService exportService = new WxCpExportServiceImpl(this);
7272

73+
private final WxCpMeetingService meetingService = new WxCpMeetingServiceImpl(this);
74+
7375
/**
7476
* 全局的是否正在刷新access token的锁.
7577
*/
@@ -665,4 +667,9 @@ public WxCpExportService getExportService() {
665667
public void setExportService(WxCpExportService exportService) {
666668
this.exportService = exportService;
667669
}
670+
671+
@Override
672+
public WxCpMeetingService getMeetingService() {
673+
return meetingService;
674+
}
668675
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package me.chanjar.weixin.cp.api.impl;
2+
3+
import com.google.common.collect.ImmutableMap;
4+
import lombok.RequiredArgsConstructor;
5+
import me.chanjar.weixin.common.error.WxErrorException;
6+
import me.chanjar.weixin.cp.api.WxCpMeetingService;
7+
import me.chanjar.weixin.cp.api.WxCpService;
8+
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeeting;
9+
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpMeetingUpdateResult;
10+
import me.chanjar.weixin.cp.bean.oa.meeting.WxCpUserMeetingIdResult;
11+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
12+
13+
import java.util.HashMap;
14+
import java.util.List;
15+
import java.util.Map;
16+
17+
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*;
18+
19+
/**
20+
* 企业微信日程接口.
21+
* 企业和开发者通过会议接口可以便捷地预定及管理会议,用于小组周会、部门例会等场景。
22+
* 调用接口的应用自动成为会议创建者,也可指定成员作为会议管理员辅助管理。
23+
* 官方文档:https://developer.work.weixin.qq.com/document/path/93626
24+
*
25+
* @author <a href="https://github.com/wangmeng3486">wangmeng3486</a> created on 2023-01-31
26+
*/
27+
@RequiredArgsConstructor
28+
public class WxCpMeetingServiceImpl implements WxCpMeetingService {
29+
private final WxCpService cpService;
30+
31+
@Override
32+
public String create(WxCpMeeting meeting) throws WxErrorException {
33+
return this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_ADD),
34+
WxCpGsonBuilder.create().toJson(meeting));
35+
}
36+
37+
@Override
38+
public WxCpMeetingUpdateResult update(WxCpMeeting meeting) throws WxErrorException {
39+
final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_UPDATE),
40+
WxCpGsonBuilder.create().toJson(meeting));
41+
return WxCpGsonBuilder.create().fromJson(response, WxCpMeetingUpdateResult.class);
42+
}
43+
44+
@Override
45+
public void cancel(String meetingId) throws WxErrorException {
46+
this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_CANCEL),
47+
WxCpGsonBuilder.create().toJson(ImmutableMap.of("meetingid", meetingId)));
48+
}
49+
50+
@Override
51+
public WxCpMeeting getDetail(String meetingId) throws WxErrorException {
52+
final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(MEETING_DETAIL),
53+
WxCpGsonBuilder.create().toJson(ImmutableMap.of("meetingid", meetingId)));
54+
return WxCpGsonBuilder.create().fromJson(response, WxCpMeeting.class);
55+
}
56+
57+
@Override
58+
public WxCpUserMeetingIdResult getUserMeetingIds(String userId, String cursor, Integer limit,
59+
Long beginTime, Long endTime) throws WxErrorException {
60+
final Map<String, Object> param = new HashMap<>(3);
61+
param.put("userid", userId);
62+
if (cursor != null) {
63+
param.put("cursor", cursor);
64+
}
65+
if (limit != null) {
66+
param.put("limit", limit);
67+
}
68+
if (limit != null) {
69+
param.put("begin_time", beginTime);
70+
}
71+
if (limit != null) {
72+
param.put("end_time", endTime);
73+
}
74+
final String response = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_MEETING_ID),
75+
WxCpGsonBuilder.create().toJson(param));
76+
return WxCpGsonBuilder.create().fromJson(response, WxCpUserMeetingIdResult.class);
77+
}
78+
}

0 commit comments

Comments
 (0)