2
2
3
3
import com .google .gson .Gson ;
4
4
import com .google .gson .JsonObject ;
5
+
5
6
import java .io .File ;
6
7
import java .io .IOException ;
7
8
import java .io .InputStream ;
8
9
import java .util .UUID ;
10
+
9
11
import lombok .NonNull ;
10
12
import lombok .RequiredArgsConstructor ;
11
13
import me .chanjar .weixin .common .bean .result .WxMediaUploadResult ;
@@ -111,7 +113,7 @@ public WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorE
111
113
@ Override
112
114
public WxCpExternalContactInfo getContactDetail (String userId , String cursor ) throws WxErrorException {
113
115
String params = userId ;
114
- if (StringUtils .isNotEmpty (cursor )){
116
+ if (StringUtils .isNotEmpty (cursor )) {
115
117
params = params + "&cursor=" + cursor ;
116
118
}
117
119
final String url = this .mainService .getWxCpConfigStorage ().getApiUrl (GET_CONTACT_DETAIL + params );
@@ -130,11 +132,11 @@ public String convertToOpenid(@NotNull String externalUserId) throws WxErrorExce
130
132
}
131
133
132
134
@ Override
133
- public String unionidToExternalUserid (@ NotNull String unionid ,String openid ) throws WxErrorException {
135
+ public String unionidToExternalUserid (@ NotNull String unionid , String openid ) throws WxErrorException {
134
136
JsonObject json = new JsonObject ();
135
137
json .addProperty ("unionid" , unionid );
136
- if (StringUtils .isNotEmpty (openid )){
137
- json .addProperty ("openid" ,openid );
138
+ if (StringUtils .isNotEmpty (openid )) {
139
+ json .addProperty ("openid" , openid );
138
140
}
139
141
final String url = this .mainService .getWxCpConfigStorage ().getApiUrl (UNIONID_TO_EXTERNAL_USERID );
140
142
String responseContent = this .mainService .post (url , json .toString ());
@@ -157,8 +159,8 @@ public WxCpExternalUserIdList unionidToExternalUserid3rd(@NotNull String unionid
157
159
JsonObject json = new JsonObject ();
158
160
json .addProperty ("unionid" , unionid );
159
161
json .addProperty ("openid" , openid );
160
- if (StringUtils .isNotEmpty (corpid )){
161
- json .addProperty ("corpid" ,corpid );
162
+ if (StringUtils .isNotEmpty (corpid )) {
163
+ json .addProperty ("corpid" , corpid );
162
164
}
163
165
final String url = this .mainService .getWxCpConfigStorage ().getApiUrl (UNIONID_TO_EXTERNAL_USERID_3RD );
164
166
String responseContent = this .mainService .post (url , json .toString ());
@@ -188,7 +190,7 @@ public WxCpBaseResp finishExternalUserIdMigration(@NotNull String corpid) throws
188
190
@ Override
189
191
public String opengidToChatid (@ NotNull String opengid ) throws WxErrorException {
190
192
JsonObject json = new JsonObject ();
191
- json .addProperty ("opengid" ,opengid );
193
+ json .addProperty ("opengid" , opengid );
192
194
final String url = this .mainService .getWxCpConfigStorage ().getApiUrl (OPENID_TO_CHATID );
193
195
String responseContent = this .mainService .post (url , json .toString ());
194
196
JsonObject tmpJson = GsonParser .parse (responseContent );
@@ -247,7 +249,7 @@ public List<String> listFollowers() throws WxErrorException {
247
249
@ Override
248
250
public WxCpUserExternalUnassignList listUnassignedList (Integer pageIndex , String cursor , Integer pageSize ) throws WxErrorException {
249
251
JsonObject json = new JsonObject ();
250
- if (pageIndex != null ){
252
+ if (pageIndex != null ) {
251
253
json .addProperty ("page_id" , pageIndex );
252
254
}
253
255
json .addProperty ("cursor" , StringUtils .isEmpty (cursor ) ? "" : cursor );
@@ -518,20 +520,20 @@ public WxCpGetMomentTaskResult getMomentTaskResult(String jobId) throws WxErrorE
518
520
519
521
@ Override
520
522
public WxCpGetMomentList getMomentList (Long startTime , Long endTime , String creator , Integer filterType ,
521
- String cursor , Integer limit ) throws WxErrorException {
523
+ String cursor , Integer limit ) throws WxErrorException {
522
524
JsonObject json = new JsonObject ();
523
525
json .addProperty ("start_time" , startTime );
524
526
json .addProperty ("end_time" , endTime );
525
527
if (!StringUtils .isEmpty (creator )) {
526
528
json .addProperty ("creator" , creator );
527
529
}
528
- if (filterType != null ) {
530
+ if (filterType != null ) {
529
531
json .addProperty ("filter_type" , filterType );
530
532
}
531
533
if (!StringUtils .isEmpty (cursor )) {
532
534
json .addProperty ("cursor" , cursor );
533
535
}
534
- if (limit != null ) {
536
+ if (limit != null ) {
535
537
json .addProperty ("limit" , limit );
536
538
}
537
539
final String url = this .mainService .getWxCpConfigStorage ().getApiUrl (GET_MOMENT_LIST );
@@ -547,7 +549,7 @@ public WxCpGetMomentTask getMomentTask(String momentId, String cursor, Integer l
547
549
if (!StringUtils .isEmpty (cursor )) {
548
550
json .addProperty ("cursor" , cursor );
549
551
}
550
- if (limit != null ) {
552
+ if (limit != null ) {
551
553
json .addProperty ("limit" , limit );
552
554
}
553
555
final String url = this .mainService .getWxCpConfigStorage ().getApiUrl (GET_MOMENT_TASK );
@@ -557,14 +559,14 @@ public WxCpGetMomentTask getMomentTask(String momentId, String cursor, Integer l
557
559
558
560
@ Override
559
561
public WxCpGetMomentCustomerList getMomentCustomerList (String momentId , String userId ,
560
- String cursor , Integer limit ) throws WxErrorException {
562
+ String cursor , Integer limit ) throws WxErrorException {
561
563
JsonObject json = new JsonObject ();
562
564
json .addProperty ("moment_id" , momentId );
563
565
json .addProperty ("userid" , userId );
564
566
if (!StringUtils .isEmpty (cursor )) {
565
567
json .addProperty ("cursor" , cursor );
566
568
}
567
- if (limit != null ) {
569
+ if (limit != null ) {
568
570
json .addProperty ("limit" , limit );
569
571
}
570
572
final String url = this .mainService .getWxCpConfigStorage ().getApiUrl (GET_MOMENT_CUSTOMER_LIST );
@@ -574,14 +576,14 @@ public WxCpGetMomentCustomerList getMomentCustomerList(String momentId, String u
574
576
575
577
@ Override
576
578
public WxCpGetMomentSendResult getMomentSendResult (String momentId , String userId ,
577
- String cursor , Integer limit ) throws WxErrorException {
579
+ String cursor , Integer limit ) throws WxErrorException {
578
580
JsonObject json = new JsonObject ();
579
581
json .addProperty ("moment_id" , momentId );
580
582
json .addProperty ("userid" , userId );
581
583
if (!StringUtils .isEmpty (cursor )) {
582
584
json .addProperty ("cursor" , cursor );
583
585
}
584
- if (limit != null ) {
586
+ if (limit != null ) {
585
587
json .addProperty ("limit" , limit );
586
588
}
587
589
final String url = this .mainService .getWxCpConfigStorage ().getApiUrl (GET_MOMENT_SEND_RESULT );
@@ -790,8 +792,8 @@ public WxCpBaseResp delGroupWelcomeTemplate(@NotNull String templateId, String a
790
792
* https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册列表
791
793
* </pre>
792
794
*
793
- * @param limit 返回的最大记录数,整型,最大值100,默认值50,超过最大值时取默认值
794
- * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
795
+ * @param limit 返回的最大记录数,整型,最大值100,默认值50,超过最大值时取默认值
796
+ * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
795
797
* @return wx cp base resp
796
798
* @throws WxErrorException the wx error exception
797
799
*/
@@ -811,7 +813,7 @@ public WxCpProductAlbumListResult getProductAlbumList(Integer limit, String curs
811
813
* https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册
812
814
* </pre>
813
815
*
814
- * @param productId 商品id
816
+ * @param productId 商品id
815
817
* @return wx cp base resp
816
818
* @throws WxErrorException the wx error exception
817
819
*/
@@ -826,7 +828,7 @@ public WxCpProductAlbumResult getProductAlbum(String productId) throws WxErrorEx
826
828
827
829
@ Override
828
830
public WxMediaUploadResult uploadAttachment (String mediaType , String fileType , Integer attachmentType ,
829
- InputStream inputStream ) throws WxErrorException , IOException {
831
+ InputStream inputStream ) throws WxErrorException , IOException {
830
832
return uploadAttachment (mediaType , attachmentType , FileUtils .createTmpFile (inputStream ,
831
833
UUID .randomUUID ().toString (), fileType ));
832
834
}
@@ -839,4 +841,26 @@ public WxMediaUploadResult uploadAttachment(String mediaType, Integer attachment
839
841
return this .mainService .execute (MediaUploadRequestExecutor .create (
840
842
this .mainService .getRequestHttp ()), url , file );
841
843
}
844
+
845
+ @ Override
846
+ public WxCpInterceptRuleResultResp addInterceptRule (WxCpInterceptRuleResp ruleResp ) throws WxErrorException {
847
+ return WxCpInterceptRuleResultResp
848
+ .fromJson (this .mainService .post (this .mainService .getWxCpConfigStorage ().getApiUrl (ADD_INTERCEPT_RULE ), ruleResp .toJson ()));
849
+ }
850
+
851
+ @ Override
852
+ public WxCpInterceptRuleResultResp updateInterceptRule (WxCpInterceptRuleResp ruleResp ) throws WxErrorException {
853
+ return WxCpInterceptRuleResultResp
854
+ .fromJson (this .mainService .post (this .mainService .getWxCpConfigStorage ().getApiUrl (UPDATE_INTERCEPT_RULE ), ruleResp .toJson ()));
855
+ }
856
+
857
+ @ Override
858
+ public WxCpBaseResp delInterceptRule (String rule_id ) throws WxErrorException {
859
+ JsonObject jsonObject = new JsonObject ();
860
+ jsonObject .addProperty ("rule_id" ,rule_id );
861
+ return WxCpBaseResp
862
+ .fromJson (this .mainService .post (this .mainService .getWxCpConfigStorage ().getApiUrl (DEL_INTERCEPT_RULE ), jsonObject ));
863
+ }
864
+
865
+
842
866
}
0 commit comments