2
2
3
3
import cn .binarywang .wx .miniapp .api .WxMaSecCheckService ;
4
4
import cn .binarywang .wx .miniapp .api .WxMaService ;
5
+ import cn .binarywang .wx .miniapp .bean .WxMaMediaAsyncCheckResult ;
5
6
import com .google .gson .JsonObject ;
7
+ import java .io .File ;
6
8
import lombok .AllArgsConstructor ;
7
9
import me .chanjar .weixin .common .bean .result .WxMediaUploadResult ;
8
10
import me .chanjar .weixin .common .error .WxErrorException ;
9
11
import me .chanjar .weixin .common .util .http .MediaUploadRequestExecutor ;
10
12
11
- import java .io .File ;
12
-
13
13
/**
14
14
* <pre>
15
15
*
20
20
*/
21
21
@ AllArgsConstructor
22
22
public class WxMaSecCheckServiceImpl implements WxMaSecCheckService {
23
+
23
24
private WxMaService service ;
24
25
25
26
@ Override
@@ -31,16 +32,24 @@ public boolean checkImage(File file) throws WxErrorException {
31
32
}
32
33
33
34
@ Override
34
- public boolean checkMessage (String msgString ) {
35
+ public boolean checkMessage (String msgString ) throws WxErrorException {
35
36
JsonObject jsonObject = new JsonObject ();
36
37
jsonObject .addProperty ("content" , msgString );
37
- try {
38
- this .service .post (MSG_SEC_CHECK_URL , jsonObject .toString ());
39
- } catch (WxErrorException e ) {
40
- return false ;
41
- }
38
+
39
+ this .service .post (MSG_SEC_CHECK_URL , jsonObject .toString ());
42
40
43
41
return true ;
44
42
}
45
43
44
+ @ Override
45
+ public WxMaMediaAsyncCheckResult mediaCheckAsync (String mediaUrl , int mediaType )
46
+ throws WxErrorException {
47
+ JsonObject jsonObject = new JsonObject ();
48
+ jsonObject .addProperty ("media_url" , mediaUrl );
49
+ jsonObject .addProperty ("media_type" , mediaType );
50
+
51
+ return WxMaMediaAsyncCheckResult
52
+ .fromJson (this .service .post (MEDIA_CHECK_ASYNC_URL , jsonObject .toString ()));
53
+ }
54
+
46
55
}
0 commit comments