44import lombok .NonNull ;
55import lombok .RequiredArgsConstructor ;
66import lombok .extern .slf4j .Slf4j ;
7+ import me .chanjar .weixin .common .bean .CommonUploadParam ;
78import me .chanjar .weixin .common .error .WxErrorException ;
89import me .chanjar .weixin .cp .api .WxCpOaWeDocService ;
910import me .chanjar .weixin .cp .api .WxCpService ;
1011import me .chanjar .weixin .cp .bean .WxCpBaseResp ;
1112import me .chanjar .weixin .cp .bean .oa .doc .*;
1213
14+ import java .io .File ;
15+ import java .util .List ;
16+
1317import 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}
0 commit comments