xzwebx-httpfilter 2.4.2 → 2.4.4
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/.idea/modules.xml +8 -0
- package/.idea/xzwebx-httpfilter.iml +12 -0
- package/HttpFilter.js +44 -55
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/xzwebx-httpfilter.iml" filepath="$PROJECT_DIR$/.idea/xzwebx-httpfilter.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
package/HttpFilter.js
CHANGED
|
@@ -134,73 +134,59 @@ class http {
|
|
|
134
134
|
}
|
|
135
135
|
checkReq(req, res, next) {
|
|
136
136
|
let reqMsgId = req.interfaceInfo.reqMsgId
|
|
137
|
-
if (!reqMsgId) {
|
|
137
|
+
if (!reqMsgId || !this.FieldMap[reqMsgId]) {
|
|
138
138
|
return next()
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
let
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
|
|
141
|
+
for (let fieldName in this.FieldMap[reqMsgId]) {
|
|
142
|
+
let retMsgData = this.cycleCheckParams(this.FieldMap[reqMsgId][fieldName], req.body)
|
|
143
|
+
if (retMsgData) {
|
|
144
|
+
return res.Msg({codeKey: 'CLT_ERR', msg: retMsgData})
|
|
145
|
+
}
|
|
144
146
|
}
|
|
145
|
-
|
|
147
|
+
|
|
146
148
|
return next()
|
|
147
149
|
}
|
|
148
150
|
cycleCheckParams(msgFieldMap, data) {
|
|
149
|
-
let retMsgData = null
|
|
150
|
-
|
|
151
151
|
if (!msgFieldMap) {
|
|
152
152
|
return null
|
|
153
153
|
}
|
|
154
|
-
|
|
155
|
-
let fCfgItem =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
isRoot = false
|
|
159
|
-
fCfgItem = msgFieldMap['__FieldCfg']
|
|
154
|
+
|
|
155
|
+
let fCfgItem = msgFieldMap['__FieldCfg']
|
|
156
|
+
if (!fCfgItem) {
|
|
157
|
+
return null
|
|
160
158
|
}
|
|
161
|
-
|
|
159
|
+
|
|
160
|
+
let retMsgData = null
|
|
161
|
+
if (fCfgItem.fieldType == 'STR') {
|
|
162
|
+
retMsgData = this.isStringOk(fCfgItem, data)
|
|
163
|
+
} else if (fCfgItem.fieldType == 'INT') {
|
|
164
|
+
retMsgData = this.isIntOk(fCfgItem, data)
|
|
165
|
+
} else if (fCfgItem.fieldType == 'OBJ') {
|
|
166
|
+
retMsgData = this.isObjOk(fCfgItem, data)
|
|
167
|
+
} else if (fCfgItem.fieldType == 'LIST') {
|
|
168
|
+
retMsgData = this.isListOk(fCfgItem, data)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (retMsgData) {
|
|
172
|
+
return retMsgData
|
|
173
|
+
}
|
|
174
|
+
|
|
162
175
|
for (let fieldName in msgFieldMap) {
|
|
163
|
-
if (
|
|
164
|
-
fCfgItem = msgFieldMap[fieldName]['__FieldCfg']
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (fCfgItem.fieldType == 'STR') {
|
|
168
|
-
retMsgData = this.isStringOk(fCfgItem, data)
|
|
169
|
-
} else if (fCfgItem.fieldType == 'INT') {
|
|
170
|
-
retMsgData = this.isIntOk(fCfgItem, data)
|
|
171
|
-
} else if (fCfgItem.fieldType == 'OBJ') {
|
|
172
|
-
retMsgData = this.isObjOk(fCfgItem, data)
|
|
173
|
-
} else if (fCfgItem.fieldType == 'LIST') {
|
|
174
|
-
retMsgData = this.isListOk(fCfgItem, data)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (retMsgData) {
|
|
178
|
-
return retMsgData
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (fieldName == '__FieldCfg') {
|
|
176
|
+
if (fieldName === '__FieldCfg') {
|
|
182
177
|
continue
|
|
183
178
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
for (let idx in data) {
|
|
190
|
-
retMsgData = this.cycleCheckParams(msgFieldMap[fieldName], data[idx])
|
|
191
|
-
if (retMsgData) {
|
|
192
|
-
return retMsgData
|
|
193
|
-
}
|
|
179
|
+
if (fCfgItem.fieldType === 'LIST' || (fCfgItem.fieldType === 'OBJ' && msgFieldMap[fieldName]['__FieldCfg'].keyType === 'VSTR')) {
|
|
180
|
+
for (let idx in data) {
|
|
181
|
+
retMsgData = this.cycleCheckParams(msgFieldMap[fieldName], data[idx])
|
|
182
|
+
if (retMsgData) {
|
|
183
|
+
return retMsgData
|
|
194
184
|
}
|
|
195
185
|
}
|
|
196
186
|
} else {
|
|
197
|
-
|
|
198
|
-
retMsgData = this.cycleCheckParams(msgFieldMap[fieldName], data)
|
|
199
|
-
} else {
|
|
200
|
-
retMsgData = this.cycleCheckParams(msgFieldMap[fieldName], data[fieldName])
|
|
201
|
-
}
|
|
187
|
+
retMsgData = this.cycleCheckParams(msgFieldMap[fieldName], data[fieldName])
|
|
202
188
|
}
|
|
203
|
-
|
|
189
|
+
|
|
204
190
|
if (retMsgData) {
|
|
205
191
|
return retMsgData
|
|
206
192
|
}
|
|
@@ -534,11 +520,14 @@ function response(params) {
|
|
|
534
520
|
if (p.IsCheckedRes &&
|
|
535
521
|
this.interfaceInfo &&
|
|
536
522
|
this.interfaceInfo.rspMsgId &&
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
523
|
+
p.FieldMap[this.interfaceInfo.rspMsgId] &&
|
|
524
|
+
params.codeKey === 'SUCC') {
|
|
525
|
+
for (let fieldName in p.FieldMap[this.interfaceInfo.rspMsgId]) {
|
|
526
|
+
let retMsgData = p.cycleCheckParams(p.FieldMap[this.interfaceInfo.rspMsgId][fieldName], params.data)
|
|
527
|
+
if (retMsgData) {
|
|
528
|
+
params.codeKey = 'SVC_ERR'
|
|
529
|
+
params.msg = retMsgData
|
|
530
|
+
}
|
|
542
531
|
}
|
|
543
532
|
}
|
|
544
533
|
let code = ''
|