修改标题检索bug
This commit is contained in:
+31
-9
@@ -168,16 +168,16 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
|||||||
select.append("( ");
|
select.append("( ");
|
||||||
for (int i = 0; i < searchContent.length; i++) {
|
for (int i = 0; i < searchContent.length; i++) {
|
||||||
regexp.append(searchContent[i]);
|
regexp.append(searchContent[i]);
|
||||||
String str = searchContent[i].length() > 1 ?
|
StringBuilder ss = new StringBuilder();
|
||||||
searchContent[i].substring(0, searchContent[i].length() - 1) : "";
|
if(isNumericAndAlphabetic(searchContent[i])){
|
||||||
if(!StringUtils.isEmpty(str)){
|
// 英文 数字
|
||||||
int arr = str.length();
|
replaceLength(searchContent, i, ss, " ");
|
||||||
StringBuilder ss = new StringBuilder();
|
}else{
|
||||||
for (int i1 = 0; i1 < arr; i1++) {
|
// 中文
|
||||||
ss.append("ℵ");
|
replaceLength(searchContent, i, ss, " ");
|
||||||
}
|
ss.append(" ");
|
||||||
str = ss.toString();
|
|
||||||
}
|
}
|
||||||
|
String str = ss.toString();
|
||||||
select.append(" LENGTH(standard_name) - LENGTH(REPLACE(standard_name, '").append(searchContent[i])
|
select.append(" LENGTH(standard_name) - LENGTH(REPLACE(standard_name, '").append(searchContent[i])
|
||||||
.append("',").append(" '").append(str).append("')) ");
|
.append("',").append(" '").append(str).append("')) ");
|
||||||
if(i != searchContent.length - 1){
|
if(i != searchContent.length - 1){
|
||||||
@@ -212,6 +212,28 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
|||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void replaceLength(String[] searchContent, int i, StringBuilder ss, String s2) {
|
||||||
|
String str = searchContent[i].length() > 1 ?
|
||||||
|
searchContent[i].substring(0, searchContent[i].length() - 1) : "";
|
||||||
|
if (!StringUtils.isEmpty(str)) {
|
||||||
|
int arr = str.length();
|
||||||
|
for (int i1 = 0; i1 < arr; i1++) {
|
||||||
|
ss.append(s2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断字符串是否全部由数字和英文字符组成
|
||||||
|
* @param str 输入的字符串
|
||||||
|
* @return 如果字符串只包含数字和英文字符,则返回true,否则返回false
|
||||||
|
*/
|
||||||
|
public static boolean isNumericAndAlphabetic(String str) {
|
||||||
|
// 正则表达式,匹配数字和英文字母
|
||||||
|
String pattern = "^[A-Za-z0-9]+$";
|
||||||
|
return str.matches(pattern);
|
||||||
|
}
|
||||||
|
|
||||||
private void addContent(String searchContent, IPage<LawsHomeNormalSearchVO> pageList) {
|
private void addContent(String searchContent, IPage<LawsHomeNormalSearchVO> pageList) {
|
||||||
if(CollectionUtils.isEmpty(pageList.getRecords())) {
|
if(CollectionUtils.isEmpty(pageList.getRecords())) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user