Compare commits

...

2 Commits

Author SHA1 Message Date
wangliwen af93de247d Merge branch 'dev' 2022-12-29 09:28:01 +08:00
wangliwen a087eea1bf pageWithattr接口判断name参数长度、中文 来分别使用分词或like查询 2022-12-29 09:27:53 +08:00
1 changed files with 10 additions and 1 deletions

View File

@ -101,6 +101,8 @@ import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -601,8 +603,15 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
} }
break; break;
} }
Boolean nonChinese = jsonObject.containsKey("nonChinese") ? jsonObject.getBoolean("nonChinese") : Boolean.FALSE; // 不传默认为中文走全文索引 Boolean nonChinese = jsonObject.containsKey("nonChinese") ? jsonObject.getBoolean("nonChinese") : Boolean.FALSE; // 不传默认为中文走全文索引
Pattern isChinese = Pattern.compile("[\u4e00-\u9fa5]"); // 中文
String name = jsonObject.containsKey("name") ? jsonObject.getString("name") : "";
Matcher isChineseMatcher = isChinese.matcher(name);
if (!nonChinese && (isChineseMatcher.matches() && name.length() < 2)) {
nonChinese = Boolean.TRUE;
} else if (name.length() < 2) { // 长度小于分词长度2
nonChinese = Boolean.TRUE;
}
//默认按上架时间降序排列 //默认按上架时间降序排列
String orderField; String orderField;
if (StringUtils.isBlank(jsonObject.getString("orderField"))) { if (StringUtils.isBlank(jsonObject.getString("orderField"))) {