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
915d3a55
Commit
915d3a55
authored
Aug 08, 2023
by
muhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 小程序登录接口
parent
0747b6a3
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
120 additions
and
100 deletions
+120
-100
ch-core/src/main/resources/application-dev.yml
ch-core/src/main/resources/application-dev.yml
+4
-2
ch-core/src/main/resources/application-prod.yml
ch-core/src/main/resources/application-prod.yml
+4
-2
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
+60
-96
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/WxLoginServiceImpl.java
...src/main/java/com/wwdz/ch/wx/impl/WxLoginServiceImpl.java
+47
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/WxLoginService.java
.../src/main/java/com/wwdz/ch/wx/service/WxLoginService.java
+5
-0
No files found.
ch-core/src/main/resources/application-dev.yml
View file @
915d3a55
...
...
@@ -2,7 +2,7 @@ dts:
# 开发者应该设置成自己的wx相关信息
wx
:
app-id
:
wx3618eab6c8b144af
app-secret
:
788559035a21b8a75b0c03f9281d5c0a
app-secret
:
6fee0d7b2197845fed0a3fe8f5a9bd66
mch-id
:
1538666666
mch-key
:
1538xxxxxx-1538xxxxxx-1538xxxxxx
notify-url
:
https://test.dtsshop.com/demo/order/dtsNotify
...
...
@@ -170,3 +170,5 @@ server:
servlet
:
session
:
timeout
:
720
avatar-url
:
https://cdn.wanwudezhi.com/static/web-static/image/b888cc6cb9c004dc342f573653e38ebd_690x690.png
\ No newline at end of file
ch-core/src/main/resources/application-prod.yml
View file @
915d3a55
...
...
@@ -2,7 +2,7 @@ dts:
# 开发者应该设置成自己的wx相关信息
wx
:
app-id
:
wx3618eab6c8b144af
app-secret
:
1a6e073ad84a1a44b6e882f3995bc400
app-secret
:
6fee0d7b2197845fed0a3fe8f5a9bd66
mch-id
:
1538666666
mch-key
:
1538xxxxxx-1538xxxxxx-1538xxxxxx
notify-url
:
https://test.dtsshop.com/demo/order/dtsNotify
...
...
@@ -168,3 +168,5 @@ server:
servlet
:
session
:
timeout
:
720
avatar-url
:
https://cdn.wanwudezhi.com/static/web-static/image/b888cc6cb9c004dc342f573653e38ebd_690x690.png
\ No newline at end of file
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
View file @
915d3a55
This diff is collapsed.
Click to expand it.
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/WxLoginServiceImpl.java
0 → 100644
View file @
915d3a55
package
com.wwdz.ch.wx.impl
;
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.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.Map
;
@Service
public
class
WxLoginServiceImpl
implements
WxLoginService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
WxMaServiceImpl
.
class
);
private
static
final
String
GET_ACCESS_TOKEN_URL
=
"https://api.weixin.qq.com/cgi-bin/stable_token"
;
private
static
final
String
GET_PHONE_URL
=
"https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%s"
;
@Value
(
"${dts.wx.app-id}"
)
private
String
appid
;
@Value
(
"${dts.wx.app-secret}"
)
private
String
secret
;
@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"
,
appid
);
tokenParam
.
put
(
"secret"
,
secret
);
String
tokenResult
=
HttpUtil
.
sendPost
(
GET_ACCESS_TOKEN_URL
,
tokenParam
);
logger
.
info
(
"获取access_token的结果是:"
+
tokenResult
);
String
accessToken
=
JsonUtils
.
getValueByPath
(
tokenResult
,
"access_token"
);
logger
.
info
(
"开始获取phone-----------------------"
);
String
url
=
String
.
format
(
GET_PHONE_URL
,
accessToken
);
Map
<
String
,
String
>
phoneParam
=
new
HashMap
<>();
phoneParam
.
put
(
"code"
,
code
);
String
phoneResult
=
HttpUtil
.
sendPost
(
url
,
phoneParam
);
logger
.
info
(
"获取phone的结果是:"
+
phoneResult
);
return
JsonUtils
.
getValueByPath
(
phoneResult
,
"phone_info/phoneNumber"
);
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/WxLoginService.java
0 → 100644
View file @
915d3a55
package
com.wwdz.ch.wx.service
;
public
interface
WxLoginService
{
String
getPhone
(
String
code
);
}
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