From 22f96a2dceae75bb66851d7f3b487919d95c4f9b Mon Sep 17 00:00:00 2001 From: lmk <1095689763@qq.com> Date: Wed, 17 Jun 2026 17:34:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(qa):=20ISSUE-006=20=E2=80=94=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=AD=97=E6=AE=B5=E7=BC=96=E7=A0=81=E5=94=AF=E4=B8=80?= =?UTF-8?q?=E6=80=A7=E6=A0=A1=E9=AA=8C=EF=BC=8C=E9=81=BF=E5=85=8D=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E9=87=8D=E5=A4=8D=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude --- common/report/api.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/common/report/api.go b/common/report/api.go index 74ef945..25ce1d4 100644 --- a/common/report/api.go +++ b/common/report/api.go @@ -362,6 +362,20 @@ func (s *ReportService) SaveField(ctx context.Context, req *model.SaveFieldReq) field.FilterOperators = []string{"=", "!=", ">", "<", ">=", "<=", "IN", "LIKE", "BETWEEN"} } + // 新增时校验字段编码唯一性 + if req.ID == nil || *req.ID == 0 { + existing, err := s.configLoader.GetReportFields(ctx, req.BusinessCode, req.ReportCode) + if err != nil { + return nil, fmt.Errorf("校验字段编码失败: %w", err) + } + allFields := append(append(existing.Dimensions, existing.Indicators...), existing.Filters...) + for _, f := range allFields { + if f.FieldCode == req.FieldCode && f.Status == model.StatusActive { + return nil, fmt.Errorf("字段编码 %s 已存在(业务: %s, 报表: %s)", req.FieldCode, req.BusinessCode, req.ReportCode) + } + } + } + if req.ID != nil && *req.ID > 0 { field.Id = *req.ID if err := s.configLoader.UpdateField(ctx, field); err != nil {