Skip to content

Commit 29fd94e

Browse files
authored
🎨 #3926 【企业微信】增加 OA 效率工具(WeDoc)相关能力的支持
1 parent 4b2383c commit 29fd94e

34 files changed

+3777
-3
lines changed

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

Lines changed: 413 additions & 0 deletions
Large diffs are not rendered by default.

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
@@ -481,6 +481,13 @@ public interface WxCpService extends WxService {
481481
*/
482482
WxCpOaWeDriveService getOaWeDriveService();
483483

484+
/**
485+
* 获取OA效率工具 文档的服务类对象
486+
*
487+
* @return oa we doc service
488+
*/
489+
WxCpOaWeDocService getOaWeDocService();
490+
484491
/**
485492
* 获取会话存档相关接口的服务类对象
486493
*

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
5959
private final WxCpLivingService livingService = new WxCpLivingServiceImpl(this);
6060
private final WxCpOaAgentService oaAgentService = new WxCpOaAgentServiceImpl(this);
6161
private final WxCpOaWeDriveService oaWeDriveService = new WxCpOaWeDriveServiceImpl(this);
62+
private final WxCpOaWeDocService oaWeDocService = new WxCpOaWeDocServiceImpl(this);
6263
private final WxCpMsgAuditService msgAuditService = new WxCpMsgAuditServiceImpl(this);
6364
private final WxCpTaskCardService taskCardService = new WxCpTaskCardServiceImpl(this);
6465
private final WxCpExternalContactService externalContactService = new WxCpExternalContactServiceImpl(this);
@@ -595,6 +596,11 @@ public WxCpOaWeDriveService getOaWeDriveService() {
595596
return oaWeDriveService;
596597
}
597598

599+
@Override
600+
public WxCpOaWeDocService getOaWeDocService() {
601+
return oaWeDocService;
602+
}
603+
598604
@Override
599605
public WxCpMsgAuditService getMsgAuditService() {
600606
return msgAuditService;

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

Lines changed: 249 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44
import lombok.NonNull;
55
import lombok.RequiredArgsConstructor;
66
import lombok.extern.slf4j.Slf4j;
7+
import me.chanjar.weixin.common.bean.CommonUploadParam;
78
import me.chanjar.weixin.common.error.WxErrorException;
89
import me.chanjar.weixin.cp.api.WxCpOaWeDocService;
910
import me.chanjar.weixin.cp.api.WxCpService;
1011
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
1112
import me.chanjar.weixin.cp.bean.oa.doc.*;
1213

14+
import java.io.File;
15+
1316
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*;
1417

1518
/**
16-
* 企业微信微盘接口实现类.
19+
* 企业微信文档接口实现类.
1720
*
18-
* @author Wang_Wong created on 2022-04-22
21+
* @author Wang_Wong created on 2022-04-22
1922
*/
2023
@Slf4j
2124
@RequiredArgsConstructor
@@ -57,11 +60,47 @@ public WxCpDocInfo docInfo(@NonNull String docId) throws WxErrorException {
5760

5861
@Override
5962
public WxCpDocShare docShare(@NonNull String docId) throws WxErrorException {
63+
return docShare(WxCpDocShareRequest.builder().docId(docId).build());
64+
}
65+
66+
@Override
67+
public WxCpDocShare docShare(@NonNull WxCpDocShareRequest request) throws WxErrorException {
6068
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_DOC_SHARE);
69+
String responseContent = this.cpService.post(apiUrl, request.toJson());
70+
return WxCpDocShare.fromJson(responseContent);
71+
}
72+
73+
@Override
74+
public WxCpDocAuthInfo docGetAuth(@NonNull String docId) throws WxErrorException {
75+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_DOC_GET_AUTH);
6176
JsonObject jsonObject = new JsonObject();
6277
jsonObject.addProperty("docid", docId);
6378
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
64-
return WxCpDocShare.fromJson(responseContent);
79+
return WxCpDocAuthInfo.fromJson(responseContent);
80+
}
81+
82+
@Override
83+
public WxCpBaseResp docModifyJoinRule(@NonNull WxCpDocModifyJoinRuleRequest request) throws WxErrorException {
84+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_MOD_DOC_JOIN_RULE);
85+
String responseContent = this.cpService.post(apiUrl, request.toJson());
86+
return WxCpBaseResp.fromJson(responseContent);
87+
}
88+
89+
@Override
90+
public WxCpBaseResp docModifyMember(@NonNull WxCpDocModifyMemberRequest request) throws WxErrorException {
91+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_MOD_DOC_MEMBER);
92+
String responseContent = this.cpService.post(apiUrl, request.toJson());
93+
return WxCpBaseResp.fromJson(responseContent);
94+
}
95+
96+
@Override
97+
public WxCpBaseResp docModifySafetySetting(
98+
@NonNull WxCpDocModifySafetySettingRequest request
99+
) throws WxErrorException {
100+
String apiUrl = this.cpService.getWxCpConfigStorage()
101+
.getApiUrl(WEDOC_MOD_DOC_SAFETY_SETTING);
102+
String responseContent = this.cpService.post(apiUrl, request.toJson());
103+
return WxCpBaseResp.fromJson(responseContent);
65104
}
66105

67106
@Override
@@ -86,4 +125,211 @@ public WxCpDocSheetData getSheetRangeData(@NonNull WxCpDocSheetGetDataRequest re
86125
String responseContent = this.cpService.post(apiUrl, request.toJson());
87126
return WxCpDocSheetData.fromJson(responseContent);
88127
}
128+
129+
@Override
130+
public WxCpDocData docGetData(@NonNull WxCpDocGetDataRequest request) throws WxErrorException {
131+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_GET_DOC_DATA);
132+
String responseContent = this.cpService.post(apiUrl, request.toJson());
133+
return WxCpDocData.fromJson(responseContent);
134+
}
135+
136+
@Override
137+
public WxCpBaseResp docModify(@NonNull WxCpDocModifyRequest request) throws WxErrorException {
138+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_MOD_DOC);
139+
String responseContent = this.cpService.post(apiUrl, request.toJson());
140+
return WxCpBaseResp.fromJson(responseContent);
141+
}
142+
143+
@Override
144+
public WxCpDocImageUploadResult docUploadImage(@NonNull File file) throws WxErrorException {
145+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_UPLOAD_DOC_IMAGE);
146+
String responseContent = this.cpService.upload(apiUrl, CommonUploadParam.fromFile("media", file));
147+
return WxCpDocImageUploadResult.fromJson(responseContent);
148+
}
149+
150+
@Override
151+
public WxCpBaseResp docAddAdmin(@NonNull WxCpDocAdminRequest request) throws WxErrorException {
152+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_ADD_ADMIN);
153+
String responseContent = this.cpService.post(apiUrl, request.toJson());
154+
return WxCpBaseResp.fromJson(responseContent);
155+
}
156+
157+
@Override
158+
public WxCpBaseResp docDeleteAdmin(@NonNull WxCpDocAdminRequest request) throws WxErrorException {
159+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_DEL_ADMIN);
160+
String responseContent = this.cpService.post(apiUrl, request.toJson());
161+
return WxCpBaseResp.fromJson(responseContent);
162+
}
163+
164+
@Override
165+
public WxCpDocAdminListResult docGetAdminList(@NonNull String docId) throws WxErrorException {
166+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_GET_ADMIN_LIST);
167+
JsonObject jsonObject = new JsonObject();
168+
jsonObject.addProperty("docid", docId);
169+
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
170+
return WxCpDocAdminListResult.fromJson(responseContent);
171+
}
172+
173+
@Override
174+
public WxCpDocSmartSheetAuth smartSheetGetAuth(@NonNull WxCpDocSmartSheetAuthRequest request) throws WxErrorException {
175+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_GET_SHEET_AUTH);
176+
String responseContent = this.cpService.post(apiUrl, request.toJson());
177+
return WxCpDocSmartSheetAuth.fromJson(responseContent);
178+
}
179+
180+
@Override
181+
public WxCpBaseResp smartSheetModifyAuth(@NonNull WxCpDocSmartSheetModifyAuthRequest request) throws WxErrorException {
182+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_MOD_SHEET_AUTH);
183+
String responseContent = this.cpService.post(apiUrl, request.toJson());
184+
return WxCpBaseResp.fromJson(responseContent);
185+
}
186+
187+
@Override
188+
public WxCpDocSmartSheetResult smartSheetGetSheet(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
189+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_GET_SHEET);
190+
String responseContent = this.cpService.post(apiUrl, request.toJson());
191+
return WxCpDocSmartSheetResult.fromJson(responseContent);
192+
}
193+
194+
@Override
195+
public WxCpDocSmartSheetResult smartSheetAddSheet(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
196+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_ADD_SHEET);
197+
String responseContent = this.cpService.post(apiUrl, request.toJson());
198+
return WxCpDocSmartSheetResult.fromJson(responseContent);
199+
}
200+
201+
@Override
202+
public WxCpBaseResp smartSheetDeleteSheet(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
203+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_DELETE_SHEET);
204+
String responseContent = this.cpService.post(apiUrl, request.toJson());
205+
return WxCpBaseResp.fromJson(responseContent);
206+
}
207+
208+
@Override
209+
public WxCpBaseResp smartSheetUpdateSheet(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
210+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_UPDATE_SHEET);
211+
String responseContent = this.cpService.post(apiUrl, request.toJson());
212+
return WxCpBaseResp.fromJson(responseContent);
213+
}
214+
215+
@Override
216+
public WxCpDocSmartSheetResult smartSheetGetViews(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
217+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_GET_VIEWS);
218+
String responseContent = this.cpService.post(apiUrl, request.toJson());
219+
return WxCpDocSmartSheetResult.fromJson(responseContent);
220+
}
221+
222+
@Override
223+
public WxCpDocSmartSheetResult smartSheetAddView(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
224+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_ADD_VIEW);
225+
String responseContent = this.cpService.post(apiUrl, request.toJson());
226+
return WxCpDocSmartSheetResult.fromJson(responseContent);
227+
}
228+
229+
@Override
230+
public WxCpBaseResp smartSheetDeleteViews(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
231+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_DELETE_VIEWS);
232+
String responseContent = this.cpService.post(apiUrl, request.toJson());
233+
return WxCpBaseResp.fromJson(responseContent);
234+
}
235+
236+
@Override
237+
public WxCpBaseResp smartSheetUpdateView(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
238+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_UPDATE_VIEW);
239+
String responseContent = this.cpService.post(apiUrl, request.toJson());
240+
return WxCpBaseResp.fromJson(responseContent);
241+
}
242+
243+
@Override
244+
public WxCpDocSmartSheetResult smartSheetGetFields(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
245+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_GET_FIELDS);
246+
String responseContent = this.cpService.post(apiUrl, request.toJson());
247+
return WxCpDocSmartSheetResult.fromJson(responseContent);
248+
}
249+
250+
@Override
251+
public WxCpDocSmartSheetResult smartSheetAddFields(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
252+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_ADD_FIELDS);
253+
String responseContent = this.cpService.post(apiUrl, request.toJson());
254+
return WxCpDocSmartSheetResult.fromJson(responseContent);
255+
}
256+
257+
@Override
258+
public WxCpBaseResp smartSheetDeleteFields(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
259+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_DELETE_FIELDS);
260+
String responseContent = this.cpService.post(apiUrl, request.toJson());
261+
return WxCpBaseResp.fromJson(responseContent);
262+
}
263+
264+
@Override
265+
public WxCpBaseResp smartSheetUpdateFields(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
266+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_UPDATE_FIELDS);
267+
String responseContent = this.cpService.post(apiUrl, request.toJson());
268+
return WxCpBaseResp.fromJson(responseContent);
269+
}
270+
271+
@Override
272+
public WxCpDocSmartSheetResult smartSheetGetRecords(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
273+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_GET_RECORDS);
274+
String responseContent = this.cpService.post(apiUrl, request.toJson());
275+
return WxCpDocSmartSheetResult.fromJson(responseContent);
276+
}
277+
278+
@Override
279+
public WxCpDocSmartSheetResult smartSheetAddRecords(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
280+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_ADD_RECORDS);
281+
String responseContent = this.cpService.post(apiUrl, request.toJson());
282+
return WxCpDocSmartSheetResult.fromJson(responseContent);
283+
}
284+
285+
@Override
286+
public WxCpBaseResp smartSheetDeleteRecords(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
287+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_DELETE_RECORDS);
288+
String responseContent = this.cpService.post(apiUrl, request.toJson());
289+
return WxCpBaseResp.fromJson(responseContent);
290+
}
291+
292+
@Override
293+
public WxCpBaseResp smartSheetUpdateRecords(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
294+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_UPDATE_RECORDS);
295+
String responseContent = this.cpService.post(apiUrl, request.toJson());
296+
return WxCpBaseResp.fromJson(responseContent);
297+
}
298+
299+
@Override
300+
public WxCpFormCreateResult formCreate(@NonNull WxCpFormCreateRequest request) throws WxErrorException {
301+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_CREATE_FORM);
302+
String responseContent = this.cpService.post(apiUrl, request.toJson());
303+
return WxCpFormCreateResult.fromJson(responseContent);
304+
}
305+
306+
@Override
307+
public WxCpBaseResp formModify(@NonNull WxCpFormModifyRequest request) throws WxErrorException {
308+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_MODIFY_FORM);
309+
String responseContent = this.cpService.post(apiUrl, request.toJson());
310+
return WxCpBaseResp.fromJson(responseContent);
311+
}
312+
313+
@Override
314+
public WxCpFormInfoResult formInfo(@NonNull String formId) throws WxErrorException {
315+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_GET_FORM_INFO);
316+
JsonObject jsonObject = new JsonObject();
317+
jsonObject.addProperty("formid", formId);
318+
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
319+
return WxCpFormInfoResult.fromJson(responseContent);
320+
}
321+
322+
@Override
323+
public WxCpFormStatisticResult formStatistic(@NonNull List<WxCpFormStatisticRequest> requests) throws WxErrorException {
324+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_GET_FORM_STATISTIC);
325+
String responseContent = this.cpService.post(apiUrl, WxCpFormStatisticRequest.toJson(requests));
326+
return WxCpFormStatisticResult.fromJson(responseContent);
327+
}
328+
329+
@Override
330+
public WxCpFormAnswer formAnswer(@NonNull WxCpFormAnswerRequest request) throws WxErrorException {
331+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_GET_FORM_ANSWER);
332+
String responseContent = this.cpService.post(apiUrl, request.toJson());
333+
return WxCpFormAnswer.fromJson(responseContent);
334+
}
89335
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package me.chanjar.weixin.cp.bean.oa.doc;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import lombok.Getter;
7+
import lombok.Setter;
8+
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
9+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
10+
11+
import java.io.Serializable;
12+
import java.util.List;
13+
14+
/**
15+
* 文档高级功能账号列表.
16+
*/
17+
@Data
18+
@EqualsAndHashCode(callSuper = true)
19+
public class WxCpDocAdminListResult extends WxCpBaseResp implements Serializable {
20+
private static final long serialVersionUID = 6293762486917512845L;
21+
22+
@SerializedName("docid")
23+
private String docId;
24+
25+
@SerializedName("admin_list")
26+
private List<Admin> adminList;
27+
28+
public static WxCpDocAdminListResult fromJson(String json) {
29+
return WxCpGsonBuilder.create().fromJson(json, WxCpDocAdminListResult.class);
30+
}
31+
32+
@Override
33+
public String toJson() {
34+
return WxCpGsonBuilder.create().toJson(this);
35+
}
36+
37+
@Getter
38+
@Setter
39+
public static class Admin implements Serializable {
40+
private static final long serialVersionUID = -4984807259145367427L;
41+
42+
@SerializedName("userid")
43+
private String userId;
44+
45+
@SerializedName("open_userid")
46+
private String openUserId;
47+
48+
@SerializedName("type")
49+
private Integer type;
50+
}
51+
}

0 commit comments

Comments
 (0)