完善配送端资源搜索与资质导航
This commit is contained in:
@@ -18,7 +18,7 @@ type KeywordSearchKind string
|
||||
const (
|
||||
// KeywordSearchText 按数据库原始文本执行不区分大小写的包含匹配。
|
||||
KeywordSearchText KeywordSearchKind = "text"
|
||||
// KeywordSearchEnum 仅按页面展示的中文枚举名称匹配,不暴露内部英文编码。
|
||||
// KeywordSearchEnum 同时按页面中文名称和内部稳定编码匹配。
|
||||
KeywordSearchEnum KeywordSearchKind = "enum"
|
||||
)
|
||||
|
||||
@@ -85,7 +85,7 @@ func useConfiguredKeywordSearch(ctx *gin.Context) bool {
|
||||
}
|
||||
|
||||
// configuredKeywordConditions 将用户关键字编译为参数化 SQL 条件。
|
||||
// 枚举字段只接受中文展示名称,普通文本字段保持原有包含匹配行为。
|
||||
// 枚举字段接受中文展示名称和内部编码,普通文本字段保持原有包含匹配行为。
|
||||
func configuredKeywordConditions(model any, keyword string) ([]string, []any) {
|
||||
fields := ConfiguredKeywordSearchFields(model)
|
||||
conditions := make([]string, 0, len(fields))
|
||||
@@ -113,7 +113,8 @@ func configuredKeywordConditions(model any, keyword string) ([]string, []any) {
|
||||
func matchingKeywordEnumValues(values []KeywordSearchValue, keyword string) []string {
|
||||
matched := make([]string, 0, len(values))
|
||||
for _, value := range values {
|
||||
if strings.Contains(strings.ToLower(value.Label), keyword) {
|
||||
if strings.Contains(strings.ToLower(value.Label), keyword) ||
|
||||
strings.Contains(strings.ToLower(value.Value), keyword) {
|
||||
matched = append(matched, value.Value)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user