From 7336f2d438e52f86afdc0cbfd052b210270696cf Mon Sep 17 00:00:00 2001 From: lmk <1095689763@qq.com> Date: Tue, 16 Jun 2026 19:17:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(qa):=20ISSUE-003=20=E2=80=94=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=EF=BC=8C=E6=8B=92=E7=BB=9D=20STRING/INT/FLOAT/DATE/DATETIME/JS?= =?UTF-8?q?ONB=20=E4=B9=8B=E5=A4=96=E7=9A=84=E5=AD=97=E6=AE=B5=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前 BOOLEAN/BOOLEAN 等无效字段类型不会被拒绝, 导致建表时 fallback 到 VARCHAR(256) 产生类型不匹配。 现在显式校验 FieldType 和 DataType 都在允许范围内。 --- common/report/api.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/report/api.go b/common/report/api.go index db85776..74ef945 100644 --- a/common/report/api.go +++ b/common/report/api.go @@ -333,6 +333,22 @@ func (s *ReportService) SaveField(ctx context.Context, req *model.SaveFieldReq) Status: req.Status, } + // 校验字段类型 + validFieldTypes := map[string]bool{ + model.FieldTypeString: true, + model.FieldTypeInt: true, + model.FieldTypeFloat: true, + model.FieldTypeDate: true, + model.FieldTypeDatetime: true, + model.FieldTypeJsonb: true, + } + if req.FieldType != "" && !validFieldTypes[req.FieldType] { + return nil, fmt.Errorf("不支持的字段类型: %s,仅支持 STRING/INT/FLOAT/DATE/DATETIME/JSONB", req.FieldType) + } + if req.DataType != "" && !validFieldTypes[req.DataType] { + return nil, fmt.Errorf("不支持的存储类型: %s,仅支持 STRING/INT/FLOAT/DATE/DATETIME/JSONB", req.DataType) + } + if req.Status == "" { field.Status = model.StatusActive }