fix(api): 修复导出字段重复问题并优化本地开发配置
修复导出字段重复过滤逻辑,添加去重校验和日志记录 将API基础URL切换为本地开发环境配置
This commit is contained in:
parent
ddec621951
commit
249e62029a
|
|
@ -223,21 +223,33 @@ func (a *ExportsAPI) create(w http.ResponseWriter, r *http.Request) {
|
||||||
filtered = append(filtered, tf)
|
filtered = append(filtered, tf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ds == "ymt" {
|
{
|
||||||
present := map[string]bool{}
|
seen := map[string]bool{}
|
||||||
for _, f := range filtered {
|
|
||||||
present[f] = true
|
|
||||||
}
|
|
||||||
if present["merchant.name"] && present["order.merchant_name"] {
|
|
||||||
out := make([]string, 0, len(filtered))
|
out := make([]string, 0, len(filtered))
|
||||||
for _, f := range filtered {
|
for _, f := range filtered {
|
||||||
if f == "order.merchant_name" {
|
if seen[f] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
seen[f] = true
|
||||||
out = append(out, f)
|
out = append(out, f)
|
||||||
}
|
}
|
||||||
filtered = out
|
filtered = out
|
||||||
}
|
}
|
||||||
|
// 字段去重与校验
|
||||||
|
{
|
||||||
|
cnt := map[string]int{}
|
||||||
|
for _, f := range filtered {
|
||||||
|
cnt[f]++
|
||||||
|
}
|
||||||
|
removed := []string{}
|
||||||
|
for k, n := range cnt {
|
||||||
|
if n > 1 {
|
||||||
|
removed = append(removed, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(removed) > 0 {
|
||||||
|
logging.JSON("INFO", map[string]interface{}{"event": "field_dedupe", "removed": removed})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// relax: creator_in 非必填,若权限中提供其他边界将被合并为等值过滤
|
// relax: creator_in 非必填,若权限中提供其他边界将被合并为等值过滤
|
||||||
req := exporter.BuildRequest{MainTable: main, Datasource: ds, Fields: filtered, Filters: p.Filters}
|
req := exporter.BuildRequest{MainTable: main, Datasource: ds, Fields: filtered, Filters: p.Filters}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
window.__API_BASE__ = 'https://ymtexporttool.cdlsxd.cn/apiv1/'
|
// window.__API_BASE__ = 'https://ymtexporttool.cdlsxd.cn/apiv1/'
|
||||||
// window.__API_BASE__ = 'http://127.0.0.1:8077'
|
window.__API_BASE__ = 'http://127.0.0.1:8077'
|
||||||
window.__ASSET_VERSION__ = window.__ASSET_VERSION__ || String(Date.now())
|
window.__ASSET_VERSION__ = window.__ASSET_VERSION__ || String(Date.now())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue