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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
center-channel/app/base/service/impl/common/signSve.js
+1
-1
center-channel/app/base/utils/execClientNew.js
+21
-10
No files found.
center-channel/app/base/service/impl/common/signSve.js
View file @
cb79012f
...
@@ -192,7 +192,7 @@ module.exports = SignService;
...
@@ -192,7 +192,7 @@ module.exports = SignService;
// };
// };
//需求
//需求
// var obj={
// var obj={
// "intentionBizId": "baidu_test_0008
7
",
// "intentionBizId": "baidu_test_0008
8
",
// "phone": "18506013355",
// "phone": "18506013355",
// "userName": "测试03",
// "userName": "测试03",
// "description": "测试03描述",
// "description": "测试03描述",
...
...
center-channel/app/base/utils/execClientNew.js
View file @
cb79012f
...
@@ -6,12 +6,14 @@ const settings = require("../../../app/config/settings");
...
@@ -6,12 +6,14 @@ const settings = require("../../../app/config/settings");
const
axios
=
require
(
'axios'
);
const
axios
=
require
(
'axios'
);
const
moment
=
require
(
'moment'
);
const
moment
=
require
(
'moment'
);
const
uuid
=
require
(
'uuid'
);
const
uuid
=
require
(
'uuid'
);
class
ExecClientNew
{
class
ExecClientNew
{
constructor
()
{
constructor
()
{
this
.
cmdGetPattern
=
"curl -G -X GET '{url}'"
;
this
.
cmdGetPattern
=
"curl -G -X GET '{url}'"
;
this
.
cmdPostPattern
=
"curl -k -H 'Content-type: application/json' -d '{data}' {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}";
// this.cmdPushDataPostPattern = "curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'appkey:{appkey}' -d '{data}' {url}";
}
}
/**
/**
* 带超时时间的post请求
* 带超时时间的post请求
* @param {*} execFile 执行文件
* @param {*} execFile 执行文件
...
@@ -99,6 +101,7 @@ class ExecClientNew {
...
@@ -99,6 +101,7 @@ class ExecClientNew {
return
reqResult
;
return
reqResult
;
}
}
}
}
/**
/**
* 记录日志信息
* 记录日志信息
* @param {*} opTitle 操作的标题
* @param {*} opTitle 操作的标题
...
@@ -109,21 +112,22 @@ class ExecClientNew {
...
@@ -109,21 +112,22 @@ class ExecClientNew {
*/
*/
async
execLogs
(
opTitle
,
params
,
identifyCode
,
resultInfo
,
errorInfo
)
{
async
execLogs
(
opTitle
,
params
,
identifyCode
,
resultInfo
,
errorInfo
)
{
var
reqUrl
=
settings
.
opNewLogUrl
();
var
reqUrl
=
settings
.
opNewLogUrl
();
params
=
typeof
params
===
'object'
?
JSON
.
stringify
(
params
)
:
params
||
""
;
let
tmpParams1
=
typeof
params
===
'object'
?
JSON
.
stringify
(
params
)
:
params
||
""
;
r
esultInfo
=
typeof
resultInfo
===
'object'
?
JSON
.
stringify
(
resultInfo
)
:
resultInfo
||
""
;
let
tmpR
esultInfo
=
typeof
resultInfo
===
'object'
?
JSON
.
stringify
(
resultInfo
)
:
resultInfo
||
""
;
e
rrorInfo
=
typeof
errorInfo
===
'object'
?
JSON
.
stringify
(
errorInfo
)
:
errorInfo
||
""
;
let
tmpE
rrorInfo
=
typeof
errorInfo
===
'object'
?
JSON
.
stringify
(
errorInfo
)
:
errorInfo
||
""
;
var
tmpParams
=
{
var
tmpParams
=
{
opTitle
:
opTitle
||
""
,
opTitle
:
opTitle
||
""
,
identifyCode
:
identifyCode
||
""
,
identifyCode
:
identifyCode
||
""
,
messageBody
:
params
,
messageBody
:
tmpParams1
,
resultInfo
:
r
esultInfo
||
""
,
resultInfo
:
tmpR
esultInfo
||
""
,
errorInfo
:
e
rrorInfo
||
""
,
errorInfo
:
tmpE
rrorInfo
||
""
,
requestId
:
resultInfo
?
resultInfo
.
requestId
||
""
:
""
,
requestId
:
resultInfo
?
resultInfo
.
requestId
||
""
:
""
,
created_at
:
moment
().
format
(
"YYYY-MM-DD HH:mm:ss:SSS"
),
created_at
:
moment
().
format
(
"YYYY-MM-DD HH:mm:ss:SSS"
),
timestamp
:
Date
.
now
()
timestamp
:
Date
.
now
()
}
}
this
.
execPostTimeOut
(
tmpParams
,
reqUrl
,
'application/json'
,
null
,
20
);
this
.
execPostTimeOut
(
tmpParams
,
reqUrl
,
'application/json'
,
null
,
20
);
}
}
/**
/**
* get请求
* get请求
* @param {*} params 提交的数据-格式JSON
* @param {*} params 提交的数据-格式JSON
...
@@ -135,6 +139,7 @@ class ExecClientNew {
...
@@ -135,6 +139,7 @@ class ExecClientNew {
var
result
=
await
this
.
exec
(
cmd
);
var
result
=
await
this
.
exec
(
cmd
);
return
result
;
return
result
;
}
}
/**
/**
*
*
* @param {*} params 提交的数据JSON格式
* @param {*} params 提交的数据JSON格式
...
@@ -148,9 +153,10 @@ class ExecClientNew {
...
@@ -148,9 +153,10 @@ class ExecClientNew {
var
options
=
{
var
options
=
{
timeout
:
timeOut
,
timeout
:
timeOut
,
};
};
const
{
stdout
,
stderr
}
=
await
exec
(
cmd
,
options
);
const
{
stdout
,
stderr
}
=
await
exec
(
cmd
,
options
);
return
{
stdout
,
stderr
};
return
{
stdout
,
stderr
};
}
}
/**
/**
* 带超时时间的post请求
* 带超时时间的post请求
* @param {*} params 请求数据-json格式
* @param {*} params 请求数据-json格式
...
@@ -169,6 +175,7 @@ class ExecClientNew {
...
@@ -169,6 +175,7 @@ class ExecClientNew {
var
result
=
await
this
.
exec
(
cmd
,
options
,
headData
);
var
result
=
await
this
.
exec
(
cmd
,
options
,
headData
);
return
result
;
return
result
;
}
}
/**
/**
* 带超时时间的post请求
* 带超时时间的post请求
* @param {*} params 请求数据-json格式
* @param {*} params 请求数据-json格式
...
@@ -195,14 +202,16 @@ class ExecClientNew {
...
@@ -195,14 +202,16 @@ class ExecClientNew {
async
exec
(
cmd
)
{
async
exec
(
cmd
)
{
//await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值
//await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值
//异常需要try/catch自己捕获或外部catch捕获
//异常需要try/catch自己捕获或外部catch捕获
const
{
stdout
,
stderr
}
=
await
exec
(
cmd
);
const
{
stdout
,
stderr
}
=
await
exec
(
cmd
);
return
{
stdout
,
stderr
};
return
{
stdout
,
stderr
};
}
}
FetchGetCmd
(
params
,
url
,
headData
)
{
FetchGetCmd
(
params
,
url
,
headData
)
{
var
cmd
=
this
.
cmdGetPattern
.
replace
(
var
cmd
=
this
.
cmdGetPattern
.
replace
(
/
\{
data
\}
/g
,
params
).
replace
(
/
\{
url
\}
/g
,
url
);
/
\{
data
\}
/g
,
params
).
replace
(
/
\{
url
\}
/g
,
url
);
return
cmd
;
return
cmd
;
}
}
FetchPostCmd
(
params
,
url
,
ContentType
,
headData
)
{
FetchPostCmd
(
params
,
url
,
ContentType
,
headData
)
{
if
(
!
ContentType
)
{
if
(
!
ContentType
)
{
ContentType
=
"application/json"
;
ContentType
=
"application/json"
;
...
@@ -262,6 +271,7 @@ class ExecClientNew {
...
@@ -262,6 +271,7 @@ class ExecClientNew {
var
timStr
=
moment
().
format
(
"YYYYMMDDHHmm"
);
var
timStr
=
moment
().
format
(
"YYYYMMDDHHmm"
);
return
prefix
+
timStr
+
uidStr
;
return
prefix
+
timStr
+
uidStr
;
}
}
/**
/**
* 返回指定长度的字符串
* 返回指定长度的字符串
* @param {*} len 返回长度
* @param {*} len 返回长度
...
@@ -286,6 +296,7 @@ class ExecClientNew {
...
@@ -286,6 +296,7 @@ class ExecClientNew {
}
}
return
uuid
.
join
(
''
);
return
uuid
.
join
(
''
);
}
}
//--------------------------------------------------辅助方法end-----------------
//--------------------------------------------------辅助方法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