mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-25 01:14:36 +08:00
🐛 #1969 【企业微信】修复第三方应用获取登录用户信息接口方法里的错误代码
This commit is contained in:
parent
596aafcfb4
commit
c4a87961af
@ -5,13 +5,17 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yqx
|
* @author yqx
|
||||||
* @date 2020/3/16
|
* @date 2020/3/16
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class WxCpBaseResp {
|
public class WxCpBaseResp implements Serializable {
|
||||||
|
private static final long serialVersionUID = -4301684507150486556L;
|
||||||
|
|
||||||
@SerializedName("errcode")
|
@SerializedName("errcode")
|
||||||
protected Long errcode;
|
protected Long errcode;
|
||||||
|
|
||||||
|
@ -2,17 +2,23 @@ package me.chanjar.weixin.cp.bean;
|
|||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 登录信息
|
* 登录信息
|
||||||
* @author: Jamie.shi
|
*
|
||||||
* @create: 2020-08-03 17:18
|
* @author Jamie.shi
|
||||||
|
* @date 2020-08-03 17:18
|
||||||
**/
|
**/
|
||||||
@Data
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class WxTpLoginInfo extends WxCpBaseResp {
|
public class WxTpLoginInfo extends WxCpBaseResp {
|
||||||
|
private static final long serialVersionUID = -6994487991072386856L;
|
||||||
|
|
||||||
@SerializedName("usertype")
|
@SerializedName("usertype")
|
||||||
private Integer userType;
|
private Integer userType;
|
||||||
@SerializedName("user_info")
|
@SerializedName("user_info")
|
||||||
@ -23,8 +29,14 @@ public class WxTpLoginInfo extends WxCpBaseResp {
|
|||||||
private AuthInfo authInfo;
|
private AuthInfo authInfo;
|
||||||
private List<Agent> agent;
|
private List<Agent> agent;
|
||||||
|
|
||||||
|
public static WxTpLoginInfo fromJson(String json) {
|
||||||
|
return WxCpGsonBuilder.create().fromJson(json, WxTpLoginInfo.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class UserInfo {
|
public static class UserInfo implements Serializable {
|
||||||
|
private static final long serialVersionUID = -4558358748587735192L;
|
||||||
|
|
||||||
@SerializedName("userid")
|
@SerializedName("userid")
|
||||||
private String userId;
|
private String userId;
|
||||||
@SerializedName("open_userid")
|
@SerializedName("open_userid")
|
||||||
@ -34,17 +46,22 @@ public class WxTpLoginInfo extends WxCpBaseResp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class CorpInfoBean {
|
public static class CorpInfoBean implements Serializable {
|
||||||
|
private static final long serialVersionUID = -3160146744148144984L;
|
||||||
|
|
||||||
@SerializedName("corpid")
|
@SerializedName("corpid")
|
||||||
private String corpId;
|
private String corpId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class AuthInfo {
|
public static class AuthInfo implements Serializable {
|
||||||
|
private static final long serialVersionUID = -8697184659526210472L;
|
||||||
|
|
||||||
private List<Department> department;
|
private List<Department> department;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Department {
|
public static class Department implements Serializable {
|
||||||
|
private static final long serialVersionUID = -4389328276936557541L;
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private boolean writable;
|
private boolean writable;
|
||||||
@ -52,14 +69,11 @@ public class WxTpLoginInfo extends WxCpBaseResp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Agent {
|
public static class Agent implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1461544500964159037L;
|
||||||
@SerializedName("agentid")
|
@SerializedName("agentid")
|
||||||
private int agentId;
|
private int agentId;
|
||||||
@SerializedName("auth_type")
|
@SerializedName("auth_type")
|
||||||
private int authType;
|
private int authType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WxTpLoginInfo fromJson(String json) {
|
|
||||||
return WxCpGsonBuilder.create().fromJson(json, WxTpLoginInfo.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public interface WxCpTpService {
|
|||||||
*
|
*
|
||||||
* @return the suite access token
|
* @return the suite access token
|
||||||
* @throws WxErrorException the wx error exception
|
* @throws WxErrorException the wx error exception
|
||||||
* @see #getSuiteAccessToken(boolean) #getSuiteAccessToken(boolean)
|
* @see #getSuiteAccessToken(boolean) #getSuiteAccessToken(boolean)#getSuiteAccessToken(boolean)
|
||||||
*/
|
*/
|
||||||
String getSuiteAccessToken() throws WxErrorException;
|
String getSuiteAccessToken() throws WxErrorException;
|
||||||
|
|
||||||
@ -58,10 +58,23 @@ public interface WxCpTpService {
|
|||||||
*
|
*
|
||||||
* @return the suite ticket
|
* @return the suite ticket
|
||||||
* @throws WxErrorException the wx error exception
|
* @throws WxErrorException the wx error exception
|
||||||
* @see #getSuiteTicket(boolean) #getSuiteTicket(boolean)
|
* @see #getSuiteTicket(boolean) #getSuiteTicket(boolean)#getSuiteTicket(boolean)
|
||||||
*/
|
*/
|
||||||
String getSuiteTicket() throws WxErrorException;
|
String getSuiteTicket() throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 保存企业微信定时推送的suite_ticket,(每10分钟)
|
||||||
|
* 详情请见:https://work.weixin.qq.com/api/doc#90001/90143/90628
|
||||||
|
*
|
||||||
|
* 注意:微信不是固定10分钟推送suite_ticket的, 且suite_ticket的有效期为30分钟
|
||||||
|
* https://work.weixin.qq.com/api/doc/10975#%E8%8E%B7%E5%8F%96%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E5%87%AD%E8%AF%81
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param suiteTicket the suite ticket
|
||||||
|
*/
|
||||||
|
void setSuiteTicket(String suiteTicket);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 获得suite_ticket
|
* 获得suite_ticket
|
||||||
@ -73,8 +86,8 @@ public interface WxCpTpService {
|
|||||||
* @param forceRefresh 强制刷新
|
* @param forceRefresh 强制刷新
|
||||||
* @return the suite ticket
|
* @return the suite ticket
|
||||||
* @throws WxErrorException the wx error exception
|
* @throws WxErrorException the wx error exception
|
||||||
* @Deprecated 由于无法主动刷新,所以这个接口实际已经没有意义,需要在接收企业微信的主动推送后,保存这个ticket
|
* @deprecated 由于无法主动刷新 ,所以这个接口实际已经没有意义,需要在接收企业微信的主动推送后,保存这个ticket
|
||||||
* @see #setSuiteTicket(String)
|
* @see #setSuiteTicket(String) #setSuiteTicket(String)
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
String getSuiteTicket(boolean forceRefresh) throws WxErrorException;
|
String getSuiteTicket(boolean forceRefresh) throws WxErrorException;
|
||||||
@ -88,21 +101,8 @@ public interface WxCpTpService {
|
|||||||
* https://work.weixin.qq.com/api/doc/10975#%E8%8E%B7%E5%8F%96%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E5%87%AD%E8%AF%81
|
* https://work.weixin.qq.com/api/doc/10975#%E8%8E%B7%E5%8F%96%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E5%87%AD%E8%AF%81
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param suiteTicket
|
* @param suiteTicket the suite ticket
|
||||||
*/
|
* @param expiresInSeconds the expires in seconds
|
||||||
void setSuiteTicket(String suiteTicket);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* 保存企业微信定时推送的suite_ticket,(每10分钟)
|
|
||||||
* 详情请见:https://work.weixin.qq.com/api/doc#90001/90143/90628
|
|
||||||
*
|
|
||||||
* 注意:微信不是固定10分钟推送suite_ticket的, 且suite_ticket的有效期为30分钟
|
|
||||||
* https://work.weixin.qq.com/api/doc/10975#%E8%8E%B7%E5%8F%96%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E5%87%AD%E8%AF%81
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @param suiteTicket
|
|
||||||
* @param expiresInSeconds
|
|
||||||
*/
|
*/
|
||||||
void setSuiteTicket(String suiteTicket, int expiresInSeconds);
|
void setSuiteTicket(String suiteTicket, int expiresInSeconds);
|
||||||
|
|
||||||
@ -111,6 +111,7 @@ public interface WxCpTpService {
|
|||||||
*
|
*
|
||||||
* @param authCorpId 授权企业的cropId
|
* @param authCorpId 授权企业的cropId
|
||||||
* @return jsapi ticket
|
* @return jsapi ticket
|
||||||
|
* @throws WxErrorException the wx error exception
|
||||||
*/
|
*/
|
||||||
String getSuiteJsApiTicket(String authCorpId) throws WxErrorException;
|
String getSuiteJsApiTicket(String authCorpId) throws WxErrorException;
|
||||||
|
|
||||||
@ -172,14 +173,12 @@ public interface WxCpTpService {
|
|||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 获取预授权链接,测试环境下使用
|
* 获取预授权链接,测试环境下使用
|
||||||
* @Link https://work.weixin.qq.com/api/doc/90001/90143/90602
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @param redirectUri 授权完成后的回调网址
|
* @param redirectUri 授权完成后的回调网址
|
||||||
* @param state a-zA-Z0-9的参数值(不超过128个字节),用于第三方自行校验session,防止跨域攻击
|
* @param state a-zA-Z0-9的参数值(不超过128个字节),用于第三方自行校验session,防止跨域攻击
|
||||||
* @param authType 授权类型:0 正式授权, 1 测试授权。
|
* @param authType 授权类型:0 正式授权, 1 测试授权。
|
||||||
* @return pre auth url
|
* @return pre auth url
|
||||||
* @throws WxErrorException the wx error exception
|
* @throws WxErrorException the wx error exception
|
||||||
|
* @Link https ://work.weixin.qq.com/api/doc/90001/90143/90602 </pre>
|
||||||
*/
|
*/
|
||||||
String getPreAuthUrl(String redirectUri, String state, int authType) throws WxErrorException;
|
String getPreAuthUrl(String redirectUri, String state, int authType) throws WxErrorException;
|
||||||
|
|
||||||
@ -198,6 +197,7 @@ public interface WxCpTpService {
|
|||||||
*
|
*
|
||||||
* @param authCorpId 授权企业的cropId
|
* @param authCorpId 授权企业的cropId
|
||||||
* @return jsapi ticket
|
* @return jsapi ticket
|
||||||
|
* @throws WxErrorException the wx error exception
|
||||||
*/
|
*/
|
||||||
String getAuthCorpJsApiTicket(String authCorpId) throws WxErrorException;
|
String getAuthCorpJsApiTicket(String authCorpId) throws WxErrorException;
|
||||||
|
|
||||||
@ -298,8 +298,9 @@ public interface WxCpTpService {
|
|||||||
* 获取访问用户身份
|
* 获取访问用户身份
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param code
|
* @param code the code
|
||||||
* @return
|
* @return user info 3 rd
|
||||||
|
* @throws WxErrorException the wx error exception
|
||||||
*/
|
*/
|
||||||
WxCpTpUserInfo getUserInfo3rd(String code) throws WxErrorException;
|
WxCpTpUserInfo getUserInfo3rd(String code) throws WxErrorException;
|
||||||
|
|
||||||
@ -308,94 +309,108 @@ public interface WxCpTpService {
|
|||||||
* 获取访问用户敏感信息
|
* 获取访问用户敏感信息
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param userTicket
|
* @param userTicket the user ticket
|
||||||
* @return
|
* @return user detail 3 rd
|
||||||
|
* @throws WxErrorException the wx error exception
|
||||||
*/
|
*/
|
||||||
WxCpTpUserDetail getUserDetail3rd(String userTicket) throws WxErrorException;
|
WxCpTpUserDetail getUserDetail3rd(String userTicket) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业用户登录信息
|
* 获取登录用户信息
|
||||||
* @param authCode
|
*
|
||||||
* @return
|
* 文档地址:https://work.weixin.qq.com/api/doc/90001/90143/91125
|
||||||
* @throws WxErrorException
|
* @param authCode the auth code
|
||||||
|
* @return login info
|
||||||
|
* @throws WxErrorException the wx error exception
|
||||||
*/
|
*/
|
||||||
WxTpLoginInfo getLoginInfo(String authCode) throws WxErrorException;
|
WxTpLoginInfo getLoginInfo(String authCode) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取服务商providerToken
|
* 获取服务商providerToken
|
||||||
* @return
|
*
|
||||||
* @throws WxErrorException
|
* @return the wx cp provider token
|
||||||
|
* @throws WxErrorException the wx error exception
|
||||||
*/
|
*/
|
||||||
String getWxCpProviderToken() throws WxErrorException;
|
String getWxCpProviderToken() throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get contact service
|
* get contact service
|
||||||
* @return WxCpTpContactService
|
*
|
||||||
|
* @return WxCpTpContactService wx cp tp contact service
|
||||||
*/
|
*/
|
||||||
WxCpTpContactService getWxCpTpContactService();
|
WxCpTpContactService getWxCpTpContactService();
|
||||||
|
|
||||||
/**
|
|
||||||
* get department service
|
|
||||||
* @return WxCpTpDepartmentService
|
|
||||||
*/
|
|
||||||
WxCpTpDepartmentService getWxCpTpDepartmentService();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get media service
|
|
||||||
* @return WxCpTpMediaService
|
|
||||||
*/
|
|
||||||
WxCpTpMediaService getWxCpTpMediaService();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get oa service
|
|
||||||
* @return WxCpTpOAService
|
|
||||||
*/
|
|
||||||
WxCpTpOAService getWxCpTpOAService();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get user service
|
|
||||||
* @return WxCpTpUserService
|
|
||||||
*/
|
|
||||||
WxCpTpUserService getWxCpTpUserService();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set contact service
|
* set contact service
|
||||||
|
*
|
||||||
* @param wxCpTpContactService the contact service
|
* @param wxCpTpContactService the contact service
|
||||||
*/
|
*/
|
||||||
void setWxCpTpContactService(WxCpTpContactService wxCpTpContactService);
|
void setWxCpTpContactService(WxCpTpContactService wxCpTpContactService);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get department service
|
||||||
|
*
|
||||||
|
* @return WxCpTpDepartmentService wx cp tp department service
|
||||||
|
*/
|
||||||
|
WxCpTpDepartmentService getWxCpTpDepartmentService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set department service
|
* set department service
|
||||||
|
*
|
||||||
* @param wxCpTpDepartmentService the department service
|
* @param wxCpTpDepartmentService the department service
|
||||||
*/
|
*/
|
||||||
void setWxCpTpDepartmentService(WxCpTpDepartmentService wxCpTpDepartmentService);
|
void setWxCpTpDepartmentService(WxCpTpDepartmentService wxCpTpDepartmentService);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get media service
|
||||||
|
*
|
||||||
|
* @return WxCpTpMediaService wx cp tp media service
|
||||||
|
*/
|
||||||
|
WxCpTpMediaService getWxCpTpMediaService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set media service
|
* set media service
|
||||||
|
*
|
||||||
* @param wxCpTpMediaService the media service
|
* @param wxCpTpMediaService the media service
|
||||||
*/
|
*/
|
||||||
void setWxCpTpMediaService(WxCpTpMediaService wxCpTpMediaService);
|
void setWxCpTpMediaService(WxCpTpMediaService wxCpTpMediaService);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get oa service
|
||||||
|
*
|
||||||
|
* @return WxCpTpOAService wx cp tp oa service
|
||||||
|
*/
|
||||||
|
WxCpTpOAService getWxCpTpOAService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set oa service
|
* set oa service
|
||||||
|
*
|
||||||
* @param wxCpTpOAService the oa service
|
* @param wxCpTpOAService the oa service
|
||||||
*/
|
*/
|
||||||
void setWxCpTpOAService(WxCpTpOAService wxCpTpOAService);
|
void setWxCpTpOAService(WxCpTpOAService wxCpTpOAService);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get user service
|
||||||
|
*
|
||||||
|
* @return WxCpTpUserService wx cp tp user service
|
||||||
|
*/
|
||||||
|
WxCpTpUserService getWxCpTpUserService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set user service
|
* set user service
|
||||||
|
*
|
||||||
* @param wxCpTpUserService the set user service
|
* @param wxCpTpUserService the set user service
|
||||||
*/
|
*/
|
||||||
void setWxCpTpUserService(WxCpTpUserService wxCpTpUserService);
|
void setWxCpTpUserService(WxCpTpUserService wxCpTpUserService);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取应用的管理员列表
|
* 获取应用的管理员列表
|
||||||
* @param authCorpId
|
*
|
||||||
* @param agentId
|
* @param authCorpId the auth corp id
|
||||||
* @return
|
* @param agentId the agent id
|
||||||
|
* @return admin list
|
||||||
|
* @throws WxErrorException the wx error exception
|
||||||
*/
|
*/
|
||||||
WxCpTpAdmin getAdminList(String authCorpId, Integer agentId) throws WxErrorException;
|
WxCpTpAdmin getAdminList(String authCorpId, Integer agentId) throws WxErrorException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
|||||||
public WxTpLoginInfo getLoginInfo(String authCode) throws WxErrorException {
|
public WxTpLoginInfo getLoginInfo(String authCode) throws WxErrorException {
|
||||||
JsonObject jsonObject = new JsonObject();
|
JsonObject jsonObject = new JsonObject();
|
||||||
jsonObject.addProperty("auth_code", authCode);
|
jsonObject.addProperty("auth_code", authCode);
|
||||||
jsonObject.addProperty("access_token", configStorage.getAccessToken(authCode));
|
jsonObject.addProperty("access_token", configStorage.getProviderToken());
|
||||||
String responseText = post(configStorage.getApiUrl(GET_LOGIN_INFO), jsonObject.toString());
|
String responseText = post(configStorage.getApiUrl(GET_LOGIN_INFO), jsonObject.toString());
|
||||||
return WxTpLoginInfo.fromJson(responseText);
|
return WxTpLoginInfo.fromJson(responseText);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user