Compare commits

...

2 Commits

Author SHA1 Message Date
busenalbantoglu51424 f04891d0b9 fix(admin): 回流接口校验/规范化 GTIN,非法条码标记 invalid 而非中断批次
CI / Go (api) (pull_request) Successful in 56s
CI / Python (ingestion) (pull_request) Successful in 28s
CI / Migrations (postgres) (pull_request) Successful in 29s
2026-06-25 01:57:43 +00:00
lixu 3a5575f51b Merge pull request 'feat(admin): 新增档案回流接口 POST /api/public/backflow' (#35) from devin/1782350840-backflow-api into main
CI / Go (api) (push) Successful in 53s
CI / Python (ingestion) (push) Successful in 28s
CI / Migrations (postgres) (push) Successful in 47s
2026-06-25 09:52:43 +08:00
+15 -2
View File
@@ -6,6 +6,7 @@ import (
"errors"
"strings"
"github.com/baicai2026-baicai/goods/api/internal/gtin"
"github.com/jackc/pgx/v5"
)
@@ -76,8 +77,20 @@ func (s *Store) CreateBackflowSubmissions(ctx context.Context, items []Submissio
if g == "" {
in.GTIN = nil
} else {
in.GTIN = &g
res.GTIN = &g
// Validate/normalize so a malformed barcode is reported as an
// invalid item instead of aborting the batch (the gtin column
// is varchar(14) and only GS1 codes are archived).
norm, err := gtin.Normalize(g)
if err != nil {
res.GTIN = &g
res.Status = "invalid"
res.Reason = err.Error()
sum.Invalid++
sum.Results = append(sum.Results, res)
continue
}
in.GTIN = &norm
res.GTIN = &norm
}
}