@imedx/ics-imedx-chromely-plugin-index-examine
Advanced tools
Comparing version 0.0.2-beta.2 to 0.0.2-beta.3
@@ -127,8 +127,13 @@ import icsChromelyRequest from '@icreate/ics-chromely-js-sdk'; | ||
* @param keys:关键字 | ||
* @param exact:精确匹配字段和值 精确匹配字段和值 { type : 1 } | ||
* @returns 成功返回结果 | ||
*/ | ||
DictIndex.query = function (category, keys) { | ||
DictIndex.query = function (category, keys, exact) { | ||
if (keys === void 0) { keys = ''; } | ||
if (exact === void 0) { exact = null; } | ||
if (icsChromelyRequest.isChromely) { | ||
return IndexExamine.query('DictionaryIndex', category, escapeSpecialCharacters(keys)); | ||
if (Array.isArray(category)) | ||
return IndexExamine.query('DictionaryIndex', category, ''); | ||
else | ||
return IndexExamine.query('DictionaryIndex', category, this.QueryCondition(category, escapeSpecialCharacters(keys), exact)); | ||
} | ||
@@ -146,8 +151,10 @@ else { | ||
* @param keys:关键字 | ||
* @param exact:精确匹配字段和值 { type : 1 } | ||
* @returns 成功返回结果 | ||
*/ | ||
DictIndex.page = function (pageIndex, pageSize, category, keys) { | ||
DictIndex.page = function (pageIndex, pageSize, category, keys, exact) { | ||
if (keys === void 0) { keys = ''; } | ||
if (exact === void 0) { exact = null; } | ||
if (icsChromelyRequest.isChromely) { | ||
return IndexExamine.page('DictionaryIndex', pageIndex, pageSize, category, escapeSpecialCharacters(keys)); | ||
return IndexExamine.page('DictionaryIndex', pageIndex, pageSize, category, this.QueryCondition(category, escapeSpecialCharacters(keys), exact)); | ||
} | ||
@@ -158,2 +165,20 @@ else { | ||
}; | ||
/** | ||
* 查询条件组装 | ||
* @param keys | ||
* @returns | ||
*/ | ||
DictIndex.QueryCondition = function (category, keys, exact) { | ||
// return `(id:*${keys}* OR name:"*${keys}*" OR spellCode:*${keys}* OR strokeCode:*${keys}*)` | ||
var condition = []; | ||
if (keys.trim()) { | ||
condition.push("(id:*" + keys + "* OR name:\"*" + keys + "*\" OR spellCode:*" + keys + "* OR strokeCode:*" + keys + "*)"); | ||
} | ||
if (exact) { | ||
Object.keys(exact).forEach(function (key) { | ||
condition.push(key + ":" + exact[key]); | ||
}); | ||
} | ||
return condition.join(' AND '); | ||
}; | ||
DictIndex.like = ['ID', 'NAME', 'SPELL_CODE', 'STROKE_CODE']; | ||
@@ -160,0 +185,0 @@ DictIndex.exact = {}; |
@@ -133,8 +133,13 @@ (function (global, factory) { | ||
* @param keys:关键字 | ||
* @param exact:精确匹配字段和值 精确匹配字段和值 { type : 1 } | ||
* @returns 成功返回结果 | ||
*/ | ||
DictIndex.query = function (category, keys) { | ||
DictIndex.query = function (category, keys, exact) { | ||
if (keys === void 0) { keys = ''; } | ||
if (exact === void 0) { exact = null; } | ||
if (icsChromelyRequest.isChromely) { | ||
return IndexExamine.query('DictionaryIndex', category, escapeSpecialCharacters(keys)); | ||
if (Array.isArray(category)) | ||
return IndexExamine.query('DictionaryIndex', category, ''); | ||
else | ||
return IndexExamine.query('DictionaryIndex', category, this.QueryCondition(category, escapeSpecialCharacters(keys), exact)); | ||
} | ||
@@ -152,8 +157,10 @@ else { | ||
* @param keys:关键字 | ||
* @param exact:精确匹配字段和值 { type : 1 } | ||
* @returns 成功返回结果 | ||
*/ | ||
DictIndex.page = function (pageIndex, pageSize, category, keys) { | ||
DictIndex.page = function (pageIndex, pageSize, category, keys, exact) { | ||
if (keys === void 0) { keys = ''; } | ||
if (exact === void 0) { exact = null; } | ||
if (icsChromelyRequest.isChromely) { | ||
return IndexExamine.page('DictionaryIndex', pageIndex, pageSize, category, escapeSpecialCharacters(keys)); | ||
return IndexExamine.page('DictionaryIndex', pageIndex, pageSize, category, this.QueryCondition(category, escapeSpecialCharacters(keys), exact)); | ||
} | ||
@@ -164,2 +171,20 @@ else { | ||
}; | ||
/** | ||
* 查询条件组装 | ||
* @param keys | ||
* @returns | ||
*/ | ||
DictIndex.QueryCondition = function (category, keys, exact) { | ||
// return `(id:*${keys}* OR name:"*${keys}*" OR spellCode:*${keys}* OR strokeCode:*${keys}*)` | ||
var condition = []; | ||
if (keys.trim()) { | ||
condition.push("(id:*" + keys + "* OR name:\"*" + keys + "*\" OR spellCode:*" + keys + "* OR strokeCode:*" + keys + "*)"); | ||
} | ||
if (exact) { | ||
Object.keys(exact).forEach(function (key) { | ||
condition.push(key + ":" + exact[key]); | ||
}); | ||
} | ||
return condition.join(' AND '); | ||
}; | ||
DictIndex.like = ['ID', 'NAME', 'SPELL_CODE', 'STROKE_CODE']; | ||
@@ -166,0 +191,0 @@ DictIndex.exact = {}; |
@@ -21,8 +21,13 @@ "use strict"; | ||
* @param keys:关键字 | ||
* @param exact:精确匹配字段和值 精确匹配字段和值 { type : 1 } | ||
* @returns 成功返回结果 | ||
*/ | ||
DictIndex.query = function (category, keys) { | ||
DictIndex.query = function (category, keys, exact) { | ||
if (keys === void 0) { keys = ''; } | ||
if (exact === void 0) { exact = null; } | ||
if (ics_chromely_js_sdk_1.default.isChromely) { | ||
return index_examine_1.default.query('DictionaryIndex', category, utils_1.escapeSpecialCharacters(keys)); | ||
if (Array.isArray(category)) | ||
return index_examine_1.default.query('DictionaryIndex', category, ''); | ||
else | ||
return index_examine_1.default.query('DictionaryIndex', category, this.QueryCondition(category, utils_1.escapeSpecialCharacters(keys), exact)); | ||
} | ||
@@ -40,8 +45,10 @@ else { | ||
* @param keys:关键字 | ||
* @param exact:精确匹配字段和值 { type : 1 } | ||
* @returns 成功返回结果 | ||
*/ | ||
DictIndex.page = function (pageIndex, pageSize, category, keys) { | ||
DictIndex.page = function (pageIndex, pageSize, category, keys, exact) { | ||
if (keys === void 0) { keys = ''; } | ||
if (exact === void 0) { exact = null; } | ||
if (ics_chromely_js_sdk_1.default.isChromely) { | ||
return index_examine_1.default.page('DictionaryIndex', pageIndex, pageSize, category, utils_1.escapeSpecialCharacters(keys)); | ||
return index_examine_1.default.page('DictionaryIndex', pageIndex, pageSize, category, this.QueryCondition(category, utils_1.escapeSpecialCharacters(keys), exact)); | ||
} | ||
@@ -52,2 +59,20 @@ else { | ||
}; | ||
/** | ||
* 查询条件组装 | ||
* @param keys | ||
* @returns | ||
*/ | ||
DictIndex.QueryCondition = function (category, keys, exact) { | ||
// return `(id:*${keys}* OR name:"*${keys}*" OR spellCode:*${keys}* OR strokeCode:*${keys}*)` | ||
var condition = []; | ||
if (keys.trim()) { | ||
condition.push("(id:*" + keys + "* OR name:\"*" + keys + "*\" OR spellCode:*" + keys + "* OR strokeCode:*" + keys + "*)"); | ||
} | ||
if (exact) { | ||
Object.keys(exact).forEach(function (key) { | ||
condition.push(key + ":" + exact[key]); | ||
}); | ||
} | ||
return condition.join(' AND '); | ||
}; | ||
DictIndex.like = ['ID', 'NAME', 'SPELL_CODE', 'STROKE_CODE']; | ||
@@ -54,0 +79,0 @@ DictIndex.exact = {}; |
@@ -8,5 +8,8 @@ export default class DictIndex { | ||
* @param keys:关键字 | ||
* @param exact:精确匹配字段和值 精确匹配字段和值 { type : 1 } | ||
* @returns 成功返回结果 | ||
*/ | ||
static query(category: string | Array<string>, keys?: string): Promise<any>; | ||
static query(category: string | Array<string>, keys?: string, exact?: { | ||
[key: string]: string; | ||
} | null): Promise<any>; | ||
/** | ||
@@ -19,5 +22,14 @@ * 分页查询索引 | ||
* @param keys:关键字 | ||
* @param exact:精确匹配字段和值 { type : 1 } | ||
* @returns 成功返回结果 | ||
*/ | ||
static page(pageIndex: number, pageSize: number, category: string, keys?: string): Promise<any>; | ||
static page(pageIndex: number, pageSize: number, category: string, keys?: string, exact?: { | ||
[key: string]: string; | ||
} | null): Promise<any>; | ||
/** | ||
* 查询条件组装 | ||
* @param keys | ||
* @returns | ||
*/ | ||
private static QueryCondition; | ||
} |
{ | ||
"name": "@imedx/ics-imedx-chromely-plugin-index-examine", | ||
"version": "0.0.2-beta.2", | ||
"version": "0.0.2-beta.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -46,5 +46,8 @@ ### 引入 | ||
* @param keys:关键字 | ||
* @param exact:精确匹配字段和值 精确匹配字段和值 { type : 1 },传入多个字典时不支持 | ||
* @returns 成功返回结果,如果category是数组则返回{"DICT_SEX":[{},{}],"DICT_NATION":[{},{}]} | ||
*/ | ||
DictIndex.query(category: string|string[], keys: string = ''):Promise<any> | ||
DictIndex.query(category: string|string[], keys: string = '',exact: { | ||
[key: string]: string | ||
} | null = null):Promise<any> | ||
``` | ||
@@ -60,2 +63,3 @@ | ||
* @param keys:关键字 | ||
* @param exact:精确匹配字段和值 精确匹配字段和值 { type : 1 } | ||
* @returns 成功返回结果 | ||
@@ -67,3 +71,6 @@ */ | ||
category: string, | ||
keys: string = '' | ||
keys: string = '', | ||
exact: { | ||
[key: string]: string | ||
} | null = null | ||
): Promise<any> | ||
@@ -70,0 +77,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
171847
2060
222