From 7e54fe2ba7007bec74013ba44b7dd14389c0b037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=BF=9B?= Date: Wed, 14 Oct 2026 17:10:48 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=81=E5=BE=AE=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E9=80=89=E5=A1=AB=E9=99=84=E4=BB=B6=E6=8E=A7=E4=BB=B6=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E5=88=97=E8=A1=A8=E6=97=B6=E8=B7=B3=E8=BF=87=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=9D=9E=E5=AE=A2=E6=88=B7=E6=94=B6=E6=AC=BE?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E6=8F=90=E4=BA=A4=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../infrastructure/wecom/approval_form.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/infrastructure/wecom/approval_form.go b/internal/infrastructure/wecom/approval_form.go index 25e66fb6..70efedbd 100644 --- a/internal/infrastructure/wecom/approval_form.go +++ b/internal/infrastructure/wecom/approval_form.go @@ -101,7 +101,7 @@ func buildApprovalForm(ctx context.Context, businessType string, applicationID, attachmentCount := 0 for _, mapping := range mappings { raw, exists := lookupSnapshotValue(snapshot, mapping.BusinessField) - if !exists || raw == nil { + if !exists || raw == nil || isEmptyFileValue(mapping, raw) { if requiredControls[mapping.ControlID] { return approvalFormBuildResult{}, errors.New(errors.CodeInvalidStatus, "审批业务快照缺少模板必填字段: "+mapping.BusinessField) } @@ -125,6 +125,23 @@ func buildApprovalForm(ctx context.Context, businessType string, applicationID, return approvalFormBuildResult{Contents: contents}, nil } +// isEmptyFileValue 判断附件控件的快照值是否为空列表;空列表按未填写处理,由模板必填与业务必填规则决定是否拦截。 +func isEmptyFileValue(mapping dto.WeComControlMappingItem, raw any) bool { + if !strings.EqualFold(strings.TrimSpace(mapping.ControlType), "file") { + return false + } + switch value := raw.(type) { + case []any: + return len(value) == 0 + case []string: + return len(value) == 0 + case string: + return strings.TrimSpace(value) == "" + default: + return false + } +} + // lookupSnapshotValue 支持用点分路径读取嵌套业务快照,避免模板映射绑定具体 DTO。 func lookupSnapshotValue(snapshot map[string]any, path string) (any, bool) { segments := strings.Split(strings.TrimSpace(path), ".")