feat(api): 增强字段去重逻辑以支持易码通客户名称处理
在exports.go和templates.go中新增逻辑,确保在处理易码通数据时,若同时选择order.merchant_name与merchant.name,仅保留merchant.name。此改动提升了字段去重的准确性,确保返回的数据符合预期。
This commit is contained in:
parent
b16746c048
commit
594de29ba0
|
|
@ -300,6 +300,34 @@ func (a *ExportsAPI) create(w http.ResponseWriter, r *http.Request) {
|
||||||
filtered = deduped
|
filtered = deduped
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 易码通客户名称字段去重:若同时选择 order.merchant_name 与 merchant.name,仅保留 merchant.name
|
||||||
|
if ds == "ymt" {
|
||||||
|
hasOrderMerchant := false
|
||||||
|
hasMerchantName := false
|
||||||
|
for _, tf := range filtered {
|
||||||
|
if tf == "order.merchant_name" {
|
||||||
|
hasOrderMerchant = true
|
||||||
|
}
|
||||||
|
if tf == "merchant.name" {
|
||||||
|
hasMerchantName = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if hasOrderMerchant && hasMerchantName {
|
||||||
|
deduped := make([]string, 0, len(filtered))
|
||||||
|
removed := []string{}
|
||||||
|
for _, tf := range filtered {
|
||||||
|
if tf == "order.merchant_name" {
|
||||||
|
removed = append(removed, tf)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
deduped = append(deduped, tf)
|
||||||
|
}
|
||||||
|
if len(removed) > 0 {
|
||||||
|
logging.JSON("INFO", map[string]interface{}{"event": "fields_deduplicated_customer_name", "removed": removed, "reason": "易码通客户名称仅保留 merchant.name"})
|
||||||
|
}
|
||||||
|
filtered = deduped
|
||||||
|
}
|
||||||
|
}
|
||||||
labels := FieldLabels()
|
labels := FieldLabels()
|
||||||
// 相同列名(中文标签)去重:如果多个表的字段共享同一列名,优先保留主表字段
|
// 相同列名(中文标签)去重:如果多个表的字段共享同一列名,优先保留主表字段
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,12 @@ func (a *TemplatesAPI) listTemplates(w http.ResponseWriter, r *http.Request) {
|
||||||
if !wl[tf] {
|
if !wl[tf] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// special dedupe: when both order.merchant_name and merchant.name exist, only count merchant.name
|
||||||
|
if ds == "ymt" && tf == "order.merchant_name" {
|
||||||
|
if _, ok := seen["merchant.name"]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
if _, ok := seen[tf]; ok {
|
if _, ok := seen[tf]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue