Skip to content

Commit 94ff00b

Browse files
authored
🆕 #2722【企业微信】 增加会议室管理相关接口
1 parent 6472484 commit 94ff00b

File tree

7 files changed

+314
-0
lines changed

7 files changed

+314
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package me.chanjar.weixin.cp.api;
2+
3+
import me.chanjar.weixin.common.error.WxErrorException;
4+
import me.chanjar.weixin.cp.bean.oa.meetingroom.WxCpOaMeetingRoom;
5+
6+
import java.util.List;
7+
8+
/**
9+
* 企业微信会议室接口.
10+
*
11+
* @author <a href="https://github.com/lm93129">lm93129</a>
12+
* @date 2022年8月12日22:33:36
13+
*/
14+
public interface WxCpOaMeetingRoomService {
15+
/**
16+
* 创建会议室.
17+
* <pre>
18+
* 该接口用于通过应用在企业内创建一个会议室。
19+
* 请求方式: POST(HTTPS)
20+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/add?access_token=ACCESS_TOKEN
21+
*
22+
* 文档地址:https://developer.work.weixin.qq.com/document/path/93619
23+
* </pre>
24+
*
25+
* @param meetingRoom 会议室对象
26+
* @return 会议室ID
27+
* @throws WxErrorException .
28+
*/
29+
String addMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException;
30+
31+
/**
32+
* 查询会议室.
33+
* <pre>
34+
* 该接口用于通过应用在企业内查询会议室列表。
35+
* 请求方式: POST(HTTPS)
36+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/list?access_token=ACCESS_TOKEN
37+
*
38+
* 文档地址:https://developer.work.weixin.qq.com/document/path/93619
39+
* </pre>
40+
*
41+
* @param meetingRoomRequest 会议室查询对象
42+
* @return 会议室ID
43+
* @throws WxErrorException .
44+
*/
45+
List<WxCpOaMeetingRoom> listMeetingRoom(WxCpOaMeetingRoom meetingRoomRequest) throws WxErrorException;
46+
47+
/**
48+
* 编辑会议室.
49+
* <pre>
50+
* 该接口用于通过应用在企业内编辑会议室。
51+
* 请求方式: POST(HTTPS)
52+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/edit?access_token=ACCESS_TOKEN
53+
*
54+
* 文档地址:https://developer.work.weixin.qq.com/document/path/93619
55+
* </pre>
56+
*
57+
* @param meetingRoom 会议室对象
58+
* @throws WxErrorException .
59+
*/
60+
void editMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException;
61+
62+
/**
63+
* 编辑会议室.
64+
* <pre>
65+
* 该接口用于通过应用在企业内编辑会议室。
66+
* 请求方式: POST(HTTPS)
67+
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/del?access_token=ACCESS_TOKEN
68+
*
69+
* 文档地址:https://developer.work.weixin.qq.com/document/path/93619
70+
* </pre>
71+
*
72+
* @param meetingRoomId 会议室对象
73+
* @throws WxErrorException .
74+
*/
75+
void deleteMeetingRoom(Integer meetingRoomId) throws WxErrorException;
76+
}

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

+7
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,13 @@ public interface WxCpService extends WxService {
456456
*/
457457
WxCpOaCalendarService getOaCalendarService();
458458

459+
/**
460+
* 获取会议室相关接口的服务类对象
461+
*
462+
* @return the oa meetingroom service
463+
*/
464+
WxCpOaMeetingRoomService getOaMeetingRoomService();
465+
459466
/**
460467
* 获取日程相关接口的服务类对象
461468
*

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

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
6161
private WxCpGroupRobotService groupRobotService = new WxCpGroupRobotServiceImpl(this);
6262
private WxCpMessageService messageService = new WxCpMessageServiceImpl(this);
6363
private WxCpOaCalendarService oaCalendarService = new WxCpOaCalendarServiceImpl(this);
64+
private WxCpOaMeetingRoomService oaMeetingRoomService = new WxCpOaMeetingRoomServiceImpl(this);
6465
private WxCpOaScheduleService oaScheduleService = new WxCpOaOaScheduleServiceImpl(this);
6566
private WxCpAgentWorkBenchService workBenchService = new WxCpAgentWorkBenchServiceImpl(this);
6667
private WxCpKfService kfService = new WxCpKfServiceImpl(this);
@@ -536,6 +537,11 @@ public WxCpOaCalendarService getOaCalendarService() {
536537
return this.oaCalendarService;
537538
}
538539

540+
@Override
541+
public WxCpOaMeetingRoomService getOaMeetingRoomService() {
542+
return this.oaMeetingRoomService;
543+
}
544+
539545
@Override
540546
public WxCpGroupRobotService getGroupRobotService() {
541547
return groupRobotService;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package me.chanjar.weixin.cp.api.impl;
2+
3+
import com.google.gson.reflect.TypeToken;
4+
import lombok.RequiredArgsConstructor;
5+
import me.chanjar.weixin.common.error.WxErrorException;
6+
import me.chanjar.weixin.common.util.json.GsonHelper;
7+
import me.chanjar.weixin.common.util.json.GsonParser;
8+
import me.chanjar.weixin.cp.api.WxCpOaMeetingRoomService;
9+
import me.chanjar.weixin.cp.api.WxCpService;
10+
11+
import me.chanjar.weixin.cp.bean.oa.meetingroom.WxCpOaMeetingRoom;
12+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
13+
14+
import java.util.List;
15+
16+
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*;
17+
18+
/**
19+
* @author fcat
20+
* @version 1.0
21+
* Create by 2022/8/12 23:49
22+
*/
23+
@RequiredArgsConstructor
24+
public class WxCpOaMeetingRoomServiceImpl implements WxCpOaMeetingRoomService {
25+
private final WxCpService wxCpService;
26+
27+
@Override
28+
public String addMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException {
29+
return this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_ADD), meetingRoom);
30+
}
31+
32+
@Override
33+
public List<WxCpOaMeetingRoom> listMeetingRoom(WxCpOaMeetingRoom meetingRoomRequest) throws WxErrorException {
34+
String response = this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_LIST),
35+
meetingRoomRequest);
36+
return WxCpGsonBuilder.create().fromJson(GsonParser.parse(response).get("meetingroom_list").getAsJsonArray().toString(),
37+
new TypeToken<List<WxCpOaMeetingRoom>>() {
38+
}.getType());
39+
}
40+
41+
@Override
42+
public void editMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException {
43+
this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_EDIT), meetingRoom);
44+
}
45+
46+
@Override
47+
public void deleteMeetingRoom(Integer meetingRoomId) throws WxErrorException {
48+
this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_DEL),
49+
GsonHelper.buildJsonObject("meetingroom_id", meetingRoomId));
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package me.chanjar.weixin.cp.bean.oa.meetingroom;
2+
3+
4+
import com.google.gson.annotations.SerializedName;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Builder;
7+
import lombok.Data;
8+
import lombok.NoArgsConstructor;
9+
import lombok.experimental.Accessors;
10+
import me.chanjar.weixin.common.bean.ToJson;
11+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
12+
13+
import java.io.Serializable;
14+
import java.util.List;
15+
16+
/**
17+
* @author fcat
18+
* @version 1.0
19+
* Create by 2022/8/12 22:46
20+
*/
21+
@Data
22+
@Builder
23+
@NoArgsConstructor
24+
@AllArgsConstructor
25+
@Accessors(chain = true)
26+
public class WxCpOaMeetingRoom implements Serializable, ToJson {
27+
private static final long serialVersionUID = 2825289798463742532L;
28+
/**
29+
* 会议室Id
30+
*/
31+
@SerializedName("meetingroom_id")
32+
private Integer meetingroomId;
33+
/**
34+
* 会议室名称,最多30个字符
35+
*/
36+
@SerializedName("name")
37+
private String name;
38+
/**
39+
* 会议室所能容纳的人数
40+
*/
41+
@SerializedName("capacity")
42+
private Integer capacity;
43+
/**
44+
* 会议室所在城市
45+
*/
46+
@SerializedName("city")
47+
private String city;
48+
/**
49+
* 会议室所在楼宇
50+
*/
51+
@SerializedName("building")
52+
private String building;
53+
/**
54+
* 会议室所在楼层
55+
*/
56+
@SerializedName("floor")
57+
private String floor;
58+
/**
59+
* 会议室支持的设备列表,参数详细1电视2电话3投影4白板5视频
60+
*/
61+
@SerializedName("equipment")
62+
private List<Integer> equipment;
63+
/**
64+
* 会议室所在建筑经纬度
65+
*/
66+
@SerializedName("coordinate")
67+
private Coordinate coordinate;
68+
/**
69+
* 会议室是否需要预定
70+
*/
71+
@SerializedName("need_approval")
72+
private Integer needApproval;
73+
74+
@Override
75+
public String toJson() {
76+
return WxCpGsonBuilder.create().toJson(this);
77+
}
78+
79+
@Data
80+
@AllArgsConstructor
81+
public static class Coordinate implements Serializable {
82+
private static final long serialVersionUID = 6626968559923978694L;
83+
/**
84+
* 纬度
85+
*/
86+
@SerializedName("latitude")
87+
private String latitude;
88+
/**
89+
* 经度
90+
*/
91+
@SerializedName("longitude")
92+
private String longitude;
93+
}
94+
}

Diff for: weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java

+9
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ interface Oa {
151151
String SCHEDULE_DEL = "/cgi-bin/oa/schedule/del";
152152
String SCHEDULE_LIST = "/cgi-bin/oa/schedule/get_by_calendar";
153153

154+
/**
155+
* 会议
156+
* https://developer.work.weixin.qq.com/document/path/93624
157+
*/
158+
String MEETINGROOM_ADD = "/cgi-bin/oa/meetingroom/add";
159+
String MEETINGROOM_LIST = "/cgi-bin/oa/meetingroom/list";
160+
String MEETINGROOM_EDIT = "/cgi-bin/oa/meetingroom/edit";
161+
String MEETINGROOM_DEL = "/cgi-bin/oa/meetingroom/del";
162+
154163
/**
155164
* 微盘
156165
* https://developer.work.weixin.qq.com/document/path/93654
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package me.chanjar.weixin.cp.api.impl;
2+
3+
import com.google.inject.Inject;
4+
import me.chanjar.weixin.common.error.WxErrorException;
5+
import me.chanjar.weixin.cp.api.ApiTestModule;
6+
import me.chanjar.weixin.cp.api.WxCpService;
7+
import me.chanjar.weixin.cp.bean.oa.meetingroom.WxCpOaMeetingRoom;
8+
import org.testng.annotations.Guice;
9+
import org.testng.annotations.Test;
10+
11+
import java.util.Arrays;
12+
import java.util.List;
13+
14+
import static org.assertj.core.api.Assertions.assertThat;
15+
16+
/**
17+
* 单元测试.
18+
*
19+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
20+
* @date 2020-09-20
21+
*/
22+
23+
@Test
24+
@Guice(modules = ApiTestModule.class)
25+
public class WxCpOaMeetingRoomServiceImplTest {
26+
@Inject
27+
protected WxCpService wxService;
28+
29+
@Test
30+
public void testAdd() throws WxErrorException {
31+
this.wxService.getOaMeetingRoomService().addMeetingRoom(WxCpOaMeetingRoom.builder()
32+
.building("腾讯大厦")
33+
.capacity(10)
34+
.city("深圳")
35+
.name("18F-会议室")
36+
.floor("18F")
37+
.equipment(Arrays.asList(1, 2))
38+
// .coordinate()
39+
.build());
40+
41+
}
42+
43+
@Test
44+
public void testUpdate() throws WxErrorException {
45+
this.wxService.getOaMeetingRoomService().editMeetingRoom(WxCpOaMeetingRoom.builder()
46+
.building("腾讯大厦")
47+
.capacity(10)
48+
.city("深圳")
49+
.name("16F-会议室")
50+
.floor("16F")
51+
.equipment(Arrays.asList(1, 2, 3))
52+
.meetingroomId(1)
53+
.build());
54+
}
55+
56+
@Test
57+
public void testGet() throws WxErrorException {
58+
final List<WxCpOaMeetingRoom> meetingRooms = this.wxService.getOaMeetingRoomService().listMeetingRoom(WxCpOaMeetingRoom.builder()
59+
.building("腾讯大厦")
60+
.city("深圳")
61+
.equipment(Arrays.asList(1, 2))
62+
.build());
63+
assertThat(meetingRooms).isNotEmpty();
64+
}
65+
66+
@Test
67+
public void testDelete() throws WxErrorException {
68+
Integer calId = 1;
69+
this.wxService.getOaMeetingRoomService().deleteMeetingRoom(calId);
70+
}
71+
}

0 commit comments

Comments
 (0)