fix: 修复entity和detection搜索时随意输入字段,没有错误提示且resource为空的问题
(cherry picked from commit df183c1836)
This commit is contained in:
@@ -1135,12 +1135,12 @@ export default class Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return returnObj
|
return returnObj
|
||||||
} else if (q.indexOf(' LIKE ') > -1 || q.indexOf(' like ') > -1) {
|
} else if (q.toLowerCase().indexOf(' like ') > -1) {
|
||||||
return {
|
return {
|
||||||
key: q,
|
key: q,
|
||||||
isKey: true
|
isKey: true
|
||||||
}
|
}
|
||||||
} else if (q.indexOf(' IN ') > -1 || q.indexOf(' in ') > -1) {
|
} else if (q.toLowerCase().indexOf(' in ') > -1) {
|
||||||
return {
|
return {
|
||||||
key: q,
|
key: q,
|
||||||
isKey: true
|
isKey: true
|
||||||
@@ -1154,15 +1154,79 @@ export default class Parser {
|
|||||||
return { key: '[' + key + ']', isKey: false }
|
return { key: '[' + key + ']', isKey: false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (q && (q.indexOf(' IN ') > -1 || q.indexOf(' in ') > -1 || q.indexOf(' LIKE ') > -1 || q.indexOf(' like ') > -1)) {
|
} else if (q && (q.toLowerCase().indexOf(' in ') > -1 || q.toLowerCase().indexOf(' like ') > -1 || q.toLowerCase().indexOf('has(') > -1)) {
|
||||||
return {
|
const lowerQ = q.toLowerCase()
|
||||||
key: q,
|
if (lowerQ.indexOf(' and ') > -1) {
|
||||||
isKey: true
|
if (this.checkStrIncludeAnd(q)) {
|
||||||
|
q = q.replace(/ and /g, ' AND ')
|
||||||
|
}
|
||||||
|
const arr = q.split(' AND ')
|
||||||
|
|
||||||
|
for (let i = 0; i < arr.length; i++) {
|
||||||
|
const item = arr[i].toLowerCase()
|
||||||
|
if (item.indexOf(' like ') > -1) {
|
||||||
|
const key = item.substring(0, item.indexOf(' like '))
|
||||||
|
const obj = this.columnList.find(t => t.label.toLowerCase() === key.toLowerCase())
|
||||||
|
if (!obj) {
|
||||||
|
return { key: '[' + key + ']', isKey: false }
|
||||||
|
}
|
||||||
|
} else if (item.indexOf(' in ') > -1) {
|
||||||
|
const key = q.substring(0, q.indexOf(' in '))
|
||||||
|
const obj = this.columnList.find(t => t.label.toLowerCase() === key.toLowerCase())
|
||||||
|
if (!obj) {
|
||||||
|
return { key: '[' + key + ']', isKey: false }
|
||||||
|
}
|
||||||
|
} else if (item.indexOf('has(') > -1) {
|
||||||
|
const key = item.substring(0, 4)
|
||||||
|
if (key === 'has(') {
|
||||||
|
const label = item.substring(4, item.indexOf(','))
|
||||||
|
if (label) {
|
||||||
|
const obj = this.columnList.find(t => t.label.toLowerCase() === label.toLowerCase())
|
||||||
|
if (!obj) {
|
||||||
|
return { key: '[' + key + ']', isKey: false }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { key: 'in index ' + q.indexOf('has('), isKey: false }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { key: 'in index ' + q.indexOf('has('), isKey: false }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { key: q, isKey: true }
|
||||||
|
} else if (lowerQ.indexOf(' like ') > -1) {
|
||||||
|
const key = q.substring(0, q.indexOf(' like '))
|
||||||
|
const obj = this.columnList.find(t => t.label.toLowerCase() === key.toLowerCase())
|
||||||
|
if (obj) {
|
||||||
|
return { key: obj.label + q.substring(lowerQ.indexOf(' like '), q.length), isKey: true }
|
||||||
|
} else {
|
||||||
|
return { key: '[' + key + ']', isKey: false }
|
||||||
|
}
|
||||||
|
} else if (lowerQ.indexOf(' in ') > -1) {
|
||||||
|
const key = q.substring(0, q.indexOf(' in '))
|
||||||
|
const obj = this.columnList.find(t => t.label.toLowerCase() === key.toLowerCase())
|
||||||
|
if (obj) {
|
||||||
|
return { key: obj.label + q.substring(lowerQ.indexOf(' in '), q.length), isKey: true }
|
||||||
|
} else {
|
||||||
|
return { key: '[' + key + ']', isKey: false }
|
||||||
|
}
|
||||||
|
} else if (lowerQ.indexOf('has(') > -1) {
|
||||||
|
const key = lowerQ.substring(0, 4)
|
||||||
|
if (key === 'has(') {
|
||||||
|
const label = lowerQ.substring(4, lowerQ.indexOf(','))
|
||||||
|
if (label) {
|
||||||
|
const obj = this.columnList.find(t => t.label.toLowerCase() === label.toLowerCase())
|
||||||
|
if (obj) {
|
||||||
|
return { key: 'has(' + obj.label + q.substring(lowerQ.indexOf(','), lowerQ.length), isKey: true }
|
||||||
|
} else {
|
||||||
|
return { key: '[' + key + ']', isKey: false }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { key: 'in index 5', isKey: false }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { key: 'in index 5', isKey: false }
|
||||||
}
|
}
|
||||||
} else if (q && (q.indexOf('has(') > -1)) {
|
|
||||||
return {
|
|
||||||
key: q,
|
|
||||||
isKey: true
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
@@ -1257,6 +1321,10 @@ export default class Parser {
|
|||||||
})
|
})
|
||||||
return str
|
return str
|
||||||
} else if (!result) {
|
} else if (!result) {
|
||||||
|
// 此处为不能识别的字段,不能当成app处理
|
||||||
|
if (str.indexOf('=') > -1 || str.toLowerCase().indexOf(' in ') > -1 || str.toLowerCase().indexOf(' like ') > -1 || str.toLowerCase().indexOf('has(') > -1) {
|
||||||
|
return str
|
||||||
|
}
|
||||||
const regex = /^["']|["']$/
|
const regex = /^["']|["']$/
|
||||||
// 去除两侧引号,如'1.1.1.1',避免校验时被当作app
|
// 去除两侧引号,如'1.1.1.1',避免校验时被当作app
|
||||||
if (regex.test(str)) {
|
if (regex.test(str)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user