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+
1316import 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}
0 commit comments