xzwebx-httpfilter 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HttpFilter.js +14 -12
- package/package.json +1 -1
package/HttpFilter.js
CHANGED
|
@@ -10,11 +10,10 @@ let FieldMap = {}
|
|
|
10
10
|
let IsCheckedRes = true
|
|
11
11
|
async function response(req, res, next) {
|
|
12
12
|
let retData = {
|
|
13
|
-
codeKey: '
|
|
13
|
+
codeKey: 'SUCC',
|
|
14
14
|
data: []
|
|
15
15
|
}
|
|
16
|
-
retData
|
|
17
|
-
return res.send(res.Msg(retData, req.interfaceInfo.rspMsgId))
|
|
16
|
+
return res.Msg(retData)
|
|
18
17
|
}
|
|
19
18
|
function SetIsCheckedRes(isCheckedRes) {
|
|
20
19
|
if (isCheckedRes) {
|
|
@@ -31,7 +30,7 @@ function Init(language, resultCodeMap, tipsMap, moduleMap, moduleInterfaceMap, f
|
|
|
31
30
|
FieldMap = fieldMap
|
|
32
31
|
}
|
|
33
32
|
function MSG(params, rspMsgId) {
|
|
34
|
-
if (IsCheckedRes && rspMsgId) {
|
|
33
|
+
if (IsCheckedRes && this.interfaceInfo.rspMsgId) {
|
|
35
34
|
let retMsgData = cycleCheckParams(FieldMap[rspMsgId], params.data)
|
|
36
35
|
if (retMsgData) {
|
|
37
36
|
return MSG({codeKey: 'CLT_ERR', msg: retMsgData, data: params.data})
|
|
@@ -68,11 +67,13 @@ function MSG(params, rspMsgId) {
|
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
return this.send(
|
|
71
|
+
{
|
|
72
|
+
code: code,
|
|
73
|
+
msg: msg,
|
|
74
|
+
data: params.data
|
|
75
|
+
}
|
|
76
|
+
)
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
function SetRoutes(app, express, projectPath) {
|
|
@@ -116,16 +117,17 @@ function CheckReq(req, res, next) {
|
|
|
116
117
|
|
|
117
118
|
const module = ModuleMap[baseUrl]
|
|
118
119
|
if (!module) {
|
|
119
|
-
return res.
|
|
120
|
+
return res.Msg({codeKey: 'CLT_ERR', msg: ['WEBX_ERR_URL']})
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
if (!ModuleInterfaceMap[module.id] ||
|
|
123
124
|
!ModuleInterfaceMap[module.id][subUri] ||
|
|
124
125
|
!ModuleInterfaceMap[module.id][subUri][req.method.toLowerCase()]) {
|
|
125
|
-
return res.
|
|
126
|
+
return res.Msg({codeKey: 'CLT_ERR', msg: ['WEBX_ERR_URL']})
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
req['interfaceInfo'] = ModuleInterfaceMap[module.id][subUri][req.method.toLowerCase()]
|
|
130
|
+
res['interfaceInfo'] = ModuleInterfaceMap[module.id][subUri][req.method.toLowerCase()]
|
|
129
131
|
let reqMsgId = ModuleInterfaceMap[module.id][subUri][req.method.toLowerCase()].reqMsgId
|
|
130
132
|
if (!reqMsgId) {
|
|
131
133
|
return next()
|
|
@@ -133,7 +135,7 @@ function CheckReq(req, res, next) {
|
|
|
133
135
|
|
|
134
136
|
let retMsgData = cycleCheckParams(FieldMap[reqMsgId], req.body)
|
|
135
137
|
if (retMsgData) {
|
|
136
|
-
return res.
|
|
138
|
+
return res.Msg({codeKey: 'CLT_ERR', msg: retMsgData})
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
return next()
|