完善气站资源列表搜索契约

This commit is contained in:
czl231
2026-08-19 22:07:00 +08:00
parent 72da8e9e47
commit 2f5b934037
10 changed files with 168 additions and 16 deletions

View File

@@ -0,0 +1,51 @@
// Package gas 定义气站管理端各资源公开的可见字段搜索契约。
// 版本v1.0.0
package gas
import "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/common"
// gasResourceSearchFields 仅声明页面能够准确解释且服务端允许匹配的字段。
var gasResourceSearchFields = map[string][]common.KeywordSearchField{
"delivery_basic": {textSearchField("delivery_code"), textSearchField("name")},
"delivery_account": {textSearchField("username"), textSearchField("display_name"), enumSearchField("role_code", searchValue("admin", "配送点管理员"))},
"staff_account": {textSearchField("username"), enumSearchField("role_code",
searchValue("installer", "安装人员"), searchValue("delivery", "配送人员"), searchValue("operations", "运维人员"))},
"staff_credential": {textSearchField("credential_type")},
"user_account": {textSearchField("username")},
"gasorder_contract": {textSearchField("contract_no"), textSearchField("title")},
"gasorder_basic": {textSearchField("request_no"), enumSearchField("creator_type",
searchValue("user", "用户"), searchValue("staff", "工作人员"), searchValue("delivery", "配送站"), searchValue("gas", "气站"))},
"product_info": {textSearchField("code"), textSearchField("name")},
"wallet_basic": {textSearchField("owner_type")},
"payment_refund": {textSearchField("refund_no")},
"wallet_apply_cash": {textSearchField("cash_no")},
"fin_settlement": {textSearchField("settlement_no"), textSearchField("subject_type")},
"cs_ticket": {textSearchField("ticket_no"), textSearchField("category"), textSearchField("priority")},
}
// resourceSearchFields 返回资源搜索契约副本;未配置资源明确不支持搜索。
func resourceSearchFields(name string) []common.KeywordSearchField {
fields := gasResourceSearchFields[name]
result := make([]common.KeywordSearchField, 0, len(fields))
for _, field := range fields {
copied := field
copied.Values = append([]common.KeywordSearchValue(nil), field.Values...)
result = append(result, copied)
}
return result
}
// textSearchField 创建文本包含匹配字段。
func textSearchField(key string) common.KeywordSearchField {
return common.KeywordSearchField{Key: key, Kind: common.KeywordSearchText}
}
// enumSearchField 创建仅按中文展示名称匹配的枚举字段。
func enumSearchField(key string, values ...common.KeywordSearchValue) common.KeywordSearchField {
return common.KeywordSearchField{Key: key, Kind: common.KeywordSearchEnum, Values: values}
}
// searchValue 绑定枚举编码和页面中文名称。
func searchValue(code, label string) common.KeywordSearchValue {
return common.KeywordSearchValue{Value: code, Label: label}
}