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
417cbfe5
Commit
417cbfe5
authored
Jul 13, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
7abd3bce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
32 deletions
+88
-32
brg-user-center/app/base/api/api.base.js
+42
-5
brg-user-center/app/base/api/impl/action/statisticData.js
+16
-0
brg-user-center/app/config/routes/api.js
+30
-27
No files found.
brg-user-center/app/base/api/api.base.js
View file @
417cbfe5
...
@@ -64,6 +64,43 @@ class APIBase {
...
@@ -64,6 +64,43 @@ class APIBase {
}
}
//-----------------------新的模式------------------开始
//-----------------------新的模式------------------开始
async
doexecOverviewMethod
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
try
{
var
shaStr
=
await
sha256
(
JSON
.
stringify
(
pobj
));
//查询缓存
var
cacheRes
=
await
this
.
redisClient
.
getCache
(
shaStr
);
if
(
cacheRes
)
{
return
JSON
.
parse
(
cacheRes
);
}
var
result
=
await
this
[
methodname
](
pobj
,
query
,
req
);
if
(
!
result
)
{
result
=
system
.
getResult
(
null
,
"请求的方法返回值为空"
);
}
this
.
execClient
.
execLogs
(
"reqPath:"
+
req
.
path
+
"执行结果"
,
pobj
,
"brg-user-center-doexecOverviewMethod"
,
result
,
null
);
//保存缓存
await
this
.
redisClient
.
setWithEx
(
shaStr
,
JSON
.
stringify
(
result
),
5
);
return
result
;
}
catch
(
error
)
{
var
stackStr
=
error
.
stack
?
error
.
stack
:
JSON
.
stringify
(
error
);
console
.
log
(
stackStr
,
"api调用出现异常,请联系管理员.........."
)
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"系统出现异常"
);
this
.
execClient
.
execLogs
(
"reqPath:"
+
req
.
path
+
"执行异常"
,
pobj
,
"brg-user-center-doexecOverviewMethod"
,
rtnerror
,
stackStr
);
if
(
pobj
.
Action
&&
action
)
{
return
{
"Response"
:
{
"Status"
:
-
200
,
"Error"
:
{
"Code"
:
"FailedOperation"
,
//操作失败
"Message"
:
req
.
path
+
"执行异常"
},
"RequestId"
:
rtnerror
.
requestId
}
};
}
return
rtnerror
;
}
}
async
doexecMethod
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
async
doexecMethod
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
var
action
=
this
.
userCenterAction
[
req
.
body
.
Action
];
var
action
=
this
.
userCenterAction
[
req
.
body
.
Action
];
...
@@ -95,7 +132,7 @@ class APIBase {
...
@@ -95,7 +132,7 @@ class APIBase {
}
}
result
.
requestId
=
pobj
.
RequestId
||
uuid
.
v1
();
result
.
requestId
=
pobj
.
RequestId
||
uuid
.
v1
();
var
tmpResult
=
reqParams
.
actionType
&&
reqParams
.
actionType
.
indexOf
(
"List"
)
<
0
?
result
:
{
status
:
result
.
status
,
message
:
result
.
message
,
requestId
:
result
.
requestId
};
var
tmpResult
=
reqParams
.
actionType
&&
reqParams
.
actionType
.
indexOf
(
"List"
)
<
0
?
result
:
{
status
:
result
.
status
,
message
:
result
.
message
,
requestId
:
result
.
requestId
};
this
.
execClient
.
execLogs
(
"reqPath:"
+
req
.
path
+
"执行结果"
,
reqParams
,
"brg-user-center-
apibase
"
,
tmpResult
,
null
);
this
.
execClient
.
execLogs
(
"reqPath:"
+
req
.
path
+
"执行结果"
,
reqParams
,
"brg-user-center-
doexecMethod
"
,
tmpResult
,
null
);
if
(
pobj
.
Action
&&
action
)
{
if
(
pobj
.
Action
&&
action
)
{
result
=
await
this
.
handleTxResult
(
result
);
result
=
await
this
.
handleTxResult
(
result
);
delete
req
.
body
[
"Action"
];
delete
req
.
body
[
"Action"
];
...
@@ -109,7 +146,7 @@ class APIBase {
...
@@ -109,7 +146,7 @@ class APIBase {
console
.
log
(
stackStr
,
"api调用出现异常,请联系管理员.........."
)
console
.
log
(
stackStr
,
"api调用出现异常,请联系管理员.........."
)
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"系统出现异常"
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"系统出现异常"
);
rtnerror
.
requestId
=
pobj
.
RequestId
||
uuid
.
v1
();
rtnerror
.
requestId
=
pobj
.
RequestId
||
uuid
.
v1
();
this
.
execClient
.
execLogs
(
"reqPath:"
+
req
.
path
+
"执行异常"
,
reqParams
,
"brg-user-center-
apibase
"
,
rtnerror
,
stackStr
);
this
.
execClient
.
execLogs
(
"reqPath:"
+
req
.
path
+
"执行异常"
,
reqParams
,
"brg-user-center-
doexecMethod
"
,
rtnerror
,
stackStr
);
if
(
pobj
.
Action
&&
action
)
{
if
(
pobj
.
Action
&&
action
)
{
return
{
return
{
"Response"
:
{
"Response"
:
{
...
@@ -245,14 +282,14 @@ class APIBase {
...
@@ -245,14 +282,14 @@ class APIBase {
result
=
system
.
getResult
(
null
,
"请求的方法返回值为空"
);
result
=
system
.
getResult
(
null
,
"请求的方法返回值为空"
);
}
}
result
.
requestId
=
pobj
.
RequestId
||
uuid
.
v1
();
result
.
requestId
=
pobj
.
RequestId
||
uuid
.
v1
();
this
.
execClient
.
execLogs
(
"reqPath:"
+
req
.
path
+
"brg请求结果"
,
param
,
"brg-user-center-brg
-apibase
"
,
result
,
null
);
this
.
execClient
.
execLogs
(
"reqPath:"
+
req
.
path
+
"brg请求结果"
,
param
,
"brg-user-center-brg
DoexecMethod
"
,
result
,
null
);
return
result
;
return
result
;
}
catch
(
error
)
{
}
catch
(
error
)
{
var
stackStr
=
error
.
stack
?
error
.
stack
:
JSON
.
stringify
(
error
);
var
stackStr
=
error
.
stack
?
error
.
stack
:
JSON
.
stringify
(
error
);
console
.
log
(
stackStr
,
"api-brg请求调用出现异常,请联系管理员.........."
)
console
.
log
(
stackStr
,
"api-brg请求调用出现异常,请联系管理员.........."
)
;
var
rtnerror
=
system
.
getResultTX
(
-
1
,
""
,
"brg请求出现异常,error:"
+
stackStr
,
null
);
var
rtnerror
=
system
.
getResultTX
(
-
1
,
""
,
"brg请求出现异常,error:"
+
stackStr
,
null
);
rtnerror
.
requestId
=
pobj
.
RequestId
||
uuid
.
v1
();
rtnerror
.
requestId
=
pobj
.
RequestId
||
uuid
.
v1
();
this
.
execClient
.
execLogs
(
"reqPath:"
+
req
.
path
+
"brg请求出现异常"
,
param
,
"brg-user-center-brg
-apibase
"
,
null
,
stackStr
);
this
.
execClient
.
execLogs
(
"reqPath:"
+
req
.
path
+
"brg请求出现异常"
,
param
,
"brg-user-center-brg
DoexecMethod
"
,
null
,
stackStr
);
return
rtnerror
;
return
rtnerror
;
}
}
}
}
...
...
brg-user-center/app/base/api/impl/action/statisticData.js
0 → 100755
View file @
417cbfe5
var
APIBase
=
require
(
"../../api.base"
);
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
class
icName
extends
APIBase
{
constructor
()
{
super
();
this
.
utilsIcNameSve
=
system
.
getObject
(
"service.utilsSve.utilsIcNameSve"
);
}
async
getVat
(
pobj
,
qobj
,
req
)
{
return
system
.
getResultSuccess
();
}
async
getBusinessRegistration
(
pobj
,
qobj
,
req
)
{
return
system
.
getResultSuccess
();
}
}
module
.
exports
=
icName
;
brg-user-center/app/config/routes/api.js
View file @
417cbfe5
var
url
=
require
(
"url"
);
var
url
=
require
(
"url"
);
var
system
=
require
(
"../../base/system"
);
var
system
=
require
(
"../../base/system"
);
var
bodyParser
=
require
(
'body-parser'
);
var
bodyParser
=
require
(
'body-parser'
);
const
{
JSON
}
=
require
(
"sequelize"
);
const
utilsAuthSve
=
system
.
getObject
(
"service.utilsSve.utilsAuthSve"
);
const
utilsAuthSve
=
system
.
getObject
(
"service.utilsSve.utilsAuthSve"
);
module
.
exports
=
function
(
app
)
{
module
.
exports
=
function
(
app
)
{
//-----------------------新的模式---------api---------开始
//-----------------------新的模式---------api---------开始
app
.
all
(
"/overview/*"
,
async
function
(
req
,
res
,
next
)
{
app
.
post
(
'/overview/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
result
=
system
.
getResult
(
null
,
"req method must is post"
);
var
classPath
=
req
.
params
[
"qname"
];
if
(
req
.
method
!=
"POST"
)
{
var
methodName
=
req
.
params
[
"method"
];
res
.
end
(
JSON
.
stringify
(
result
));
var
gname
=
req
.
params
[
"gname"
];
return
;
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
system
.
get_client_ip
(
req
);
req
.
clientIp
=
tClientIp
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
classname
=
classPath
;
var
keys
=
Object
.
keys
(
req
.
body
);
if
(
keys
.
length
>
0
)
{
req
.
body
=
JSON
.
parse
(
keys
[
0
]);
}
}
console
.
log
(
req
.
body
,
"....body......"
);
// var param = bodyParser.urlencoded({ extended: false })
params
.
push
(
gname
);
// if (["getAppTokenByHosts", "getAppTokenByAppKey"].indexOf(req.body.actionType) >= 0) {
params
.
push
(
methodName
);
// req.body.actionBody.appHosts = req.host;
params
.
push
(
req
.
body
);
// next();
params
.
push
(
req
.
query
);
// return;
params
.
push
(
req
);
// }
var
p
=
null
;
// if (req.path.indexOf("/taskapi/") >= 0) {
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
// next();
if
(
invokeObj
[
"doexecOverviewMethod"
])
{
// return;
p
=
invokeObj
[
"doexecOverviewMethod"
].
apply
(
invokeObj
,
params
);
// }
}
next
();
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
});
});
});
app
.
all
(
"/api/*"
,
async
function
(
req
,
res
,
next
)
{
app
.
all
(
"/api/*"
,
async
function
(
req
,
res
,
next
)
{
...
@@ -31,15 +43,6 @@ module.exports = function (app) {
...
@@ -31,15 +43,6 @@ module.exports = function (app) {
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
// if (["getAppTokenByHosts", "getAppTokenByAppKey"].indexOf(req.body.actionType) >= 0) {
// req.body.actionBody.appHosts = req.host;
// next();
// return;
// }
// if (req.path.indexOf("/taskapi/") >= 0) {
// next();
// return;
// }
next
();
next
();
});
});
...
...
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