Skip to content

Commit 90b705c

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

34 files changed

+3778
-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: 250 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@
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+
import java.util.List;
16+
1317
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*;
1418

1519
/**
16-
* 企业微信微盘接口实现类.
20+
* 企业微信文档接口实现类.
1721
*
18-
* @author Wang_Wong created on 2022-04-22
22+
* @author Wang_Wong created on 2022-04-22
1923
*/
2024
@Slf4j
2125
@RequiredArgsConstructor
@@ -57,11 +61,47 @@ public WxCpDocInfo docInfo(@NonNull String docId) throws WxErrorException {
5761

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

67107
@Override
@@ -86,4 +126,211 @@ public WxCpDocSheetData getSheetRangeData(@NonNull WxCpDocSheetGetDataRequest re
86126
String responseContent = this.cpService.post(apiUrl, request.toJson());
87127
return WxCpDocSheetData.fromJson(responseContent);
88128
}
129+
130+
@Override
131+
public WxCpDocData docGetData(@NonNull WxCpDocGetDataRequest request) throws WxErrorException {
132+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_GET_DOC_DATA);
133+
String responseContent = this.cpService.post(apiUrl, request.toJson());
134+
return WxCpDocData.fromJson(responseContent);
135+
}
136+
137+
@Override
138+
public WxCpBaseResp docModify(@NonNull WxCpDocModifyRequest request) throws WxErrorException {
139+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_MOD_DOC);
140+
String responseContent = this.cpService.post(apiUrl, request.toJson());
141+
return WxCpBaseResp.fromJson(responseContent);
142+
}
143+
144+
@Override
145+
public WxCpDocImageUploadResult docUploadImage(@NonNull File file) throws WxErrorException {
146+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_UPLOAD_DOC_IMAGE);
147+
String responseContent = this.cpService.upload(apiUrl, CommonUploadParam.fromFile("media", file));
148+
return WxCpDocImageUploadResult.fromJson(responseContent);
149+
}
150+
151+
@Override
152+
public WxCpBaseResp docAddAdmin(@NonNull WxCpDocAdminRequest request) throws WxErrorException {
153+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_ADD_ADMIN);
154+
String responseContent = this.cpService.post(apiUrl, request.toJson());
155+
return WxCpBaseResp.fromJson(responseContent);
156+
}
157+
158+
@Override
159+
public WxCpBaseResp docDeleteAdmin(@NonNull WxCpDocAdminRequest request) throws WxErrorException {
160+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_DEL_ADMIN);
161+
String responseContent = this.cpService.post(apiUrl, request.toJson());
162+
return WxCpBaseResp.fromJson(responseContent);
163+
}
164+
165+
@Override
166+
public WxCpDocAdminListResult docGetAdminList(@NonNull String docId) throws WxErrorException {
167+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_GET_ADMIN_LIST);
168+
JsonObject jsonObject = new JsonObject();
169+
jsonObject.addProperty("docid", docId);
170+
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
171+
return WxCpDocAdminListResult.fromJson(responseContent);
172+
}
173+
174+
@Override
175+
public WxCpDocSmartSheetAuth smartSheetGetAuth(@NonNull WxCpDocSmartSheetAuthRequest request) throws WxErrorException {
176+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_GET_SHEET_AUTH);
177+
String responseContent = this.cpService.post(apiUrl, request.toJson());
178+
return WxCpDocSmartSheetAuth.fromJson(responseContent);
179+
}
180+
181+
@Override
182+
public WxCpBaseResp smartSheetModifyAuth(@NonNull WxCpDocSmartSheetModifyAuthRequest request) throws WxErrorException {
183+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_MOD_SHEET_AUTH);
184+
String responseContent = this.cpService.post(apiUrl, request.toJson());
185+
return WxCpBaseResp.fromJson(responseContent);
186+
}
187+
188+
@Override
189+
public WxCpDocSmartSheetResult smartSheetGetSheet(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
190+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_GET_SHEET);
191+
String responseContent = this.cpService.post(apiUrl, request.toJson());
192+
return WxCpDocSmartSheetResult.fromJson(responseContent);
193+
}
194+
195+
@Override
196+
public WxCpDocSmartSheetResult smartSheetAddSheet(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
197+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_ADD_SHEET);
198+
String responseContent = this.cpService.post(apiUrl, request.toJson());
199+
return WxCpDocSmartSheetResult.fromJson(responseContent);
200+
}
201+
202+
@Override
203+
public WxCpBaseResp smartSheetDeleteSheet(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
204+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_DELETE_SHEET);
205+
String responseContent = this.cpService.post(apiUrl, request.toJson());
206+
return WxCpBaseResp.fromJson(responseContent);
207+
}
208+
209+
@Override
210+
public WxCpBaseResp smartSheetUpdateSheet(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
211+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_UPDATE_SHEET);
212+
String responseContent = this.cpService.post(apiUrl, request.toJson());
213+
return WxCpBaseResp.fromJson(responseContent);
214+
}
215+
216+
@Override
217+
public WxCpDocSmartSheetResult smartSheetGetViews(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
218+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_GET_VIEWS);
219+
String responseContent = this.cpService.post(apiUrl, request.toJson());
220+
return WxCpDocSmartSheetResult.fromJson(responseContent);
221+
}
222+
223+
@Override
224+
public WxCpDocSmartSheetResult smartSheetAddView(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
225+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_ADD_VIEW);
226+
String responseContent = this.cpService.post(apiUrl, request.toJson());
227+
return WxCpDocSmartSheetResult.fromJson(responseContent);
228+
}
229+
230+
@Override
231+
public WxCpBaseResp smartSheetDeleteViews(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
232+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_DELETE_VIEWS);
233+
String responseContent = this.cpService.post(apiUrl, request.toJson());
234+
return WxCpBaseResp.fromJson(responseContent);
235+
}
236+
237+
@Override
238+
public WxCpBaseResp smartSheetUpdateView(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
239+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_UPDATE_VIEW);
240+
String responseContent = this.cpService.post(apiUrl, request.toJson());
241+
return WxCpBaseResp.fromJson(responseContent);
242+
}
243+
244+
@Override
245+
public WxCpDocSmartSheetResult smartSheetGetFields(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
246+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_GET_FIELDS);
247+
String responseContent = this.cpService.post(apiUrl, request.toJson());
248+
return WxCpDocSmartSheetResult.fromJson(responseContent);
249+
}
250+
251+
@Override
252+
public WxCpDocSmartSheetResult smartSheetAddFields(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
253+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_ADD_FIELDS);
254+
String responseContent = this.cpService.post(apiUrl, request.toJson());
255+
return WxCpDocSmartSheetResult.fromJson(responseContent);
256+
}
257+
258+
@Override
259+
public WxCpBaseResp smartSheetDeleteFields(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
260+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_DELETE_FIELDS);
261+
String responseContent = this.cpService.post(apiUrl, request.toJson());
262+
return WxCpBaseResp.fromJson(responseContent);
263+
}
264+
265+
@Override
266+
public WxCpBaseResp smartSheetUpdateFields(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
267+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_UPDATE_FIELDS);
268+
String responseContent = this.cpService.post(apiUrl, request.toJson());
269+
return WxCpBaseResp.fromJson(responseContent);
270+
}
271+
272+
@Override
273+
public WxCpDocSmartSheetResult smartSheetGetRecords(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
274+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_GET_RECORDS);
275+
String responseContent = this.cpService.post(apiUrl, request.toJson());
276+
return WxCpDocSmartSheetResult.fromJson(responseContent);
277+
}
278+
279+
@Override
280+
public WxCpDocSmartSheetResult smartSheetAddRecords(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
281+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_ADD_RECORDS);
282+
String responseContent = this.cpService.post(apiUrl, request.toJson());
283+
return WxCpDocSmartSheetResult.fromJson(responseContent);
284+
}
285+
286+
@Override
287+
public WxCpBaseResp smartSheetDeleteRecords(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
288+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_DELETE_RECORDS);
289+
String responseContent = this.cpService.post(apiUrl, request.toJson());
290+
return WxCpBaseResp.fromJson(responseContent);
291+
}
292+
293+
@Override
294+
public WxCpBaseResp smartSheetUpdateRecords(@NonNull WxCpDocSmartSheetRequest request) throws WxErrorException {
295+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_SMARTSHEET_UPDATE_RECORDS);
296+
String responseContent = this.cpService.post(apiUrl, request.toJson());
297+
return WxCpBaseResp.fromJson(responseContent);
298+
}
299+
300+
@Override
301+
public WxCpFormCreateResult formCreate(@NonNull WxCpFormCreateRequest request) throws WxErrorException {
302+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_CREATE_FORM);
303+
String responseContent = this.cpService.post(apiUrl, request.toJson());
304+
return WxCpFormCreateResult.fromJson(responseContent);
305+
}
306+
307+
@Override
308+
public WxCpBaseResp formModify(@NonNull WxCpFormModifyRequest request) throws WxErrorException {
309+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_MODIFY_FORM);
310+
String responseContent = this.cpService.post(apiUrl, request.toJson());
311+
return WxCpBaseResp.fromJson(responseContent);
312+
}
313+
314+
@Override
315+
public WxCpFormInfoResult formInfo(@NonNull String formId) throws WxErrorException {
316+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_GET_FORM_INFO);
317+
JsonObject jsonObject = new JsonObject();
318+
jsonObject.addProperty("formid", formId);
319+
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
320+
return WxCpFormInfoResult.fromJson(responseContent);
321+
}
322+
323+
@Override
324+
public WxCpFormStatisticResult formStatistic(@NonNull List<WxCpFormStatisticRequest> requests) throws WxErrorException {
325+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_GET_FORM_STATISTIC);
326+
String responseContent = this.cpService.post(apiUrl, WxCpFormStatisticRequest.toJson(requests));
327+
return WxCpFormStatisticResult.fromJson(responseContent);
328+
}
329+
330+
@Override
331+
public WxCpFormAnswer formAnswer(@NonNull WxCpFormAnswerRequest request) throws WxErrorException {
332+
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(WEDOC_GET_FORM_ANSWER);
333+
String responseContent = this.cpService.post(apiUrl, request.toJson());
334+
return WxCpFormAnswer.fromJson(responseContent);
335+
}
89336
}
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)