mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-03 04:13:37 +08:00
🆕 #2722【企业微信】 增加会议室管理相关接口
This commit is contained in:
parent
6472484b32
commit
94ff00bc4b
@ -0,0 +1,76 @@
|
||||
package me.chanjar.weixin.cp.api;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.oa.meetingroom.WxCpOaMeetingRoom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 企业微信会议室接口.
|
||||
*
|
||||
* @author <a href="https://github.com/lm93129">lm93129</a>
|
||||
* @date 2022年8月12日22:33:36
|
||||
*/
|
||||
public interface WxCpOaMeetingRoomService {
|
||||
/**
|
||||
* 创建会议室.
|
||||
* <pre>
|
||||
* 该接口用于通过应用在企业内创建一个会议室。
|
||||
* 请求方式: POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/add?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/93619
|
||||
* </pre>
|
||||
*
|
||||
* @param meetingRoom 会议室对象
|
||||
* @return 会议室ID
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
String addMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 查询会议室.
|
||||
* <pre>
|
||||
* 该接口用于通过应用在企业内查询会议室列表。
|
||||
* 请求方式: POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/list?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/93619
|
||||
* </pre>
|
||||
*
|
||||
* @param meetingRoomRequest 会议室查询对象
|
||||
* @return 会议室ID
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
List<WxCpOaMeetingRoom> listMeetingRoom(WxCpOaMeetingRoom meetingRoomRequest) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 编辑会议室.
|
||||
* <pre>
|
||||
* 该接口用于通过应用在企业内编辑会议室。
|
||||
* 请求方式: POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/edit?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/93619
|
||||
* </pre>
|
||||
*
|
||||
* @param meetingRoom 会议室对象
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
void editMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 编辑会议室.
|
||||
* <pre>
|
||||
* 该接口用于通过应用在企业内编辑会议室。
|
||||
* 请求方式: POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/meetingroom/del?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/93619
|
||||
* </pre>
|
||||
*
|
||||
* @param meetingRoomId 会议室对象
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
void deleteMeetingRoom(Integer meetingRoomId) throws WxErrorException;
|
||||
}
|
@ -456,6 +456,13 @@ public interface WxCpService extends WxService {
|
||||
*/
|
||||
WxCpOaCalendarService getOaCalendarService();
|
||||
|
||||
/**
|
||||
* 获取会议室相关接口的服务类对象
|
||||
*
|
||||
* @return the oa meetingroom service
|
||||
*/
|
||||
WxCpOaMeetingRoomService getOaMeetingRoomService();
|
||||
|
||||
/**
|
||||
* 获取日程相关接口的服务类对象
|
||||
*
|
||||
|
@ -61,6 +61,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
|
||||
private WxCpGroupRobotService groupRobotService = new WxCpGroupRobotServiceImpl(this);
|
||||
private WxCpMessageService messageService = new WxCpMessageServiceImpl(this);
|
||||
private WxCpOaCalendarService oaCalendarService = new WxCpOaCalendarServiceImpl(this);
|
||||
private WxCpOaMeetingRoomService oaMeetingRoomService = new WxCpOaMeetingRoomServiceImpl(this);
|
||||
private WxCpOaScheduleService oaScheduleService = new WxCpOaOaScheduleServiceImpl(this);
|
||||
private WxCpAgentWorkBenchService workBenchService = new WxCpAgentWorkBenchServiceImpl(this);
|
||||
private WxCpKfService kfService = new WxCpKfServiceImpl(this);
|
||||
@ -536,6 +537,11 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
|
||||
return this.oaCalendarService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpOaMeetingRoomService getOaMeetingRoomService() {
|
||||
return this.oaMeetingRoomService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpGroupRobotService getGroupRobotService() {
|
||||
return groupRobotService;
|
||||
|
@ -0,0 +1,51 @@
|
||||
package me.chanjar.weixin.cp.api.impl;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
import me.chanjar.weixin.cp.api.WxCpOaMeetingRoomService;
|
||||
import me.chanjar.weixin.cp.api.WxCpService;
|
||||
|
||||
import me.chanjar.weixin.cp.bean.oa.meetingroom.WxCpOaMeetingRoom;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*;
|
||||
|
||||
/**
|
||||
* @author fcat
|
||||
* @version 1.0
|
||||
* Create by 2022/8/12 23:49
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class WxCpOaMeetingRoomServiceImpl implements WxCpOaMeetingRoomService {
|
||||
private final WxCpService wxCpService;
|
||||
|
||||
@Override
|
||||
public String addMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException {
|
||||
return this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_ADD), meetingRoom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WxCpOaMeetingRoom> listMeetingRoom(WxCpOaMeetingRoom meetingRoomRequest) throws WxErrorException {
|
||||
String response = this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_LIST),
|
||||
meetingRoomRequest);
|
||||
return WxCpGsonBuilder.create().fromJson(GsonParser.parse(response).get("meetingroom_list").getAsJsonArray().toString(),
|
||||
new TypeToken<List<WxCpOaMeetingRoom>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editMeetingRoom(WxCpOaMeetingRoom meetingRoom) throws WxErrorException {
|
||||
this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_EDIT), meetingRoom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMeetingRoom(Integer meetingRoomId) throws WxErrorException {
|
||||
this.wxCpService.post(this.wxCpService.getWxCpConfigStorage().getApiUrl(MEETINGROOM_DEL),
|
||||
GsonHelper.buildJsonObject("meetingroom_id", meetingRoomId));
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package me.chanjar.weixin.cp.bean.oa.meetingroom;
|
||||
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import me.chanjar.weixin.common.bean.ToJson;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fcat
|
||||
* @version 1.0
|
||||
* Create by 2022/8/12 22:46
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class WxCpOaMeetingRoom implements Serializable, ToJson {
|
||||
private static final long serialVersionUID = 2825289798463742532L;
|
||||
/**
|
||||
* 会议室Id
|
||||
*/
|
||||
@SerializedName("meetingroom_id")
|
||||
private Integer meetingroomId;
|
||||
/**
|
||||
* 会议室名称,最多30个字符
|
||||
*/
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
/**
|
||||
* 会议室所能容纳的人数
|
||||
*/
|
||||
@SerializedName("capacity")
|
||||
private Integer capacity;
|
||||
/**
|
||||
* 会议室所在城市
|
||||
*/
|
||||
@SerializedName("city")
|
||||
private String city;
|
||||
/**
|
||||
* 会议室所在楼宇
|
||||
*/
|
||||
@SerializedName("building")
|
||||
private String building;
|
||||
/**
|
||||
* 会议室所在楼层
|
||||
*/
|
||||
@SerializedName("floor")
|
||||
private String floor;
|
||||
/**
|
||||
* 会议室支持的设备列表,参数详细1电视2电话3投影4白板5视频
|
||||
*/
|
||||
@SerializedName("equipment")
|
||||
private List<Integer> equipment;
|
||||
/**
|
||||
* 会议室所在建筑经纬度
|
||||
*/
|
||||
@SerializedName("coordinate")
|
||||
private Coordinate coordinate;
|
||||
/**
|
||||
* 会议室是否需要预定
|
||||
*/
|
||||
@SerializedName("need_approval")
|
||||
private Integer needApproval;
|
||||
|
||||
@Override
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class Coordinate implements Serializable {
|
||||
private static final long serialVersionUID = 6626968559923978694L;
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@SerializedName("latitude")
|
||||
private String latitude;
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@SerializedName("longitude")
|
||||
private String longitude;
|
||||
}
|
||||
}
|
@ -151,6 +151,15 @@ public interface WxCpApiPathConsts {
|
||||
String SCHEDULE_DEL = "/cgi-bin/oa/schedule/del";
|
||||
String SCHEDULE_LIST = "/cgi-bin/oa/schedule/get_by_calendar";
|
||||
|
||||
/**
|
||||
* 会议
|
||||
* https://developer.work.weixin.qq.com/document/path/93624
|
||||
*/
|
||||
String MEETINGROOM_ADD = "/cgi-bin/oa/meetingroom/add";
|
||||
String MEETINGROOM_LIST = "/cgi-bin/oa/meetingroom/list";
|
||||
String MEETINGROOM_EDIT = "/cgi-bin/oa/meetingroom/edit";
|
||||
String MEETINGROOM_DEL = "/cgi-bin/oa/meetingroom/del";
|
||||
|
||||
/**
|
||||
* 微盘
|
||||
* https://developer.work.weixin.qq.com/document/path/93654
|
||||
|
@ -0,0 +1,71 @@
|
||||
package me.chanjar.weixin.cp.api.impl;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.bean.oa.meetingroom.WxCpOaMeetingRoom;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* 单元测试.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* @date 2020-09-20
|
||||
*/
|
||||
|
||||
@Test
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxCpOaMeetingRoomServiceImplTest {
|
||||
@Inject
|
||||
protected WxCpService wxService;
|
||||
|
||||
@Test
|
||||
public void testAdd() throws WxErrorException {
|
||||
this.wxService.getOaMeetingRoomService().addMeetingRoom(WxCpOaMeetingRoom.builder()
|
||||
.building("腾讯大厦")
|
||||
.capacity(10)
|
||||
.city("深圳")
|
||||
.name("18F-会议室")
|
||||
.floor("18F")
|
||||
.equipment(Arrays.asList(1, 2))
|
||||
// .coordinate()
|
||||
.build());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() throws WxErrorException {
|
||||
this.wxService.getOaMeetingRoomService().editMeetingRoom(WxCpOaMeetingRoom.builder()
|
||||
.building("腾讯大厦")
|
||||
.capacity(10)
|
||||
.city("深圳")
|
||||
.name("16F-会议室")
|
||||
.floor("16F")
|
||||
.equipment(Arrays.asList(1, 2, 3))
|
||||
.meetingroomId(1)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet() throws WxErrorException {
|
||||
final List<WxCpOaMeetingRoom> meetingRooms = this.wxService.getOaMeetingRoomService().listMeetingRoom(WxCpOaMeetingRoom.builder()
|
||||
.building("腾讯大厦")
|
||||
.city("深圳")
|
||||
.equipment(Arrays.asList(1, 2))
|
||||
.build());
|
||||
assertThat(meetingRooms).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete() throws WxErrorException {
|
||||
Integer calId = 1;
|
||||
this.wxService.getOaMeetingRoomService().deleteMeetingRoom(calId);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user