Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
4a8f66da
Commit
4a8f66da
authored
Aug 09, 2023
by
muhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 小程序登录接口
parent
1f0455ac
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
7 deletions
+22
-7
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
+3
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/WxLoginServiceImpl.java
...src/main/java/com/wwdz/ch/wx/impl/WxLoginServiceImpl.java
+19
-7
No files found.
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
View file @
4a8f66da
...
...
@@ -69,6 +69,9 @@ public class UserServiceImpl implements UserService {
String
mobile
=
""
;
try
{
mobile
=
wxLoginService
.
getPhone
(
dto
.
getCode
());
if
(
StringUtils
.
equals
(
"false"
,
mobile
))
{
return
Result
.
failed
(
"获取access_token失败"
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取微信用户手机号失败"
,
e
);
return
Result
.
failed
(
"获取微信用户手机号失败"
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/WxLoginServiceImpl.java
View file @
4a8f66da
package
com.wwdz.ch.wx.impl
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl
;
import
com.wwdz.ch.core.util.HttpUtil
;
import
com.wwdz.ch.wx.service.WxLoginService
;
import
com.xxdxxs.utils.JsonUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
...
...
@@ -24,17 +26,27 @@ public class WxLoginServiceImpl implements WxLoginService {
@Value
(
"${dts.wx.app-secret}"
)
private
String
secret
;
@Autowired
private
WxMaService
wxMaService
;
@Override
public
String
getPhone
(
String
code
)
{
logger
.
info
(
"开始获取access_token----------------"
);
Map
<
String
,
String
>
tokenParam
=
new
HashMap
<>();
tokenParam
.
put
(
"grant_type"
,
"client_credential"
);
tokenParam
.
put
(
"appid"
,
"wx3618eab6c8b144af"
);
tokenParam
.
put
(
"secret"
,
"6fee0d7b2197845fed0a3fe8f5a9bd66"
);
String
tokenResult
=
HttpUtil
.
sendPost
(
GET_ACCESS_TOKEN_URL
,
tokenParam
);
logger
.
info
(
"获取access_token的结果是:"
+
tokenResult
);
String
accessToken
=
JsonUtils
.
getValueByPath
(
tokenResult
,
"access_token"
);
// Map<String, String> tokenParam = new HashMap<>();
// tokenParam.put("grant_type", "client_credential");
// tokenParam.put("appid", "wx3618eab6c8b144af");
// tokenParam.put("secret", "6fee0d7b2197845fed0a3fe8f5a9bd66");
// String tokenResult = HttpUtil.sendPost(GET_ACCESS_TOKEN_URL, tokenParam);
// logger.info("获取access_token的结果是:" + tokenResult);
// String accessToken = JsonUtils.getValueByPath(tokenResult, "access_token");
String
accessToken
=
""
;
try
{
accessToken
=
wxMaService
.
getAccessToken
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取accessToken出错"
);
return
"false"
;
}
logger
.
info
(
"开始获取phone-----------------------"
);
String
url
=
String
.
format
(
GET_PHONE_URL
,
accessToken
);
...
...
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