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
f9d09321
Commit
f9d09321
authored
Jul 31, 2020
by
v_vjyjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
98fa7496
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
icp-deliver/app/base/system.js
+19
-19
No files found.
icp-deliver/app/base/system.js
View file @
f9d09321
...
...
@@ -3,7 +3,7 @@ var objsettings = require("../config/objsettings");
var
settings
=
require
(
"../config/settings"
);
const
request
=
require
(
'request'
);
class
System
{
static
declare
(
ns
)
{
static
declare
(
ns
)
{
var
ar
=
ns
.
split
(
'.'
);
var
root
=
System
;
for
(
var
i
=
0
,
len
=
ar
.
length
;
i
<
len
;
++
i
)
{
...
...
@@ -16,15 +16,15 @@ class System {
}
}
}
static
async
delReq
(
url
,
qdata
)
{
static
async
delReq
(
url
,
qdata
)
{
let
rtn
=
{}
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
request
.
del
({
url
:
url
,
qs
:
qdata
},
function
(
error
,
response
,
body
)
{
rtn
.
statusCode
=
response
.
statusCode
if
(
!
error
)
{
rtn
.
statusCode
=
response
.
statusCode
if
(
body
)
{
let
data
=
JSON
.
parse
(
body
)
rtn
.
data
=
data
...
...
@@ -39,7 +39,7 @@ class System {
})
return
promise
;
}
static
async
getReq
(
url
,
qdata
)
{
static
async
getReq
(
url
,
qdata
)
{
let
rtn
=
{}
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
request
.
get
({
...
...
@@ -47,8 +47,8 @@ class System {
json
:
true
,
qs
:
qdata
},
function
(
error
,
response
,
body
)
{
rtn
.
statusCode
=
response
.
statusCode
;
if
(
!
error
)
{
rtn
.
statusCode
=
response
.
statusCode
;
if
(
body
)
{
rtn
.
data
=
body
}
else
{
...
...
@@ -62,7 +62,7 @@ class System {
})
return
promise
;
}
static
async
postJsonTypeReq
(
url
,
data
,
md
=
"POST"
)
{
static
async
postJsonTypeReq
(
url
,
data
,
md
=
"POST"
)
{
let
rtn
=
{}
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
request
({
...
...
@@ -75,8 +75,8 @@ class System {
},
body
:
data
},
function
(
error
,
response
,
body
)
{
rtn
.
statusCode
=
response
.
statusCode
if
(
!
error
)
{
rtn
.
statusCode
=
response
.
statusCode
if
(
body
)
{
rtn
.
data
=
body
}
else
{
...
...
@@ -90,15 +90,15 @@ class System {
})
return
promise
;
}
static
async
post3wFormTypeReq
(
url
,
data
)
{
static
async
post3wFormTypeReq
(
url
,
data
)
{
let
rtn
=
{}
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
request
.
post
({
url
:
url
,
form
:
data
},
function
(
error
,
response
,
body
)
{
rtn
.
statusCode
=
response
.
statusCode
if
(
!
error
)
{
rtn
.
statusCode
=
response
.
statusCode
let
data
=
JSON
.
parse
(
body
)
rtn
.
data
=
data
resv
(
rtn
);
...
...
@@ -109,7 +109,7 @@ class System {
})
return
promise
;
}
static
async
postMpFormTypeReq
(
url
,
formdata
)
{
static
async
postMpFormTypeReq
(
url
,
formdata
)
{
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
request
.
post
({
url
:
url
,
...
...
@@ -131,7 +131,7 @@ class System {
* @param {*} okmsg 操作成功的描述
* @param {*} req 请求头信息
*/
static
getResult
(
data
,
opmsg
=
"操作成功"
,
req
)
{
static
getResult
(
data
,
opmsg
=
"操作成功"
,
req
)
{
return
{
status
:
!
data
?
-
1
:
0
,
msg
:
opmsg
,
...
...
@@ -144,7 +144,7 @@ class System {
* @param {*} data 操作成功返回的数据
* @param {*} okmsg 操作成功的描述
*/
static
getResultSuccess
(
data
,
okmsg
=
"success"
)
{
static
getResultSuccess
(
data
,
okmsg
=
"success"
)
{
return
{
status
:
0
,
msg
:
okmsg
,
...
...
@@ -157,7 +157,7 @@ class System {
* @param {*} errmsg 操作失败的描述,默认为fail
* @param {*} data 操作失败返回的数据
*/
static
getResultFail
(
status
=
-
1
,
errmsg
=
"fail"
,
data
=
null
)
{
static
getResultFail
(
status
=
-
1
,
errmsg
=
"fail"
,
data
=
null
)
{
return
{
status
:
status
,
msg
:
errmsg
,
...
...
@@ -169,14 +169,14 @@ class System {
* @param {*} errmsg 操作失败的描述,默认为fail
* @param {*} data 操作失败返回的数据
*/
static
getResultError
(
errmsg
=
"fail"
,
data
=
null
)
{
static
getResultError
(
errmsg
=
"fail"
,
data
=
null
)
{
return
{
status
:
-
200
,
msg
:
errmsg
,
data
:
data
,
};
}
static
register
(
key
,
ClassObj
,
groupName
,
filename
)
{
static
register
(
key
,
ClassObj
,
groupName
,
filename
)
{
if
(
System
.
objTable
[
key
]
!=
null
)
{
throw
new
Error
(
"相同key的对象已经存在"
);
}
else
{
...
...
@@ -191,7 +191,7 @@ class System {
return
System
.
objTable
[
key
];
}
static
getObject
(
objpath
)
{
static
getObject
(
objpath
)
{
var
pathArray
=
objpath
.
split
(
"."
);
var
packageName
=
pathArray
[
0
];
var
groupName
=
pathArray
[
1
];
...
...
@@ -233,7 +233,7 @@ class System {
}
}
static
getSysConfig
()
{
static
getSysConfig
()
{
var
configPath
=
settings
.
basepath
+
"/app/base/db/metadata/index.js"
;
// if(settings.env=="dev"){
// console.log("delete "+configPath+"cache config");
...
...
@@ -243,7 +243,7 @@ class System {
var
configValue
=
require
(
configPath
);
return
configValue
.
config
;
}
static
get_client_ip
(
req
)
{
static
get_client_ip
(
req
)
{
var
ip
=
req
.
headers
[
'x-forwarded-for'
]
||
req
.
ip
||
req
.
connection
.
remoteAddress
||
...
...
@@ -267,7 +267,7 @@ class System {
* @param {*} resultInfo 返回结果
* @param {*} errorInfo 错误信息
*/
static
execLogs
(
opTitle
,
params
,
identifyCode
,
resultInfo
,
errorInfo
)
{
static
execLogs
(
opTitle
,
params
,
identifyCode
,
resultInfo
,
errorInfo
)
{
var
reqUrl
=
settings
.
logUrl
();
let
isLogData
=
true
if
(
params
.
method
&&
(
params
.
method
.
indexOf
(
"find"
)
>=
0
||
params
.
method
.
indexOf
(
"get"
)
>=
0
))
{
...
...
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