记得上下班打卡 | 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
f44d2da5
Commit
f44d2da5
authored
Jul 15, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:get openid;
parent
0bee2ceb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
AdamLoginController.java
...iquidnet/service/adam/controller/AdamLoginController.java
+6
-6
No files found.
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/java/com/liquidnet/service/adam/controller/AdamLoginController.java
View file @
f44d2da5
...
@@ -335,11 +335,11 @@ public class AdamLoginController {
...
@@ -335,11 +335,11 @@ public class AdamLoginController {
@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
;
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
);
String
respJStr
=
HttpUtil
.
get
(
url
,
null
);
respJStr
=
HttpUtil
.
get
(
url
,
null
);
JsonNode
respJNode
=
JsonUtils
.
fromJson
(
respJStr
,
JsonNode
.
class
);
JsonNode
respJNode
=
JsonUtils
.
fromJson
(
respJStr
,
JsonNode
.
class
);
if
(
null
==
respJNode
||
!
"0"
.
equalsIgnoreCase
(
respJNode
.
get
(
"errcode"
).
asText
()))
{
if
(
null
==
respJNode
||
!
"0"
.
equalsIgnoreCase
(
respJNode
.
get
(
"errcode"
).
asText
()))
{
log
.
warn
(
"WX.API调用失败[{}]"
,
respJStr
);
log
.
warn
(
"WX.API调用失败[{}]"
,
respJStr
);
...
@@ -347,7 +347,7 @@ public class AdamLoginController {
...
@@ -347,7 +347,7 @@ public class AdamLoginController {
}
}
openId
=
respJNode
.
get
(
"openid"
).
asText
();
openId
=
respJNode
.
get
(
"openid"
).
asText
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"WX.API调用异常[jsCode:{}
]"
,
jsCode
,
e
);
log
.
error
(
"WX.API调用异常[jsCode:{}
,respJStr={}]"
,
jsCode
,
respJStr
,
e
);
}
}
return
ResponseDto
.
success
(
openId
);
return
ResponseDto
.
success
(
openId
);
}
}
...
@@ -356,11 +356,11 @@ public class AdamLoginController {
...
@@ -356,11 +356,11 @@ public class AdamLoginController {
@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
;
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
);
String
respJStr
=
HttpUtil
.
get
(
url
,
null
);
respJStr
=
HttpUtil
.
get
(
url
,
null
);
JsonNode
respJNode
=
JsonUtils
.
fromJson
(
respJStr
,
JsonNode
.
class
);
JsonNode
respJNode
=
JsonUtils
.
fromJson
(
respJStr
,
JsonNode
.
class
);
if
(
null
==
respJNode
||
!
"0"
.
equalsIgnoreCase
(
respJNode
.
get
(
"errcode"
).
asText
()))
{
if
(
null
==
respJNode
||
!
"0"
.
equalsIgnoreCase
(
respJNode
.
get
(
"errcode"
).
asText
()))
{
log
.
warn
(
"WX.API调用失败[{}]"
,
respJStr
);
log
.
warn
(
"WX.API调用失败[{}]"
,
respJStr
);
...
@@ -368,7 +368,7 @@ public class AdamLoginController {
...
@@ -368,7 +368,7 @@ public class AdamLoginController {
}
}
openId
=
respJNode
.
get
(
"openid"
).
asText
();
openId
=
respJNode
.
get
(
"openid"
).
asText
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"WX.API调用异常[
code:{}]"
,
code
,
e
);
log
.
error
(
"WX.API调用异常[
jsCode:{},respJStr={}]"
,
code
,
respJStr
,
e
);
}
}
return
ResponseDto
.
success
(
openId
);
return
ResponseDto
.
success
(
openId
);
}
}
...
...
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