|
25 | 25 | import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.ExternalContact.*;
|
26 | 26 |
|
27 | 27 | /**
|
28 |
| - * @author 曹祖鹏 & yuanqixun |
| 28 | + * @author 曹祖鹏 & yuanqixun & Mr.Pan |
29 | 29 | */
|
30 | 30 | @RequiredArgsConstructor
|
31 | 31 | public class WxCpExternalContactServiceImpl implements WxCpExternalContactService {
|
@@ -135,6 +135,49 @@ public String unionidToExternalUserid(@NotNull String unionid,String openid) thr
|
135 | 135 | return tmpJson.get("external_userid").getAsString();
|
136 | 136 | }
|
137 | 137 |
|
| 138 | + @Override |
| 139 | + public String toServiceExternalUserid(@NotNull String externalUserid) throws WxErrorException { |
| 140 | + JsonObject json = new JsonObject(); |
| 141 | + json.addProperty("external_userid", externalUserid); |
| 142 | + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TO_SERVICE_EXTERNAL_USERID); |
| 143 | + String responseContent = this.mainService.post(url, json.toString()); |
| 144 | + JsonObject tmpJson = GsonParser.parse(responseContent); |
| 145 | + return tmpJson.get("external_userid").getAsString(); |
| 146 | + } |
| 147 | + |
| 148 | + @Override |
| 149 | + public WxCpExternalUserIdList unionidToExternalUserid3rd(@NotNull String unionid, @NotNull String openid, String corpid) throws WxErrorException { |
| 150 | + JsonObject json = new JsonObject(); |
| 151 | + json.addProperty("unionid", unionid); |
| 152 | + json.addProperty("openid", openid); |
| 153 | + if(StringUtils.isNotEmpty(corpid)){ |
| 154 | + json.addProperty("corpid",corpid); |
| 155 | + } |
| 156 | + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UNIONID_TO_EXTERNAL_USERID_3RD); |
| 157 | + String responseContent = this.mainService.post(url, json.toString()); |
| 158 | + return WxCpExternalUserIdList.fromJson(responseContent); |
| 159 | + } |
| 160 | + |
| 161 | + @Override |
| 162 | + public WxCpNewExternalUserIdList getNewExternalUserId(String[] externalUserIdList) throws WxErrorException { |
| 163 | + JsonObject json = new JsonObject(); |
| 164 | + if (ArrayUtils.isNotEmpty(externalUserIdList)) { |
| 165 | + json.add("external_userid_list", new Gson().toJsonTree(externalUserIdList).getAsJsonArray()); |
| 166 | + } |
| 167 | + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_NEW_EXTERNAL_USERID); |
| 168 | + String responseContent = this.mainService.post(url, json.toString()); |
| 169 | + return WxCpNewExternalUserIdList.fromJson(responseContent); |
| 170 | + } |
| 171 | + |
| 172 | + @Override |
| 173 | + public WxCpBaseResp finishExternalUserIdMigration(@NotNull String corpid) throws WxErrorException { |
| 174 | + JsonObject json = new JsonObject(); |
| 175 | + json.addProperty("corpid", corpid); |
| 176 | + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(FINISH_EXTERNAL_USERID_MIGRATION); |
| 177 | + String responseContent = this.mainService.post(url, json.toString()); |
| 178 | + return WxCpBaseResp.fromJson(responseContent); |
| 179 | + } |
| 180 | + |
138 | 181 | @Override
|
139 | 182 | public String opengidToChatid(@NotNull String opengid) throws WxErrorException {
|
140 | 183 | JsonObject json = new JsonObject();
|
|
0 commit comments