前言
数据全等查询:皮卡猪
数据左模糊查询 :*卡猪
数据右模糊查询:皮卡*
数据全局模糊查询: 卡
/**
* 通用模糊查询语句
* @param searchContent 模糊查询json对象字符串,如下示例
* searchContent: {"maskSearch:"123",fieldSearch:"column_name"}"
* @param mode 模糊查询模式,默认right,以右边做模糊查询;mode:left,right,其他全部默认左右的模糊查询
* @returns {string}
*/
fuzzyQueryWhere : function (searchContent, mode = 'right') {
let where = "";
//模糊内容查询
//判断字段是否为空
if (searchContent != null &&searchContent.maskSearch !=null) {
//清除前端入参左右空格
searchContent.maskSearch = common.stringHelper.trim(searchContent.maskSearch);
if (mode == 'right') {
where += ` and ${searchContent.fieldSearch} like '${searchContent.maskSearch}%'`;
}
else if (mode == 'left') {
where += ` and ${searchContent.fieldSearch} like '%${searchContent.maskSearch}'`;
}
else if (mode == 'no_contain') {
where += ` and ${searchContent.fieldSearch} = '${searchContent.maskSearch}'`;
}
else {
where += ` and ${searchContent.fieldSearch} like '%${searchContent.maskSearch}%'`;
}
}
return where;
https://www.pexels.com/zh-cn/collections/1379530-l47756n/
https://www.pexels.com/zh-cn/collections/1379530-f17napd/
https://www.pexels.com/zh-cn/collections/1379530-h8ytruy/
https://www.pexels.com/zh-cn/collections/1379530-8jblapw/
https://www.pexels.com/zh-cn/collections/1379530-rq09wrw/
https://www.pexels.com/zh-cn/collections/1379530-jjkewjv/
https://www.pexels.com/zh-cn/collections/1379530-bwriptj/
https://www.pexels.com/zh-cn/collections/1379530-tmawq1m/
https://www.pexels.com/zh-cn/collections/1379530-0sy22lm/
https://www.pexels.com/zh-cn/collections/1379530-yooiscz/
https://www.pexels.com/zh-cn/collections/1379530-dewn8cg/
https://www.pexels.com/zh-cn/collections/1379530-cgtat9t/
https://www.pexels.com/zh-cn/collections/1379530-9jdvtks/
https://www.pexels.com/zh-cn/collections/1379530-pevbeef/
https://infogram.com/1379530-1h7v4pdmyydjj4k?live
https://infogram.com/1379530-1h7v4pdmyy3xj4k?live
https://infogram.com/1379530-1h7v4pdmyy3784k?live
https://infogram.com/1379530-1hnp27exrr5py4g?live
https://infogram.com/1379530-1hnq41oxee31p23?live