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
cf71f2c1
Commit
cf71f2c1
authored
Jan 10, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
326e9929
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
28 deletions
+65
-28
igirl-zcapi/app/base/api/impl/action/tmQuery.js
+2
-14
igirl-zcapi/app/base/api/impl/action/tmTools.js
+2
-14
igirl-zcapi/app/base/service/app.base.js
+61
-0
No files found.
igirl-zcapi/app/base/api/impl/action/tmQuery.js
View file @
cf71f2c1
...
...
@@ -10,29 +10,17 @@ class TmQueryAPI extends APIBase {
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async
springBoard
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
actionProcess
)
{
return
system
.
getResult
(
null
,
"actionProcess参数不能为空"
);
}
if
(
!
pobj
.
actionType
)
{
return
system
.
getResult
(
null
,
"actionType参数不能为空"
);
}
var
result
=
null
;
switch
(
pobj
.
actionProcess
)
{
case
"jd"
:
//京东
result
=
await
this
.
jdOpActionProcess
(
pobj
.
actionProcess
,
pobj
.
actionType
,
pobj
.
actionBody
);
break
;
default
:
result
=
system
.
getResult
(
null
,
"actionProcess参数错误"
);
break
;
}
var
result
=
await
this
.
opActionProcess
(
pobj
.
actionType
,
pobj
.
actionBody
);
return
result
;
}
async
jdOpActionProcess
(
action_process
,
action_type
,
action_body
)
{
async
opActionProcess
(
action_type
,
action_body
)
{
var
opResult
=
null
;
switch
(
action_type
)
{
case
"test"
:
//测试
...
...
igirl-zcapi/app/base/api/impl/action/tmTools.js
View file @
cf71f2c1
...
...
@@ -8,29 +8,17 @@ class TmToolsAPI extends APIBase {
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async
springBoard
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
actionProcess
)
{
return
system
.
getResult
(
null
,
"actionProcess参数不能为空"
);
}
if
(
!
pobj
.
actionType
)
{
return
system
.
getResult
(
null
,
"actionType参数不能为空"
);
}
var
result
=
null
;
switch
(
pobj
.
actionProcess
)
{
case
"jd"
:
//京东
result
=
await
this
.
jdOpActionProcess
(
pobj
.
actionProcess
,
pobj
.
actionType
,
pobj
.
actionBody
);
break
;
default
:
result
=
system
.
getResult
(
null
,
"actionProcess参数错误"
);
break
;
}
var
result
=
await
this
.
opActionProcess
(
pobj
.
actionType
,
pobj
.
actionBody
);
return
result
;
}
async
jdOpActionProcess
(
action_process
,
action_type
,
action_body
)
{
async
opActionProcess
(
action_type
,
action_body
)
{
var
opResult
=
null
;
switch
(
action_type
)
{
// sy
...
...
igirl-zcapi/app/base/service/app.base.js
0 → 100644
View file @
cf71f2c1
const
system
=
require
(
"../system"
);
const
moment
=
require
(
'moment'
)
const
settings
=
require
(
"../../config/settings"
);
const
md5
=
require
(
"MD5"
);
class
AppServiceBase
{
constructor
()
{
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
}
/**
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
*/
async
verifySign
(
params
,
app_key
)
{
if
(
!
params
)
{
return
system
.
getResult
(
null
,
"请求参数为空"
);
}
if
(
!
params
.
sign
)
{
return
system
.
getResult
(
null
,
"请求参数sign为空"
);
}
var
signArr
=
[];
var
keys
=
Object
.
keys
(
params
).
sort
();
if
(
keys
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"请求参数信息为空"
);
}
for
(
let
k
=
0
;
k
<
keys
.
length
;
k
++
)
{
const
tKey
=
keys
[
k
];
if
(
tKey
!=
"sign"
&&
params
[
tKey
]
&&
!
(
params
[
tKey
]
instanceof
Array
))
{
signArr
.
push
(
tKey
+
"="
+
params
[
tKey
]);
}
}
if
(
signArr
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"请求参数组装签名参数信息为空"
);
}
var
resultSignStr
=
signArr
.
join
(
"&"
)
+
"&key="
+
app_key
;
var
resultTmpSign
=
md5
(
resultSignStr
).
toUpperCase
();
if
(
params
.
sign
!=
resultTmpSign
)
{
return
system
.
getResult
(
null
,
"返回值签名验证失败"
);
}
return
system
.
getResultSuccess
();
}
async
restPostUrl
(
pobj
,
url
)
{
var
rtn
=
await
this
.
restClient
.
execPost
(
pobj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"restPost is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
async
execPostUrl
(
pobj
,
url
)
{
var
rtn
=
await
this
.
execClient
.
execPost
(
pobj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
}
module
.
exports
=
AppServiceBase
;
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