From f04891d0b97f6af4f3fd52c049bb23809d579722 Mon Sep 17 00:00:00 2001 From: busenalbantoglu51424 Date: Thu, 25 Jun 2026 01:57:43 +0000 Subject: [PATCH] =?UTF-8?q?fix(admin):=20=E5=9B=9E=E6=B5=81=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=A0=A1=E9=AA=8C/=E8=A7=84=E8=8C=83=E5=8C=96=20GTIN?= =?UTF-8?q?=EF=BC=8C=E9=9D=9E=E6=B3=95=E6=9D=A1=E7=A0=81=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=20invalid=20=E8=80=8C=E9=9D=9E=E4=B8=AD=E6=96=AD=E6=89=B9?= =?UTF-8?q?=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/internal/adminstore/backflow.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/api/internal/adminstore/backflow.go b/api/internal/adminstore/backflow.go index a6fcbcb..ccac9a2 100644 --- a/api/internal/adminstore/backflow.go +++ b/api/internal/adminstore/backflow.go @@ -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 } } -- 2.52.0