1
1
package me .chanjar .weixin .mp .api .impl ;
2
2
3
+ import java .util .List ;
4
+
3
5
import com .google .gson .JsonObject ;
4
6
import me .chanjar .weixin .common .error .WxErrorException ;
5
7
import me .chanjar .weixin .mp .api .WxMpService ;
8
10
import me .chanjar .weixin .mp .bean .result .WxMpUser ;
9
11
import me .chanjar .weixin .mp .bean .result .WxMpUserList ;
10
12
11
- import java .util .List ;
12
-
13
13
/**
14
14
* Created by Binary Wang on 2016/7/21.
15
+ *
16
+ * @author BinaryWang
15
17
*/
16
18
public class WxMpUserServiceImpl implements WxMpUserService {
17
- private static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/user" ;
18
19
private WxMpService wxMpService ;
19
20
20
21
public WxMpUserServiceImpl (WxMpService wxMpService ) {
@@ -23,11 +24,10 @@ public WxMpUserServiceImpl(WxMpService wxMpService) {
23
24
24
25
@ Override
25
26
public void userUpdateRemark (String openid , String remark ) throws WxErrorException {
26
- String url = API_URL_PREFIX + "/info/updateremark" ;
27
27
JsonObject json = new JsonObject ();
28
28
json .addProperty ("openid" , openid );
29
29
json .addProperty ("remark" , remark );
30
- this .wxMpService .post (url , json .toString ());
30
+ this .wxMpService .post (USER_INFO_UPDATE_REMARK_URL , json .toString ());
31
31
}
32
32
33
33
@ Override
@@ -37,32 +37,28 @@ public WxMpUser userInfo(String openid) throws WxErrorException {
37
37
38
38
@ Override
39
39
public WxMpUser userInfo (String openid , String lang ) throws WxErrorException {
40
- String url = API_URL_PREFIX + "/info" ;
41
40
lang = lang == null ? "zh_CN" : lang ;
42
- String responseContent = this .wxMpService .get (url ,
41
+ String responseContent = this .wxMpService .get (USER_INFO_URL ,
43
42
"openid=" + openid + "&lang=" + lang );
44
43
return WxMpUser .fromJson (responseContent );
45
44
}
46
45
47
46
@ Override
48
- public WxMpUserList userList (String next_openid ) throws WxErrorException {
49
- String url = API_URL_PREFIX + "/get" ;
50
- String responseContent = this .wxMpService .get (url ,
51
- next_openid == null ? null : "next_openid=" + next_openid );
47
+ public WxMpUserList userList (String nextOpenid ) throws WxErrorException {
48
+ String responseContent = this .wxMpService .get (USER_GET_URL ,
49
+ nextOpenid == null ? null : "next_openid=" + nextOpenid );
52
50
return WxMpUserList .fromJson (responseContent );
53
51
}
54
52
55
53
@ Override
56
- public List <WxMpUser > userInfoList (List <String > openids )
54
+ public List <WxMpUser > userInfoList (List <String > openidList )
57
55
throws WxErrorException {
58
- return this .userInfoList (new WxMpUserQuery (openids ));
56
+ return this .userInfoList (new WxMpUserQuery (openidList ));
59
57
}
60
58
61
59
@ Override
62
60
public List <WxMpUser > userInfoList (WxMpUserQuery userQuery ) throws WxErrorException {
63
- String url = API_URL_PREFIX + "/info/batchget" ;
64
- String responseContent = this .wxMpService .post (url ,
65
- userQuery .toJsonString ());
61
+ String responseContent = this .wxMpService .post (USER_INFO_BATCH_GET_URL , userQuery .toJsonString ());
66
62
return WxMpUser .fromJsonList (responseContent );
67
63
}
68
64
0 commit comments