Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zhny
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
王夏晖
zhny
Commits
c38fe785
Commit
c38fe785
authored
May 24, 2018
by
张大伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加微信授权
parent
9be839fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
2 deletions
+27
-2
WechatRedirectController.java
...ain/java/org/rcisoft/wechat/WechatRedirectController.java
+27
-2
No files found.
src/main/java/org/rcisoft/wechat/WechatRedirectController.java
View file @
c38fe785
package
org
.
rcisoft
.
wechat
;
import
me.chanjar.weixin.common.bean.WxJsapiSignature
;
import
me.chanjar.weixin.common.exception.WxErrorException
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.bean.result.WxMpUser
;
import
org.rcisoft.wechat.service.WxPortalService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.
servlet.ModelAndView
;
import
org.springframework.web.
bind.annotation.ResponseBody
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 网页授权微信回调接口
*
* @author David
*/
@Controller
...
...
@@ -20,6 +26,9 @@ public class WechatRedirectController {
@Resource
private
WxPortalService
service
;
@Autowired
private
WxMpService
wxService
;
@RequestMapping
(
value
=
{
"/index"
})
public
String
index
(
String
code
)
{
...
...
@@ -34,4 +43,20 @@ public class WechatRedirectController {
}
}
@RequestMapping
(
value
=
{
"/getConfig"
})
@ResponseBody
public
Map
<
String
,
Object
>
getConfig
(
String
url
)
{
try
{
WxJsapiSignature
wxJsapiSignature
=
service
.
getJsApiTicket
(
url
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
4
);
map
.
put
(
"timestamp"
,
wxJsapiSignature
.
getTimestamp
());
map
.
put
(
"nonceStr"
,
wxJsapiSignature
.
getNonceStr
());
map
.
put
(
"signature"
,
wxJsapiSignature
.
getSignature
());
map
.
put
(
"appId"
,
wxJsapiSignature
.
getAppId
());
return
map
;
}
catch
(
WxErrorException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
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