完善配送端资源搜索与资质导航

This commit is contained in:
czl231
2026-08-22 23:24:12 +08:00
parent 5d4bd61672
commit 4334719051
22 changed files with 432 additions and 58 deletions

View File

@@ -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)
}
}