记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
803fe038
Commit
803fe038
authored
Mar 03, 2022
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-API:adam:删除`微信小程序登录凭证校验`、`微信网站应用登录`;
~opt:UserPathDto;
parent
b3873248
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
68 deletions
+106
-68
ServletUtils.java
...in/java/com/liquidnet/commons/lang/util/ServletUtils.java
+1
-0
UserPathDto.java
...src/main/java/com/liquidnet/service/base/UserPathDto.java
+51
-11
AdamLoginController.java
...iquidnet/service/adam/controller/AdamLoginController.java
+54
-57
No files found.
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/ServletUtils.java
View file @
803fe038
...
@@ -17,6 +17,7 @@ import java.io.IOException;
...
@@ -17,6 +17,7 @@ import java.io.IOException;
*/
*/
public
class
ServletUtils
public
class
ServletUtils
{
{
public
final
static
String
HEADER_USER_AGENT
=
"User-Agent"
;
/**
/**
* 定义移动端请求的所有可能类型
* 定义移动端请求的所有可能类型
*/
*/
...
...
liquidnet-bus-common/liquidnet-common-service-base/src/main/java/com/liquidnet/service/base/UserPathDto.java
View file @
803fe038
package
com
.
liquidnet
.
service
.
base
;
package
com
.
liquidnet
.
service
.
base
;
import
com.liquidnet.commons.lang.util.CurrentUtil
;
import
com.liquidnet.commons.lang.util.CurrentUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.ServletUtils
;
import
com.liquidnet.commons.lang.util.ServletUtils
;
import
lombok.Data
;
import
lombok.Data
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
@Data
@Data
public
class
UserPathDto
implements
Serializable
{
public
class
UserPathDto
implements
Serializable
,
Cloneable
{
private
static
final
long
serialVersionUID
=
-
4153353929914805750L
;
private
static
final
String
LOG_SEPARATOR
=
","
;
private
static
final
String
LOG_NOW_ELK
=
"NOW_ELK_"
;
private
static
final
String
LOG_NOW_PDK
=
"NOW_PDK_"
;
private
static
UserPathDto
instance
=
new
UserPathDto
();
private
static
UserPathDto
instance
=
new
UserPathDto
();
private
static
final
long
serialVersionUID
=
-
4153353929914805750L
;
// private String tag;
// private String tag;
private
String
uid
;
private
String
uid
;
private
String
ip
;
private
String
ip
;
private
String
token
;
private
String
token
;
private
String
time
;
//yyyyMMddHHmmssSSS
private
LocalDateTime
time
;
private
String
interfaceName
;
private
String
interfaceName
;
private
String
params
;
private
Object
params
;
private
String
result
;
private
Object
result
;
private
String
userAgent
;
private
String
userAgent
;
private
UserPathDto
()
{
private
UserPathDto
()
{
}
}
private
static
UserPathDto
getInstance
()
{
private
static
UserPathDto
getInstance
()
{
return
instance
;
try
{
return
(
UserPathDto
)
instance
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
UserPathDto
();
}
}
}
public
static
String
setData
(
String
interfaceName
,
Object
params
,
Object
result
)
{
/*
public static String setData(String interfaceName, Object params, Object result) {
// instance.tag = "MDSKY.NOW.ELK";
// instance.tag = "MDSKY.NOW.ELK";
instance.ip = CurrentUtil.getCliIpAddr();
instance.ip = CurrentUtil.getCliIpAddr();
instance.uid = CurrentUtil.getCurrentUid() == null ? "UID" : CurrentUtil.getCurrentUid();
instance.uid = CurrentUtil.getCurrentUid() == null ? "UID" : CurrentUtil.getCurrentUid();
...
@@ -48,11 +55,44 @@ public class UserPathDto implements Serializable {
...
@@ -48,11 +55,44 @@ public class UserPathDto implements Serializable {
public static String setPartnerData(String merchantId ,String interfaceName, Object params, Object result) {
public static String setPartnerData(String merchantId ,String interfaceName, Object params, Object result) {
instance.ip = CurrentUtil.getCliIpAddr();
instance.ip = CurrentUtil.getCliIpAddr();
instance.uid = merchantId;
instance.uid = merchantId;
instance
.
time
=
DateUtil
.
Formatter
.
yyyyMMddHHmmssSSSUnTrim
.
format
(
LocalDateTime
.
now
()
);
instance.time =
LocalDateTime.now(
);
instance.interfaceName = interfaceName;
instance.interfaceName = interfaceName;
instance.params = params.toString().equals("") ? "NanParams" : params.toString();
instance.params = params.toString().equals("") ? "NanParams" : params.toString();
instance.result = result.toString().equals("") ? "NanResults" : result.toString();
instance.result = result.toString().equals("") ? "NanResults" : result.toString();
instance.userAgent = ServletUtils.getRequest().getHeader("User-Agent");
instance.userAgent = ServletUtils.getRequest().getHeader("User-Agent");
return "MDSKY.NOW.PDK." + instance.uid+ " = " + JsonUtils.toJson(instance);
return "MDSKY.NOW.PDK." + instance.uid+ " = " + JsonUtils.toJson(instance);
}*/
public
static
String
setData
(
String
interfaceName
,
Object
params
,
Object
result
)
{
HttpServletRequest
request
=
ServletUtils
.
getRequest
();
String
uid
=
(
String
)
request
.
getAttribute
(
CurrentUtil
.
TOKEN_SUB
);
UserPathDto
userPathDto
=
getInstance
();
userPathDto
.
setIp
(
CurrentUtil
.
getCliIpAddr
());
userPathDto
.
setUid
(
uid
);
userPathDto
.
setToken
((
String
)
request
.
getAttribute
(
CurrentUtil
.
uToken
));
userPathDto
.
setTime
(
LocalDateTime
.
now
());
userPathDto
.
setInterfaceName
(
interfaceName
);
userPathDto
.
setParams
(
params
);
userPathDto
.
setResult
(
result
);
userPathDto
.
setUserAgent
(
request
.
getHeader
(
ServletUtils
.
HEADER_USER_AGENT
));
return
(
LOG_NOW_ELK
+
(
StringUtils
.
isEmpty
(
uid
)
?
interfaceName
:
uid
)).
concat
(
LOG_SEPARATOR
)
.
concat
(
JsonUtils
.
toJson
(
userPathDto
));
}
public
static
String
setPartnerData
(
String
merchantId
,
String
interfaceName
,
Object
params
,
Object
result
)
{
HttpServletRequest
request
=
ServletUtils
.
getRequest
();
UserPathDto
userPathDto
=
getInstance
();
userPathDto
.
setIp
(
CurrentUtil
.
getCliIpAddr
());
userPathDto
.
setUid
(
merchantId
);
userPathDto
.
setTime
(
LocalDateTime
.
now
());
userPathDto
.
setInterfaceName
(
interfaceName
);
userPathDto
.
setParams
(
params
);
userPathDto
.
setResult
(
result
);
userPathDto
.
setUserAgent
(
request
.
getHeader
(
ServletUtils
.
HEADER_USER_AGENT
));
return
(
LOG_NOW_PDK
+
merchantId
).
concat
(
LOG_SEPARATOR
).
concat
(
JsonUtils
.
toJson
(
instance
));
}
}
}
}
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/java/com/liquidnet/service/adam/controller/AdamLoginController.java
View file @
803fe038
package
com
.
liquidnet
.
service
.
adam
.
controller
;
package
com
.
liquidnet
.
service
.
adam
.
controller
;
import
cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult
;
import
cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.dypnsapi.model.v20170525.GetMobileRequest
;
import
com.aliyuncs.dypnsapi.model.v20170525.GetMobileRequest
;
import
com.aliyuncs.dypnsapi.model.v20170525.GetMobileResponse
;
import
com.aliyuncs.dypnsapi.model.v20170525.GetMobileResponse
;
...
@@ -31,7 +29,6 @@ import io.swagger.annotations.ApiImplicitParam;
...
@@ -31,7 +29,6 @@ import io.swagger.annotations.ApiImplicitParam;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -144,7 +141,7 @@ public class AdamLoginController {
...
@@ -144,7 +141,7 @@ public class AdamLoginController {
loginInfoVo
.
setUserInfo
(
userInfoVo
);
loginInfoVo
.
setUserInfo
(
userInfoVo
);
loginInfoVo
.
setUserMemberVo
(
adamRdmService
.
getUserMemberVoByUid
(
userInfoVo
.
getUid
()));
loginInfoVo
.
setUserMemberVo
(
adamRdmService
.
getUserMemberVoByUid
(
userInfoVo
.
getUid
()));
log
.
info
(
UserPathDto
.
setData
(
"
登录
"
,
ServletUtils
.
getRequest
().
getParameterMap
(),
loginInfoVo
));
log
.
info
(
UserPathDto
.
setData
(
"
LOGIN
"
,
ServletUtils
.
getRequest
().
getParameterMap
(),
loginInfoVo
));
// return ResponseDto.success(loginInfoVo.desensitize(reviewUserInfo).finalRating());
// return ResponseDto.success(loginInfoVo.desensitize(reviewUserInfo).finalRating());
return
this
.
loginVoResponseProcessing
(
loginInfoVo
);
return
this
.
loginVoResponseProcessing
(
loginInfoVo
);
}
}
...
@@ -187,7 +184,7 @@ public class AdamLoginController {
...
@@ -187,7 +184,7 @@ public class AdamLoginController {
loginInfoVo
.
setUserMemberVo
(
adamRdmService
.
getUserMemberVoByUid
(
userInfoVo
.
getUid
()));
loginInfoVo
.
setUserMemberVo
(
adamRdmService
.
getUserMemberVoByUid
(
userInfoVo
.
getUid
()));
}
}
log
.
info
(
UserPathDto
.
setData
(
toRegister
?
"
注册"
:
"登录
"
,
ServletUtils
.
getRequest
().
getParameterMap
(),
loginInfoVo
));
log
.
info
(
UserPathDto
.
setData
(
toRegister
?
"
REGIST"
:
"LOGIN
"
,
ServletUtils
.
getRequest
().
getParameterMap
(),
loginInfoVo
));
// return ResponseDto.success(loginInfoVo.desensitize(reviewUserInfo).finalRating());
// return ResponseDto.success(loginInfoVo.desensitize(reviewUserInfo).finalRating());
return
this
.
loginVoResponseProcessing
(
loginInfoVo
);
return
this
.
loginVoResponseProcessing
(
loginInfoVo
);
}
}
...
@@ -199,7 +196,7 @@ public class AdamLoginController {
...
@@ -199,7 +196,7 @@ public class AdamLoginController {
})
})
@PostMapping
(
value
=
{
"login/mobile"
})
@PostMapping
(
value
=
{
"login/mobile"
})
public
ResponseDto
<
AdamLoginInfoVo
>
loginByMobile
(
@NotBlank
(
message
=
"访问令牌不能为空"
)
@RequestParam
String
accessToken
)
{
public
ResponseDto
<
AdamLoginInfoVo
>
loginByMobile
(
@NotBlank
(
message
=
"访问令牌不能为空"
)
@RequestParam
String
accessToken
)
{
log
.
info
(
"login by mobile access token:{}"
,
accessToken
);
log
.
debug
(
"login by mobile access token:{}"
,
accessToken
);
String
mobile
=
this
.
getMobile
(
accessToken
);
String
mobile
=
this
.
getMobile
(
accessToken
);
if
(
StringUtils
.
isEmpty
(
mobile
))
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10005"
));
if
(
StringUtils
.
isEmpty
(
mobile
))
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10005"
));
...
@@ -220,7 +217,7 @@ public class AdamLoginController {
...
@@ -220,7 +217,7 @@ public class AdamLoginController {
loginInfoVo
.
setUserMemberVo
(
adamRdmService
.
getUserMemberVoByUid
(
userInfoVo
.
getUid
()));
loginInfoVo
.
setUserMemberVo
(
adamRdmService
.
getUserMemberVoByUid
(
userInfoVo
.
getUid
()));
}
}
log
.
info
(
UserPathDto
.
setData
(
toRegister
?
"
注册"
:
"登录
"
,
ServletUtils
.
getRequest
().
getParameterMap
(),
loginInfoVo
));
log
.
info
(
UserPathDto
.
setData
(
toRegister
?
"
REGIST"
:
"LOGIN
"
,
ServletUtils
.
getRequest
().
getParameterMap
(),
loginInfoVo
));
// return ResponseDto.success(loginInfoVo.desensitize(reviewUserInfo).finalRating());
// return ResponseDto.success(loginInfoVo.desensitize(reviewUserInfo).finalRating());
return
this
.
loginVoResponseProcessing
(
loginInfoVo
);
return
this
.
loginVoResponseProcessing
(
loginInfoVo
);
}
}
...
@@ -277,7 +274,7 @@ public class AdamLoginController {
...
@@ -277,7 +274,7 @@ public class AdamLoginController {
// loginInfoVo.setWechatOpenid(wechatOpenid);
// loginInfoVo.setWechatOpenid(wechatOpenid);
// loginInfoVo.setWechatUnionid(wechatUnionid);
// loginInfoVo.setWechatUnionid(wechatUnionid);
//
//
// log.info(UserPathDto.setData(toRegister ? "
注册" : "登录
", ServletUtils.getRequest().getParameterMap(), loginInfoVo));
// log.info(UserPathDto.setData(toRegister ? "
REGIST" : "LOGIN
", ServletUtils.getRequest().getParameterMap(), loginInfoVo));
//// return ResponseDto.success(loginInfoVo.desensitize(reviewUserInfo).finalRating());
//// return ResponseDto.success(loginInfoVo.desensitize(reviewUserInfo).finalRating());
// return this.loginVoResponseProcessing(loginInfoVo);
// return this.loginVoResponseProcessing(loginInfoVo);
// }
// }
...
@@ -318,7 +315,7 @@ public class AdamLoginController {
...
@@ -318,7 +315,7 @@ public class AdamLoginController {
}
}
loginInfoVo
.
setToken
(
this
.
ssoProcess
(
loginInfoVo
.
getUserInfo
()));
loginInfoVo
.
setToken
(
this
.
ssoProcess
(
loginInfoVo
.
getUserInfo
()));
log
.
info
(
UserPathDto
.
setData
(
toRegister
?
"
注册"
:
"登录
"
,
ServletUtils
.
getRequest
().
getParameterMap
(),
loginInfoVo
));
log
.
info
(
UserPathDto
.
setData
(
toRegister
?
"
REGIST"
:
"LOGIN
"
,
ServletUtils
.
getRequest
().
getParameterMap
(),
loginInfoVo
));
// return ResponseDto.success(loginInfoVo.desensitize(reviewUserInfo).finalRating());
// return ResponseDto.success(loginInfoVo.desensitize(reviewUserInfo).finalRating());
return
this
.
loginVoResponseProcessing
(
loginInfoVo
);
return
this
.
loginVoResponseProcessing
(
loginInfoVo
);
}
}
...
@@ -365,7 +362,7 @@ public class AdamLoginController {
...
@@ -365,7 +362,7 @@ public class AdamLoginController {
loginInfoVo
.
setUserMemberVo
(
adamRdmService
.
getUserMemberVoByUid
(
userInfoVo
.
getUid
()));
loginInfoVo
.
setUserMemberVo
(
adamRdmService
.
getUserMemberVoByUid
(
userInfoVo
.
getUid
()));
}
}
log
.
info
(
UserPathDto
.
setData
(
toRegister
?
"
注册"
:
"登录
"
,
ServletUtils
.
getRequest
().
getParameterMap
(),
loginInfoVo
));
log
.
info
(
UserPathDto
.
setData
(
toRegister
?
"
REGIST"
:
"LOGIN
"
,
ServletUtils
.
getRequest
().
getParameterMap
(),
loginInfoVo
));
return
this
.
loginVoResponseProcessing
(
loginInfoVo
);
return
this
.
loginVoResponseProcessing
(
loginInfoVo
);
}
}
...
@@ -373,7 +370,7 @@ public class AdamLoginController {
...
@@ -373,7 +370,7 @@ public class AdamLoginController {
@ApiOperation
(
value
=
"登出"
)
@ApiOperation
(
value
=
"登出"
)
@PostMapping
(
value
=
{
"out"
})
@PostMapping
(
value
=
{
"out"
})
public
void
logout
()
{
public
void
logout
()
{
log
.
info
(
"###logout
:uid:{}\ntoken:{}"
,
CurrentUtil
.
getCurrentUid
(),
CurrentUtil
.
getToken
());
log
.
info
(
"###logout
_uid:{}"
,
CurrentUtil
.
getCurrentUid
());
redisUtil
.
del
(
jwtValidator
.
getSsoRedisKey
().
concat
(
CurrentUtil
.
getCurrentUid
()));
redisUtil
.
del
(
jwtValidator
.
getSsoRedisKey
().
concat
(
CurrentUtil
.
getCurrentUid
()));
}
}
...
@@ -382,7 +379,7 @@ public class AdamLoginController {
...
@@ -382,7 +379,7 @@ public class AdamLoginController {
@ApiOperation
(
value
=
"注销"
)
@ApiOperation
(
value
=
"注销"
)
@PostMapping
(
value
=
{
"close"
})
@PostMapping
(
value
=
{
"close"
})
public
ResponseDto
<
Object
>
close
()
{
public
ResponseDto
<
Object
>
close
()
{
log
.
info
(
"###close
:
uid:{}"
,
CurrentUtil
.
getCurrentUid
());
log
.
info
(
"###close
_
uid:{}"
,
CurrentUtil
.
getCurrentUid
());
this
.
logout
();
this
.
logout
();
...
@@ -398,51 +395,51 @@ public class AdamLoginController {
...
@@ -398,51 +395,51 @@ public class AdamLoginController {
return
ResponseDto
.
success
(
LocalDateTime
.
now
().
toInstant
(
ZoneOffset
.
of
(
"+8"
)).
toEpochMilli
());
return
ResponseDto
.
success
(
LocalDateTime
.
now
().
toInstant
(
ZoneOffset
.
of
(
"+8"
)).
toEpochMilli
());
}
}
@ApiOperationSupport
(
order
=
10
)
//
@ApiOperationSupport(order = 10)
@ApiOperation
(
value
=
"微信小程序登录凭证校验"
,
notes
=
"这里仅用于获取OPENID使用。登录凭证校验。通过 wx.login 接口获得临时登录凭证 code 后传到开发者服务器调用此接口完成登录流程。更多使用方法详见 https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html"
)
//
@ApiOperation(value = "微信小程序登录凭证校验", notes = "这里仅用于获取OPENID使用。登录凭证校验。通过 wx.login 接口获得临时登录凭证 code 后传到开发者服务器调用此接口完成登录流程。更多使用方法详见 https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html")
@GetMapping
(
value
=
{
"wxa/code2session"
})
//
@GetMapping(value = {"wxa/code2session"})
public
ResponseDto
<
String
>
wxaCode2Session
(
@RequestParam
String
jsCode
)
{
//
public ResponseDto<String> wxaCode2Session(@RequestParam String jsCode) {
String
openId
=
null
,
respJStr
=
null
;
//
String openId = null, respJStr = null;
try
{
//
try {
String
url
=
AdamWechatConst
.
API_URL_JS_CODE2SESSION
.
replace
(
"APPID"
,
AdamWechatConst
.
zhengzaiAppletAppid
)
//
String url = AdamWechatConst.API_URL_JS_CODE2SESSION.replace("APPID", AdamWechatConst.zhengzaiAppletAppid)
.
replace
(
"SECRET"
,
AdamWechatConst
.
zhengzaiAppletSecret
).
replace
(
"JSCODE"
,
jsCode
);
//
.replace("SECRET", AdamWechatConst.zhengzaiAppletSecret).replace("JSCODE", jsCode);
log
.
debug
(
"jsCode={},url={}"
,
jsCode
,
url
);
//
log.debug("jsCode={},url={}", jsCode, url);
respJStr
=
HttpUtil
.
get
(
url
,
null
);
//
respJStr = HttpUtil.get(url, null);
JsonNode
respJNode
=
JsonUtils
.
fromJson
(
respJStr
,
JsonNode
.
class
),
respErrcode
;
//
JsonNode respJNode = JsonUtils.fromJson(respJStr, JsonNode.class), respErrcode;
if
(
null
==
respJNode
||
(((
respErrcode
=
respJNode
.
get
(
"errcode"
))
!=
null
)
&&
!
"0"
.
equalsIgnoreCase
(
respErrcode
.
asText
())))
{
//
if (null == respJNode || (((respErrcode = respJNode.get("errcode")) != null) && !"0".equalsIgnoreCase(respErrcode.asText()))) {
log
.
warn
(
"WX.API调用失败[{}]"
,
respJStr
);
//
log.warn("WX.API调用失败[{}]", respJStr);
return
ResponseDto
.
success
(
null
);
//
return ResponseDto.success(null);
}
//
}
openId
=
respJNode
.
get
(
"openid"
).
asText
();
//
openId = respJNode.get("openid").asText();
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
log
.
error
(
"WX.API调用异常[jsCode:{},respJStr={}]"
,
jsCode
,
respJStr
,
e
);
//
log.error("WX.API调用异常[jsCode:{},respJStr={}]", jsCode, respJStr, e);
}
//
}
log
.
debug
(
"jsCode={},respJStr={}"
,
jsCode
,
respJStr
);
//
log.debug("jsCode={},respJStr={}", jsCode, respJStr);
return
ResponseDto
.
success
(
openId
);
//
return ResponseDto.success(openId);
}
//
}
//
@ApiOperationSupport
(
order
=
11
)
//
@ApiOperationSupport(order = 11)
@ApiOperation
(
value
=
"微信网站应用登录"
,
notes
=
"这里仅用于获取OPENID使用。方法详见 https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html"
)
//
@ApiOperation(value = "微信网站应用登录", notes = "这里仅用于获取OPENID使用。方法详见 https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html")
@GetMapping
(
value
=
{
"wx/oauth2/access_token"
})
//
@GetMapping(value = {"wx/oauth2/access_token"})
public
ResponseDto
<
String
>
wxOauth2AccessToken
(
@RequestParam
String
code
)
{
//
public ResponseDto<String> wxOauth2AccessToken(@RequestParam String code) {
String
openId
=
null
,
respJStr
=
null
;
//
String openId = null, respJStr = null;
try
{
//
try {
String
url
=
AdamWechatConst
.
API_URL_OAUTH2_ACCESS_TOKEN
.
replace
(
"APPID"
,
AdamWechatConst
.
zhengzaiServiceAppid
)
//
String url = AdamWechatConst.API_URL_OAUTH2_ACCESS_TOKEN.replace("APPID", AdamWechatConst.zhengzaiServiceAppid)
.
replace
(
"SECRET"
,
AdamWechatConst
.
zhengzaiServiceSecret
).
replace
(
"CODE"
,
code
);
//
.replace("SECRET", AdamWechatConst.zhengzaiServiceSecret).replace("CODE", code);
log
.
debug
(
"code={},url={}"
,
code
,
url
);
//
log.debug("code={},url={}", code, url);
respJStr
=
HttpUtil
.
get
(
url
,
null
);
//
respJStr = HttpUtil.get(url, null);
JsonNode
respJNode
=
JsonUtils
.
fromJson
(
respJStr
,
JsonNode
.
class
),
respErrcode
;
//
JsonNode respJNode = JsonUtils.fromJson(respJStr, JsonNode.class), respErrcode;
if
(
null
==
respJNode
||
(((
respErrcode
=
respJNode
.
get
(
"errcode"
))
!=
null
)
&&
!
"0"
.
equalsIgnoreCase
(
respErrcode
.
asText
())))
{
//
if (null == respJNode || (((respErrcode = respJNode.get("errcode")) != null) && !"0".equalsIgnoreCase(respErrcode.asText()))) {
log
.
warn
(
"WX.API调用失败[{}]"
,
respJStr
);
//
log.warn("WX.API调用失败[{}]", respJStr);
return
ResponseDto
.
success
(
null
);
//
return ResponseDto.success(null);
}
//
}
openId
=
respJNode
.
get
(
"openid"
).
asText
();
//
openId = respJNode.get("openid").asText();
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
log
.
error
(
"WX.API调用异常[jsCode:{},respJStr={}]"
,
code
,
respJStr
,
e
);
//
log.error("WX.API调用异常[jsCode:{},respJStr={}]", code, respJStr, e);
}
//
}
log
.
debug
(
"code={},respJStr={}"
,
code
,
respJStr
);
//
log.debug("code={},respJStr={}", code, respJStr);
return
ResponseDto
.
success
(
openId
);
//
return ResponseDto.success(openId);
}
//
}
/* ---------------------------- Internal Method ---------------------------- */
/* ---------------------------- Internal Method ---------------------------- */
/* ---------------------------- Internal Method ---------------------------- */
/* ---------------------------- Internal Method ---------------------------- */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment