feat(admin): 新增档案回流接口 POST /api/public/backflow
CI / Go (api) (pull_request) Successful in 55s
CI / Python (ingestion) (pull_request) Successful in 16s
CI / Migrations (postgres) (pull_request) Successful in 25s

进销存软件可用公开 API Key(og_live_) 批量回流未收录商品,进入现有审核
队列,审核通过后收录。按 GTIN 去重(已收录跳过 exists,已有待审跳过
duplicate),来源标记 source=backflow,在后台队列与公众投稿区分。

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
busenalbantoglu51424
2026-06-25 01:27:31 +00:00
parent 856b81125c
commit e7e5ce22ab
3 changed files with 215 additions and 3 deletions
+8 -3
View File
@@ -40,6 +40,10 @@ type SubmissionInput struct {
SubmitterName *string `json:"submitter_name"`
SubmitterContact *string `json:"submitter_contact"`
Note *string `json:"note"`
// Source tags the origin of the submission, stored inside the payload so no
// schema change is needed. Empty means the default public contribution
// ("community"); "backflow" marks records pushed by inventory software.
Source *string `json:"source,omitempty"`
}
// SubmissionRow is a queue-list row for the admin review table.
@@ -49,6 +53,7 @@ type SubmissionRow struct {
Name string `json:"name"`
Status string `json:"status"`
SubmitterName *string `json:"submitter_name"`
Source *string `json:"source"`
Matched bool `json:"matched"`
CreatedAt string `json:"created_at"`
ReviewedAt *string `json:"reviewed_at"`
@@ -129,8 +134,8 @@ func (s *Store) ListSubmissions(ctx context.Context, status string, limit, offse
args = append(args, limit, offset)
sql := `
SELECT id, gtin, name, status, submitter_name, (target_product_id IS NOT NULL),
created_at, reviewed_at
SELECT id, gtin, name, status, submitter_name, NULLIF(payload->>'source',''),
(target_product_id IS NOT NULL), created_at, reviewed_at
FROM submission ` + where +
" ORDER BY (status='pending') DESC, created_at DESC LIMIT $" +
strconv.Itoa(len(args)-1) + " OFFSET $" + strconv.Itoa(len(args))
@@ -146,7 +151,7 @@ FROM submission ` + where +
var r SubmissionRow
var created time.Time
var reviewed *time.Time
if err := rows.Scan(&r.ID, &r.GTIN, &r.Name, &r.Status, &r.SubmitterName, &r.Matched, &created, &reviewed); err != nil {
if err := rows.Scan(&r.ID, &r.GTIN, &r.Name, &r.Status, &r.SubmitterName, &r.Source, &r.Matched, &created, &reviewed); err != nil {
return nil, 0, err
}
r.CreatedAt = created.Format(time.RFC3339)