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
88e24c2b
Commit
88e24c2b
authored
Jul 15, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
2eaa1def
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
55 deletions
+36
-55
center-manage/app/base/api/api.base.js
+3
-31
center-manage/app/base/controller/ctl.base.js
+4
-16
center-manage/app/base/utils/logClient.js
+29
-8
No files found.
center-manage/app/base/api/api.base.js
View file @
88e24c2b
...
...
@@ -4,6 +4,7 @@ const settings = require("../../config/settings");
class
APIBase
{
constructor
()
{
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
logClient
=
system
.
getObject
(
"util.logClient"
);
}
getUUID
()
{
var
uuid
=
uuidv4
();
...
...
@@ -51,39 +52,10 @@ class APIBase{
}
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
rtn
.
requestId
=
this
.
getUUID
()
req
.
params
.
param
=
pobj
let
t
=
req
.
xctx
.
codetitle
if
(
t
==
''
){
t
=
"外部调用"
}
system
.
execLogs
(
t
,
req
.
params
,
pobj
.
company_id
,
rtn
,
null
).
then
(
res
=>
{
if
(
res
&&
res
.
status
==
1
){
console
.
log
(
"log.....success"
)
}
else
{
console
.
log
(
"log.....fail"
)
}
}).
catch
(
e
=>
{
console
.
log
(
"log.....fail"
)
})
this
.
logClient
.
log
(
pobj
,
req
,
rtn
)
return
rtn
;
}
catch
(
e
)
{
let
rtn
=
{}
rtn
.
requestId
=
this
.
getUUID
()
req
.
params
.
param
=
pobj
let
t
=
req
.
xctx
.
codetitle
if
(
t
==
''
){
t
=
"外部调用"
}
system
.
execLogs
(
t
,
req
.
params
,
pobj
.
company_id
,
rtn
,
e
.
stack
).
then
(
res
=>
{
if
(
res
&&
res
.
status
==
1
){
console
.
log
(
"log.....success"
)
}
else
{
console
.
log
(
"log.....fail"
)
}
}).
catch
(
e
=>
{
console
.
log
(
"log.....fail"
)
})
this
.
logClient
.
log
(
pobj
,
req
,{})
console
.
log
(
e
.
stack
,
"api调用异常--error..................."
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,请联系管理员"
);
return
rtnerror
;
...
...
center-manage/app/base/controller/ctl.base.js
View file @
88e24c2b
...
...
@@ -6,6 +6,7 @@ class CtlBase {
this
.
serviceName
=
sname
;
this
.
service
=
system
.
getObject
(
"service."
+
gname
+
"."
+
sname
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
logClient
=
system
.
getObject
(
"util.logClient"
);
}
getUUID
()
{
var
uuid
=
uuidv4
();
...
...
@@ -85,20 +86,7 @@ class CtlBase {
}
pobj
.
bizpath
=
req
.
xctx
.
bizpath
;
}
async
log
(
pobj
,
req
,
rtn
)
{
rtn
.
requestId
=
this
.
getUUID
()
req
.
params
.
param
=
pobj
//第三个字段应该存公司id
system
.
execLogs
(
req
.
xctx
.
codetitle
,
req
.
params
,
pobj
.
company_id
,
rtn
,
null
).
then
(
res
=>
{
if
(
res
&&
res
.
status
==
1
)
{
console
.
log
(
"log.....success"
)
}
else
{
console
.
log
(
"log.....fail"
)
}
}).
catch
(
e
=>
{
console
.
log
(
"log.....fail"
)
})
}
async
doexec
(
methodname
,
pobj
,
query
,
req
)
{
try
{
let
xarg
=
await
this
.
setContextParams
(
pobj
,
query
,
req
);
...
...
@@ -106,10 +94,10 @@ class CtlBase {
return
system
.
getResultFail
(...
xarg
);
}
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
//this
.log(pobj,req,rtn)
this
.
logClient
.
log
(
pobj
,
req
,
rtn
)
return
rtn
;
}
catch
(
e
)
{
//this.log(pobj,req,rtn
)
this
.
logClient
.
log
(
pobj
,
req
,{}
)
console
.
log
(
e
.
stack
,
"出现异常,请联系管理员......."
);
return
system
.
getResultFail
(
-
200
,
"出现异常,请联系管理员"
);
}
...
...
center-manage/app/base/utils/logClient.js
View file @
88e24c2b
// var log4js = require('log4js');
var
settings
=
require
(
"../../config/settings"
);
class
LogClient
{
constructor
(){
// log4js.configure(settings.basepath+"/app/config/log4js.json");
// this.logerApp=log4js.getLogger("app");
// this.logerHttp=log4js.getLogger("http");
}
var
settings
=
require
(
"../../config/settings"
);
const
uuidv4
=
require
(
'uuid/v4'
);
const
system
=
require
(
"../system"
);
class
LogClient
{
constructor
()
{
// log4js.configure(settings.basepath+"/app/config/log4js.json");
// this.logerApp=log4js.getLogger("app");
// this.logerHttp=log4js.getLogger("http");
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
return
u
;
}
async
log
(
pobj
,
req
,
rtn
)
{
rtn
.
requestId
=
this
.
getUUID
()
req
.
params
.
param
=
pobj
//第三个字段应该存公司id
system
.
execLogs
(
req
.
xctx
.
codetitle
,
req
.
params
,
pobj
.
company_id
,
rtn
,
null
).
then
(
res
=>
{
if
(
res
&&
res
.
status
==
1
)
{
console
.
log
(
"log.....success"
)
}
else
{
console
.
log
(
"log.....fail"
)
}
}).
catch
(
e
=>
{
console
.
log
(
"log.....fail"
)
})
}
}
module
.
exports
=
LogClient
;
module
.
exports
=
LogClient
;
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