public class WechatLoginUtil
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
static int |
ACCESS_TOKEN_EXPIRED
access_token过期状态码
|
static int |
ERROR_CODE
自定义错误状态码
|
static int |
HTTP_CLIENT_CONNECT_TIMEOUT |
static int |
HTTP_CLIENT_READ_TIMEOUT |
static int |
SUCCESS_CODE
微信接口调用成功状态码
|
static java.lang.String |
WECHAT_LOGIN_SCOPE
微信扫描登录授权作用域
|
static java.lang.String |
WECHAT_OPT_KEY
微信扫码登录平台配置key
|
static java.lang.String |
WECHAT_OPT_RWID
微信扫码登录平台配置rwid
|
构造器和说明 |
---|
WechatLoginUtil() |
限定符和类型 | 方法和说明 |
---|---|
static java.lang.String |
buildAccessTokenUrl(java.lang.String code,
java.lang.String orgcode)
构建获取接口凭证access_token的URL
|
static java.lang.String |
buildCallbackUrl(java.util.Map<java.lang.String,java.lang.String> params)
构建微信扫码回调URL
|
static java.lang.String |
buildCallbackUrlEx(java.util.Map<java.lang.String,java.lang.String> params,
java.lang.String callbackUrl)
构建微信扫码回调URL(非平台内调用)
|
static java.lang.String |
buildRefreshAccessTokenUrl(java.lang.String refreshToken,
java.lang.String orgcode)
构建刷新接口凭证access_token的URL
|
static java.lang.String |
buildUserInfoUrl(java.lang.String accessToken,
java.lang.String openid)
构建获取用户信息URL
|
static WechatUserInfo |
converSysUserinfoToWechatUserinfo(CoreWxUserinfo userinfo)
将系统用户信息对象转成微信用户信息对象
|
static <T extends BaseResp> |
convertResponseEntity(org.springframework.http.ResponseEntity<java.lang.String> entity,
java.lang.Class<T> clazz)
将请求结果转换为对应的java bean
|
static CoreWxUserinfo |
convertWechatUserinfoToSysUserinfo(WechatUserInfo userinfo)
将微信用户信息对象转成系统用户信息对象
|
static AccessTokenResp |
getAccessTokenFromSession(java.lang.String openid)
从session中通openid获取accessToken
|
static WechatConfig |
getWechatConfig(java.lang.String orgcode)
获取微信扫码登录配置
|
static WechatConfig |
getWechatConfigByOrgid(java.lang.String orgid) |
static org.springframework.web.client.RestTemplate |
restTemplate()
创建RestTemplate实例:默认编码为utf-8
|
static org.springframework.web.client.RestTemplate |
restTemplate(java.nio.charset.Charset charset)
创建RestTemplate实例
|
static void |
setAccessTokenToSession(AccessTokenResp accessToken)
将accesstoken保存到session中,以AccessTokenResp中的openid作为key
|
public static final int HTTP_CLIENT_CONNECT_TIMEOUT
public static final int HTTP_CLIENT_READ_TIMEOUT
public static final java.lang.String WECHAT_OPT_RWID
public static final java.lang.String WECHAT_OPT_KEY
public static final int ACCESS_TOKEN_EXPIRED
public static final int SUCCESS_CODE
public static final int ERROR_CODE
public static java.lang.String WECHAT_LOGIN_SCOPE
public static WechatConfig getWechatConfig(java.lang.String orgcode)
orgcode
- 机构编码public static WechatConfig getWechatConfigByOrgid(java.lang.String orgid)
public static java.lang.String buildCallbackUrl(java.util.Map<java.lang.String,java.lang.String> params) throws java.lang.Exception
params
- 参数java.lang.Exception
- 出错抛出异常public static java.lang.String buildCallbackUrlEx(java.util.Map<java.lang.String,java.lang.String> params, java.lang.String callbackUrl) throws java.lang.Exception
params
- 参数callbackUrl
- 回调地址java.lang.Exception
- 出错抛出异常public static java.lang.String buildAccessTokenUrl(java.lang.String code, java.lang.String orgcode) throws java.lang.Exception
code
- 微信扫描回调返回的code参数orgcode
- 机构编码java.lang.Exception
- 出错抛出异常public static java.lang.String buildRefreshAccessTokenUrl(java.lang.String refreshToken, java.lang.String orgcode) throws java.lang.Exception
refreshToken
- refreshTokenorgcode
- 机构编码java.lang.Exception
- 出错抛出异常public static java.lang.String buildUserInfoUrl(java.lang.String accessToken, java.lang.String openid)
accessToken
- 接口调用凭证openid
- 普通用户标识public static org.springframework.web.client.RestTemplate restTemplate()
public static org.springframework.web.client.RestTemplate restTemplate(java.nio.charset.Charset charset)
charset
- 编码格式public static <T extends BaseResp> T convertResponseEntity(org.springframework.http.ResponseEntity<java.lang.String> entity, java.lang.Class<T> clazz)
T
- 是一个类的类型entity
- 实体实例clazz
- 类的类型public static CoreWxUserinfo convertWechatUserinfoToSysUserinfo(WechatUserInfo userinfo)
userinfo
- 用户信息public static WechatUserInfo converSysUserinfoToWechatUserinfo(CoreWxUserinfo userinfo)
userinfo
- 用户信息public static void setAccessTokenToSession(AccessTokenResp accessToken)
accessToken
- AccessTokenpublic static AccessTokenResp getAccessTokenFromSession(java.lang.String openid)
openid
- OpenId