Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
tianjin-cement
Project
Project
Details
Activity
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
竹天卫
tianjin-cement
Commits
9de559e2
Commit
9de559e2
authored
Dec 14, 2020
by
竹天卫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
正式版本
parent
e969010a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
12 deletions
+33
-12
WeiXinService.java
...n/wise/sc/cement/business/service/impl/WeiXinService.java
+33
-12
No files found.
cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/WeiXinService.java
View file @
9de559e2
...
...
@@ -36,11 +36,17 @@ public class WeiXinService {
@Value
(
"${weixin.corpId}"
)
private
String
corpId
;
@Value
(
"${weixin.agentId}"
)
private
int
agentId
;
@Value
(
"${weixin.agentSecret}"
)
private
String
agentSecret
;
@Value
(
"${weixin.agentIdPC}"
)
private
int
agentIdPC
;
@Value
(
"${weixin.agentSecretPC}"
)
private
String
agentSecretPC
;
final
static
String
ACCESS_TOKEN
=
"ACCESS_TOKEN"
;
final
static
String
JSAPITICKET
=
"JSAPITICKET"
;
...
...
@@ -95,9 +101,9 @@ public class WeiXinService {
System
.
out
.
println
(
code
);
try
{
String
accessToken
=
null
;
if
(
type
.
equals
(
"
PC
"
))
{
if
(
type
.
equals
(
"
APP
"
))
{
accessToken
=
getAccessToken
();
}
else
if
(
type
.
equals
(
"
APP
"
))
{
}
else
if
(
type
.
equals
(
"
PC
"
))
{
accessToken
=
getPCAccessToken
();
}
else
{
return
BaseResponse
.
errorMsg
(
"参数错误"
);
...
...
@@ -138,7 +144,8 @@ public class WeiXinService {
}
//获取accessToken信息
//获取accessToken信息 =======小程序
public
String
getAccessToken
()
{
try
{
return
getToken
();
...
...
@@ -160,6 +167,29 @@ public class WeiXinService {
return
redisUtil
.
getString
(
ACCESS_TOKEN
)
+
""
;
}
//获取accessToken信息 =======管理端
public
String
getPCAccessToken
()
{
try
{
return
getPCToken
();
}
catch
(
Exception
e
)
{
return
null
;
}
}
public
String
getPCToken
()
{
String
accessToken
;
if
(!
redisUtil
.
existsKey
(
ACCESS_TOKEN
))
{
String
param
=
"corpid=%s&corpsecret=%s"
;
param
=
String
.
format
(
param
,
corpId
,
agentSecretPC
);
JSONObject
jsonObject
=
WeixinInterfaceUtil
.
doGet
(
Global
.
ACCESSTOKENURL
,
param
);
accessToken
=
jsonObject
.
getString
(
"access_token"
);
redisUtil
.
setString
(
ACCESS_TOKEN
,
accessToken
,
7100
);
}
return
redisUtil
.
getString
(
ACCESS_TOKEN
)
+
""
;
}
//获取accessToken信息
public
String
getJsapiTicket
()
{
try
{
...
...
@@ -182,15 +212,6 @@ public class WeiXinService {
}
}
public
String
getPCAccessToken
()
{
try
{
return
getToken
();
}
catch
(
Exception
e
)
{
return
null
;
}
}
//获取用户信息
public
JSONObject
getUser
(
String
accessToken
,
String
userId
)
{
try
{
...
...
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