-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
feat [ 企业微信三方应用ID转换接口 ] #2865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat [ 企业微信三方应用ID转换接口 ] #2865
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpUnionidToExternalUseridResult.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package me.chanjar.weixin.cp.bean; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
import lombok.*; | ||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||
|
||
|
||
@Getter | ||
@Setter | ||
public class WxCpTpUnionidToExternalUseridResult extends WxCpBaseResp { | ||
|
||
|
||
private static final long serialVersionUID = -6153589164415497369L; | ||
|
||
@SerializedName("external_userid") | ||
private String externalUserid; | ||
|
||
@SerializedName("pending_id") | ||
private String pendingId; | ||
|
||
|
||
public static WxCpTpUnionidToExternalUseridResult fromJson(String json) { | ||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpUnionidToExternalUseridResult.class); | ||
} | ||
|
||
|
||
} |
25 changes: 25 additions & 0 deletions
25
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpIdConverService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package me.chanjar.weixin.cp.tp.service; | ||
|
||
import me.chanjar.weixin.common.error.WxErrorException; | ||
import me.chanjar.weixin.cp.bean.WxCpTpUnionidToExternalUseridResult; | ||
|
||
/** | ||
* <pre> | ||
* 企业微信三方应用ID转换接口 | ||
* | ||
* </pre> | ||
*/ | ||
public interface WxCpTpIdConverService { | ||
|
||
|
||
/** | ||
* unionid与external_userid的关联 https://developer.work.weixin.qq.com/document/path/95900 | ||
* @param unionid 微信客户的unionid | ||
* @param openid 微信客户的openid | ||
* @param subjectType 程序或公众号的主体类型: 0表示主体名称是企业的,1表示主体名称是服务商的 | ||
* @throws WxErrorException | ||
*/ | ||
WxCpTpUnionidToExternalUseridResult unionidToExternalUserid(String cropId,String unionid, String openid, Integer subjectType) throws WxErrorException; | ||
|
||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpIdConverServiceImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package me.chanjar.weixin.cp.tp.service.impl; | ||
|
||
import com.google.gson.JsonObject; | ||
import lombok.RequiredArgsConstructor; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
import me.chanjar.weixin.cp.bean.WxCpTpUnionidToExternalUseridResult; | ||
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; | ||
import me.chanjar.weixin.cp.tp.service.WxCpTpIdConverService; | ||
import me.chanjar.weixin.cp.tp.service.WxCpTpService; | ||
|
||
|
||
@RequiredArgsConstructor | ||
public class WxCpTpIdConverServiceImpl implements WxCpTpIdConverService { | ||
|
||
private final WxCpTpService mainService; | ||
|
||
@Override | ||
public WxCpTpUnionidToExternalUseridResult unionidToExternalUserid(String cropId, String unionid, String openid, Integer subjectType) throws WxErrorException { | ||
JsonObject json = new JsonObject(); | ||
json.addProperty("unionid", unionid); | ||
json.addProperty("openid", openid); | ||
if (subjectType != null) { | ||
json.addProperty("subject_type", subjectType); | ||
} | ||
WxCpTpConfigStorage wxCpTpConfigStorage = mainService.getWxCpTpConfigStorage(); | ||
String accessToken = wxCpTpConfigStorage.getAccessToken(cropId); | ||
String url = wxCpTpConfigStorage.getApiUrl("/cgi-bin/idconvert/unionid_to_external_userid"); | ||
url += "?access_token=" + accessToken; | ||
String responseContent = this.mainService.post(url, json.toString()); | ||
return WxCpTpUnionidToExternalUseridResult.fromJson(responseContent); | ||
} | ||
|
||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.