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
4daac078
Commit
4daac078
authored
Sep 20, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
123
parent
ad63ee67
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
25 deletions
+35
-25
WeixinController.java
...com/xxfc/platform/summit/controller/WeixinController.java
+35
-25
No files found.
xx-summit/xx-summit-server/src/main/java/com/xxfc/platform/summit/controller/WeixinController.java
View file @
4daac078
...
@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.GetMapping;
...
@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSession
;
...
@@ -45,10 +44,16 @@ public class WeixinController {
...
@@ -45,10 +44,16 @@ public class WeixinController {
if
(
StringUtils
.
isBlank
(
redirec_url
)){
if
(
StringUtils
.
isBlank
(
redirec_url
)){
redirec_url
=
""
;
redirec_url
=
""
;
}
}
String
encrypt_curr_url
=
Base64
.
encode
(
redirec_url
);
try
{
String
encrypt_curr_url
=
Base64
.
encode
(
redirec_url
.
getBytes
(
"utf-8"
));
redirec_url
=
url
+
"?"
+
WECHAT_AUTOLOGIN_CALLBACKURL_KEY
+
"="
+
encrypt_curr_url
;
redirec_url
=
url
+
"?"
+
WECHAT_AUTOLOGIN_CALLBACKURL_KEY
+
"="
+
encrypt_curr_url
;
String
oauth_api
=
weixinService
.
getAuthorize
(
redirec_url
);
String
oauth_api
=
weixinService
.
getAuthorize
(
redirec_url
);
return
String
.
format
(
"redirect:"
+
oauth_api
);
return
String
.
format
(
"redirect:"
+
oauth_api
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
log
.
info
(
"网络异常==="
+
e
.
getMessage
());
return
String
.
format
(
"网络异常"
);
}
}
}
/**
/**
...
@@ -64,6 +69,7 @@ public class WeixinController {
...
@@ -64,6 +69,7 @@ public class WeixinController {
log
.
info
(
"----code为空---"
);
log
.
info
(
"----code为空---"
);
return
String
.
format
(
"code为空"
);
return
String
.
format
(
"code为空"
);
}
}
try
{
JSONObject
jsonData
=
weixinService
.
getAccessToken
(
code
);
JSONObject
jsonData
=
weixinService
.
getAccessToken
(
code
);
String
openid
=
jsonData
.
getString
(
"openid"
);
String
openid
=
jsonData
.
getString
(
"openid"
);
String
access_token
=
jsonData
.
getString
(
"access_token"
);
String
access_token
=
jsonData
.
getString
(
"access_token"
);
...
@@ -79,15 +85,19 @@ public class WeixinController {
...
@@ -79,15 +85,19 @@ public class WeixinController {
}
}
UserInfo
userInfo
=
new
UserInfo
();
UserInfo
userInfo
=
new
UserInfo
();
userInfo
.
setOpenId
(
openid
);
userInfo
.
setOpenId
(
openid
);
log
.
error
(
"UserInfo==="
+
JSONObject
.
toJSONString
(
userInfo
));
log
.
info
(
"UserInfo==="
+
JSONObject
.
toJSONString
(
userInfo
));
String
encode
=
Base64
.
encode
(
JSONObject
.
toJSONString
(
userInfo
));
String
encode
=
Base64
.
encode
(
JSONObject
.
toJSONString
(
userInfo
));
session
.
removeAttribute
(
frontSessionKey
);
session
.
removeAttribute
(
frontSessionKey
);
session
.
setAttribute
(
frontSessionKey
,
encode
);
session
.
setAttribute
(
frontSessionKey
,
encode
);
callback
=
Base64
.
encode
(
callback
);
callback
=
new
String
(
Base64
.
decode
(
callback
),
"utf-8"
);
log
.
error
(
"callback==="
+
callback
);
log
.
info
(
"callback==="
+
callback
);
return
String
.
format
(
"redirect:"
+
callback
);
return
String
.
format
(
"redirect:"
+
callback
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
log
.
info
(
"网络异常==="
+
e
.
getMessage
());
return
String
.
format
(
"网络异常"
);
}
}
}
}
}
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