forked from chanjarster/weixin-java-tools
-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
314 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaMeetingRoomService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaMeetingRoomServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/meetingroom/WxCpOaMeetingRoom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaMeetingRoomServiceImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |