采集器(bypos-collector)的「④ 导入到 Goods 系统」功能会把 JSONL 数据 POST 到后台 /api/import/bypos,但该后端接口此前只存在于未合并分支 b08495b,生产没有,导致后台返回 404 文本页,浏览器 JSON.parse 报「unexpected character at line 1 column 1」。
Brings the bypos JSONL import backend (handler + store) into main so the
bypos-collector tool's import feature works end-to-end. Records are upserted
on GTIN with manufacturer/MSRP/barcode/source provenance, quality recomputed
per product. Only status=hit records with a name are imported.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
lixu
merged commit 0da57a2fb3 into main2026-06-24 21:33:03 +08:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
背景
采集器(bypos-collector)的「④ 导入到 Goods 系统」功能会把 JSONL 数据 POST 到后台
/api/import/bypos,但该后端接口此前只存在于未合并分支 b08495b,生产没有,导致后台返回 404 文本页,浏览器JSON.parse报「unexpected character at line 1 column 1」。改动
从
b08495b引入两份后端文件并注册路由(纯新增,不改动既有代码/接口):api/internal/adminstore/import_bypos.go:ByposRecord解析 + 事务化批量 upsert(按 GTINON CONFLICT),写入 manufacturer / MSRP / product_barcode / product_source 溯源,并按记录重算质量分;仅导入status=hit且有名称的记录。api/internal/adminhandler/import_bypos.go:ImportBypos处理器,流式解析 NDJSON,返回{loaded, skipped, errored},空请求返回 400。handler.go:在鉴权路由组注册POST /api/import/bypos。本地验证(临时 Postgres,迁移至 v13)
{"loaded":2,"skipped":1,"errored":0}。go build ./...、go vet、gofmt全部通过。