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
cb79012f
Commit
cb79012f
authored
Mar 30, 2021
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加推送判断
parent
bbb32a1e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
28 deletions
+39
-28
center-channel/app/base/service/impl/common/signSve.js
+1
-1
center-channel/app/base/utils/execClientNew.js
+38
-27
No files found.
center-channel/app/base/service/impl/common/signSve.js
View file @
cb79012f
...
...
@@ -192,7 +192,7 @@ module.exports = SignService;
// };
//需求
// var obj={
// "intentionBizId": "baidu_test_0008
7
",
// "intentionBizId": "baidu_test_0008
8
",
// "phone": "18506013355",
// "userName": "测试03",
// "description": "测试03描述",
...
...
center-channel/app/base/utils/execClientNew.js
View file @
cb79012f
...
...
@@ -6,22 +6,24 @@ const settings = require("../../../app/config/settings");
const
axios
=
require
(
'axios'
);
const
moment
=
require
(
'moment'
);
const
uuid
=
require
(
'uuid'
);
class
ExecClientNew
{
constructor
()
{
this
.
cmdGetPattern
=
"curl -G -X GET '{url}'"
;
this
.
cmdPostPattern
=
"curl -k -H 'Content-type: application/json' -d '{data}' {url}"
;
// this.cmdPushDataPostPattern = "curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'appkey:{appkey}' -d '{data}' {url}";
}
/**
* 带超时时间的post请求
* @param {*} execFile 执行文件
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
* @param {*} timeOut 超时时间设置,单位秒
* @param {*} req 请求信息
*/
* 带超时时间的post请求
* @param {*} execFile 执行文件
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
* @param {*} timeOut 超时时间设置,单位秒
* @param {*} req 请求信息
*/
async
execPostTimeOutByBusiness
(
execFile
,
params
,
url
,
ContentType
,
headData
,
timeOut
=
60
,
req
)
{
var
rtn
=
null
;
var
reqResult
=
null
;
...
...
@@ -99,6 +101,7 @@ class ExecClientNew {
return
reqResult
;
}
}
/**
* 记录日志信息
* @param {*} opTitle 操作的标题
...
...
@@ -109,37 +112,39 @@ class ExecClientNew {
*/
async
execLogs
(
opTitle
,
params
,
identifyCode
,
resultInfo
,
errorInfo
)
{
var
reqUrl
=
settings
.
opNewLogUrl
();
params
=
typeof
params
===
'object'
?
JSON
.
stringify
(
params
)
:
params
||
""
;
r
esultInfo
=
typeof
resultInfo
===
'object'
?
JSON
.
stringify
(
resultInfo
)
:
resultInfo
||
""
;
e
rrorInfo
=
typeof
errorInfo
===
'object'
?
JSON
.
stringify
(
errorInfo
)
:
errorInfo
||
""
;
let
tmpParams1
=
typeof
params
===
'object'
?
JSON
.
stringify
(
params
)
:
params
||
""
;
let
tmpR
esultInfo
=
typeof
resultInfo
===
'object'
?
JSON
.
stringify
(
resultInfo
)
:
resultInfo
||
""
;
let
tmpE
rrorInfo
=
typeof
errorInfo
===
'object'
?
JSON
.
stringify
(
errorInfo
)
:
errorInfo
||
""
;
var
tmpParams
=
{
opTitle
:
opTitle
||
""
,
identifyCode
:
identifyCode
||
""
,
messageBody
:
params
,
resultInfo
:
r
esultInfo
||
""
,
errorInfo
:
e
rrorInfo
||
""
,
messageBody
:
tmpParams1
,
resultInfo
:
tmpR
esultInfo
||
""
,
errorInfo
:
tmpE
rrorInfo
||
""
,
requestId
:
resultInfo
?
resultInfo
.
requestId
||
""
:
""
,
created_at
:
moment
().
format
(
"YYYY-MM-DD HH:mm:ss:SSS"
),
timestamp
:
Date
.
now
()
}
this
.
execPostTimeOut
(
tmpParams
,
reqUrl
,
'application/json'
,
null
,
20
);
}
/**
* get请求
* @param {*} params 提交的数据-格式JSON
* @param {*} url
* @param {*} headData 请求信息,JSON格式
* @param {*} url
* @param {*} headData 请求信息,JSON格式
*/
async
execGet
(
params
,
url
,
headData
)
{
let
cmd
=
this
.
FetchGetCmd
(
params
,
url
,
headData
);
var
result
=
await
this
.
exec
(
cmd
);
return
result
;
}
/**
*
*
* @param {*} params 提交的数据JSON格式
* @param {*} url
* @param {*} headData 请求信息,JSON格式
* @param {*} url
* @param {*} headData 请求信息,JSON格式
* @param {*} timeOut 超时时间
*/
async
execGetTimeOut
(
params
,
url
,
headData
,
timeOut
=
5000
)
{
...
...
@@ -148,9 +153,10 @@ class ExecClientNew {
var
options
=
{
timeout
:
timeOut
,
};
const
{
stdout
,
stderr
}
=
await
exec
(
cmd
,
options
);
return
{
stdout
,
stderr
};
const
{
stdout
,
stderr
}
=
await
exec
(
cmd
,
options
);
return
{
stdout
,
stderr
};
}
/**
* 带超时时间的post请求
* @param {*} params 请求数据-json格式
...
...
@@ -169,6 +175,7 @@ class ExecClientNew {
var
result
=
await
this
.
exec
(
cmd
,
options
,
headData
);
return
result
;
}
/**
* 带超时时间的post请求
* @param {*} params 请求数据-json格式
...
...
@@ -195,14 +202,16 @@ class ExecClientNew {
async
exec
(
cmd
)
{
//await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值
//异常需要try/catch自己捕获或外部catch捕获
const
{
stdout
,
stderr
}
=
await
exec
(
cmd
);
return
{
stdout
,
stderr
};
const
{
stdout
,
stderr
}
=
await
exec
(
cmd
);
return
{
stdout
,
stderr
};
}
FetchGetCmd
(
params
,
url
,
headData
)
{
var
cmd
=
this
.
cmdGetPattern
.
replace
(
/
\{
data
\}
/g
,
params
).
replace
(
/
\{
url
\}
/g
,
url
);
return
cmd
;
}
FetchPostCmd
(
params
,
url
,
ContentType
,
headData
)
{
if
(
!
ContentType
)
{
ContentType
=
"application/json"
;
...
...
@@ -245,9 +254,9 @@ class ExecClientNew {
}
/**
* 返回20位业务订单号
* @param {*} prefix 业务前缀
*/
* 返回20位业务订单号
* @param {*} prefix 业务前缀
*/
async
getBusUid
(
prefix
)
{
prefix
=
(
prefix
||
""
);
if
(
prefix
)
{
...
...
@@ -262,6 +271,7 @@ class ExecClientNew {
var
timStr
=
moment
().
format
(
"YYYYMMDDHHmm"
);
return
prefix
+
timStr
+
uidStr
;
}
/**
* 返回指定长度的字符串
* @param {*} len 返回长度
...
...
@@ -286,6 +296,7 @@ class ExecClientNew {
}
return
uuid
.
join
(
''
);
}
//--------------------------------------------------辅助方法end-----------------
}
...
...
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