|
|
@@ -61,6 +61,7 @@ namespace OASystem.API.OAMethodLib.GenericSearch
|
|
|
|
|
|
return new SearchResult<T>
|
|
|
{
|
|
|
+ Message = $"搜索成功!耗时:{stopwatch.ElapsedMilliseconds}ms",
|
|
|
Items = scoredItems,
|
|
|
TotalCount = totalCount,
|
|
|
Keyword = request.Keyword,
|
|
|
@@ -326,6 +327,7 @@ namespace OASystem.API.OAMethodLib.GenericSearch
|
|
|
if (!string.IsNullOrWhiteSpace(request.Keyword))
|
|
|
{
|
|
|
var searchAnalysis = AnalyzeSearchPattern(request.Keyword);
|
|
|
+ var keywordConditions = new List<string>(); // 专门存放关键字相关条件
|
|
|
|
|
|
// 符号分割的关键字条件
|
|
|
foreach (var segment in searchAnalysis.SymbolSegments)
|
|
|
@@ -339,7 +341,8 @@ namespace OASystem.API.OAMethodLib.GenericSearch
|
|
|
parameters.Add(new SugarParameter(paramName, $"%{cleanSegment}%"));
|
|
|
return $"{field} LIKE {paramName}";
|
|
|
});
|
|
|
- whereConditions.Add($"({string.Join(" OR ", fieldConditions)})");
|
|
|
+ // 每个片段内部使用 OR 连接不同字段
|
|
|
+ keywordConditions.Add($"({string.Join(" OR ", fieldConditions)})");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -353,8 +356,16 @@ namespace OASystem.API.OAMethodLib.GenericSearch
|
|
|
parameters.Add(new SugarParameter(paramName, $"%{charStr}%"));
|
|
|
return $"{field} LIKE {paramName}";
|
|
|
});
|
|
|
- whereConditions.Add($"({string.Join(" OR ", fieldConditions)})");
|
|
|
+ // 每个单字内部使用 OR 连接不同字段
|
|
|
+ keywordConditions.Add($"({string.Join(" OR ", fieldConditions)})");
|
|
|
}
|
|
|
+
|
|
|
+ // 所有关键字条件使用 OR 连接
|
|
|
+ if (keywordConditions.Any())
|
|
|
+ {
|
|
|
+ whereConditions.Add($"({string.Join(" OR ", keywordConditions)})");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 构建过滤条件
|