Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
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
youjj
cloud-platform
Commits
1f661d79
Commit
1f661d79
authored
Sep 29, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
123
parent
cd942b0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
WeixinService.java
...n/java/com/xxfc/platform/universal/biz/WeixinService.java
+3
-1
WeixinController.java
.../xxfc/platform/universal/controller/WeixinController.java
+7
-2
No files found.
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/biz/WeixinService.java
View file @
1f661d79
package
com
.
xxfc
.
platform
.
universal
.
biz
;
package
com
.
xxfc
.
platform
.
universal
.
biz
;
import
cn.hutool.core.codec.Base64
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
...
@@ -78,7 +79,8 @@ public class WeixinService {
...
@@ -78,7 +79,8 @@ public class WeixinService {
if
(
StringUtils
.
isBlank
(
frontSessionValue1
))
{
if
(
StringUtils
.
isBlank
(
frontSessionValue1
))
{
return
null
;
return
null
;
}
}
return
frontSessionValue1
;
String
openId
=
Base64
.
decodeStr
(
frontSessionValue1
);
return
openId
;
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
e
.
printStackTrace
();
e
.
printStackTrace
();
return
null
;
return
null
;
...
...
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/controller/WeixinController.java
View file @
1f661d79
...
@@ -31,6 +31,7 @@ public class WeixinController {
...
@@ -31,6 +31,7 @@ public class WeixinController {
public
static
final
String
WECHAT_AUTOLOGIN_CALLBACKURL_KEY
=
"callback"
;
public
static
final
String
WECHAT_AUTOLOGIN_CALLBACKURL_KEY
=
"callback"
;
public
static
final
String
frontSessionKey
=
"frontWeixKey"
;
@Autowired
@Autowired
WeixinService
weixinService
;
WeixinService
weixinService
;
...
@@ -70,7 +71,7 @@ public class WeixinController {
...
@@ -70,7 +71,7 @@ public class WeixinController {
public
String
getUserInformation
(
String
code
,
String
callback
,
HttpServletRequest
request
)
{
public
String
getUserInformation
(
String
code
,
String
callback
,
HttpServletRequest
request
)
{
log
.
info
(
"-----微信回调userInfo---code=="
+
code
+
"----redirec_url==="
+
callback
);
log
.
info
(
"-----微信回调userInfo---code=="
+
code
+
"----redirec_url==="
+
callback
);
try
{
try
{
authUser
(
code
);
authUser
(
code
,
request
);
callback
=
new
String
(
Base64
.
decode
(
callback
),
"utf-8"
);
callback
=
new
String
(
Base64
.
decode
(
callback
),
"utf-8"
);
log
.
info
(
"callback==="
+
callback
);
log
.
info
(
"callback==="
+
callback
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
...
@@ -82,7 +83,7 @@ public class WeixinController {
...
@@ -82,7 +83,7 @@ public class WeixinController {
public
void
authUser
(
String
code
){
public
void
authUser
(
String
code
,
HttpServletRequest
request
){
if
(
StringUtils
.
isBlank
(
code
)){
if
(
StringUtils
.
isBlank
(
code
)){
log
.
info
(
"----code为空---"
);
log
.
info
(
"----code为空---"
);
throw
new
BaseException
(
ResultCode
.
FAILED_CODE
,
Sets
.
newSet
(
"code为空"
));
throw
new
BaseException
(
ResultCode
.
FAILED_CODE
,
Sets
.
newSet
(
"code为空"
));
...
@@ -102,6 +103,10 @@ public class WeixinController {
...
@@ -102,6 +103,10 @@ public class WeixinController {
JSONObject
refreshData
=
weixinService
.
getRefreshToken
(
refresh_token
);
JSONObject
refreshData
=
weixinService
.
getRefreshToken
(
refresh_token
);
access_token
=
refreshData
.
getString
(
"access_token"
);
access_token
=
refreshData
.
getString
(
"access_token"
);
}
}
String
encode
=
Base64
.
encode
(
openid
);
HttpSession
session
=
request
.
getSession
();
session
.
removeAttribute
(
frontSessionKey
);
session
.
setAttribute
(
frontSessionKey
,
encode
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
e
.
printStackTrace
();
e
.
printStackTrace
();
log
.
info
(
"网络异常==="
+
e
.
getMessage
());
log
.
info
(
"网络异常==="
+
e
.
getMessage
());
...
...
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