Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
c56073b3
Commit
c56073b3
authored
Feb 18, 2020
by
庄冰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wxtoken
parent
c7d131de
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
0 deletions
+85
-0
center-channel/app/base/api/impl/action/policy.js
+3
-0
center-channel/app/base/db/cache/wxTokenCache.js
+42
-0
center-channel/app/base/service/impl/common/wxTokenSve.js
+32
-0
center-channel/app/base/service/impl/policy/policySve.js
+8
-0
No files found.
center-channel/app/base/api/impl/action/policy.js
View file @
c56073b3
...
@@ -40,6 +40,9 @@ class PolicyAPI extends APIBase {
...
@@ -40,6 +40,9 @@ class PolicyAPI extends APIBase {
case
"submitPolicyNeedNotes"
:
//申请信息备注提交
case
"submitPolicyNeedNotes"
:
//申请信息备注提交
opResult
=
this
.
policySve
.
submitPolicyNeedNotes
(
pobj
);
opResult
=
this
.
policySve
.
submitPolicyNeedNotes
(
pobj
);
break
;
break
;
case
"getWxToken"
:
//申请信息备注提交
opResult
=
this
.
policySve
.
getWxToken
();
break
;
default
:
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
break
;
...
...
center-channel/app/base/db/cache/wxTokenCache.js
0 → 100644
View file @
c56073b3
const
CacheBase
=
require
(
"../cache.base"
);
const
system
=
require
(
"../../system"
);
// const OpenplatformWxop = require("../../wxop/impl/openplatformWxop");
/**
* 微信开放平台 公众号或小程序的接口调用凭据(授权方令牌)缓存(2小时后失效)
*/
class
WxTokenCache
extends
CacheBase
{
constructor
(){
super
();
this
.
prefix
=
"wx_policy_token_wx8aa8a8d4ff3da8bd"
;
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
wxTokenSve
=
system
.
getObject
(
"service.common.wxTokenSve"
);
}
desc
()
{
return
"应用UI配置缓存"
;
}
prefix
()
{
return
"wx_policy_token_wx8aa8a8d4ff3da8bd"
;
}
async
get
(){
//公众号appid
var
key
=
this
.
prefix
;
var
result
=
await
this
.
redisClient
.
get
(
key
);
var
obj
=
null
;
if
(
result
){
obj
=
JSON
.
parse
(
result
);
}
if
(
!
obj
){
//无缓存
var
newobj
=
await
this
.
wxTokenSve
.
getToken
();
if
(
newobj
&&
newobj
.
access_token
){
var
newobjstring
=
JSON
.
stringify
(
newobj
);
await
this
.
redisClient
.
rpushWithEx
(
key
,
newobjstring
,
30
);
return
newobj
;
}
else
{
return
null
;
}
}
return
obj
;
}
}
module
.
exports
=
WxTokenCache
;
\ No newline at end of file
center-channel/app/base/service/impl/common/wxTokenSve.js
0 → 100644
View file @
c56073b3
const
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
/**
* 微信token
* zhuangbing
* 2020.02.17
*/
class
WxTokenService
{
constructor
(){
this
.
rc
=
system
.
getObject
(
"util.execClient"
);
}
/**
* 获取微信access_token
* 返回结果:
* component_access_token 第三方平台access_token
* expires_in 有效期
*/
async
getToken
(){
try
{
var
url
=
"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx8aa8a8d4ff3da8bd&secret=5b64d43832cfd08327e9369aa455f799"
;
var
rtn
=
await
this
.
rc
.
execGet
({},
url
);
console
.
log
(
rtn
);
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
catch
(
e
){
return
null
;
}
}
}
module
.
exports
=
WxTokenService
;
\ No newline at end of file
center-channel/app/base/service/impl/policy/policySve.js
View file @
c56073b3
...
@@ -4,7 +4,15 @@ class PolicyService{
...
@@ -4,7 +4,15 @@ class PolicyService{
constructor
()
{
constructor
()
{
this
.
centerOrderUrl
=
settings
.
centerOrderUrl
();
this
.
centerOrderUrl
=
settings
.
centerOrderUrl
();
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
};
};
async
getWxToken
(){
var
data
=
await
this
.
cacheManager
[
"WxTokenCache"
].
get
();
if
(
data
){
return
system
.
getResultSuccess
(
data
);
}
return
system
.
getResult
();
}
async
policyQuery
(
pobj
)
{
async
policyQuery
(
pobj
)
{
var
url
=
this
.
centerOrderUrl
+
"action/policy/springBoard"
;
var
url
=
this
.
centerOrderUrl
+
"action/policy/springBoard"
;
var
rtn
=
await
this
.
execClient
.
execPost
(
pobj
,
url
);
var
rtn
=
await
this
.
execClient
.
execPost
(
pobj
,
url
);
...
...
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