11package me .chanjar .weixin .mp .api .impl ;
22
3+ import java .util .List ;
4+
35import com .google .gson .JsonObject ;
46import me .chanjar .weixin .common .error .WxErrorException ;
57import me .chanjar .weixin .mp .api .WxMpService ;
810import me .chanjar .weixin .mp .bean .result .WxMpUser ;
911import me .chanjar .weixin .mp .bean .result .WxMpUserList ;
1012
11- import java .util .List ;
12-
1313/**
1414 * Created by Binary Wang on 2016/7/21.
15+ *
16+ * @author BinaryWang
1517 */
1618public class WxMpUserServiceImpl implements WxMpUserService {
17- private static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/user" ;
1819 private WxMpService wxMpService ;
1920
2021 public WxMpUserServiceImpl (WxMpService wxMpService ) {
@@ -23,11 +24,10 @@ public WxMpUserServiceImpl(WxMpService wxMpService) {
2324
2425 @ Override
2526 public void userUpdateRemark (String openid , String remark ) throws WxErrorException {
26- String url = API_URL_PREFIX + "/info/updateremark" ;
2727 JsonObject json = new JsonObject ();
2828 json .addProperty ("openid" , openid );
2929 json .addProperty ("remark" , remark );
30- this .wxMpService .post (url , json .toString ());
30+ this .wxMpService .post (USER_INFO_UPDATE_REMARK_URL , json .toString ());
3131 }
3232
3333 @ Override
@@ -37,32 +37,28 @@ public WxMpUser userInfo(String openid) throws WxErrorException {
3737
3838 @ Override
3939 public WxMpUser userInfo (String openid , String lang ) throws WxErrorException {
40- String url = API_URL_PREFIX + "/info" ;
4140 lang = lang == null ? "zh_CN" : lang ;
42- String responseContent = this .wxMpService .get (url ,
41+ String responseContent = this .wxMpService .get (USER_INFO_URL ,
4342 "openid=" + openid + "&lang=" + lang );
4443 return WxMpUser .fromJson (responseContent );
4544 }
4645
4746 @ 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 );
5250 return WxMpUserList .fromJson (responseContent );
5351 }
5452
5553 @ Override
56- public List <WxMpUser > userInfoList (List <String > openids )
54+ public List <WxMpUser > userInfoList (List <String > openidList )
5755 throws WxErrorException {
58- return this .userInfoList (new WxMpUserQuery (openids ));
56+ return this .userInfoList (new WxMpUserQuery (openidList ));
5957 }
6058
6159 @ Override
6260 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 ());
6662 return WxMpUser .fromJsonList (responseContent );
6763 }
6864
0 commit comments