From f708a86d5c98b476c19fe843f33c0369fb617c4e Mon Sep 17 00:00:00 2001 From: "DESKTOP-L8OUL9F\\gfl0034" <1003614916@qq.com> Date: Thu, 24 Sep 2026 23:07:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(upload):=20=E6=8E=A5=E5=85=A5=E5=AA=92?= =?UTF-8?q?=E4=BD=93=E7=AD=96=E7=95=A5=E4=B8=8E=E6=97=A5=E5=BF=97=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为上传服务注入 media.Policy 与 zap.Logger,对齐广场媒体校验。 --- internal/module/upload/logic/service.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/module/upload/logic/service.go b/internal/module/upload/logic/service.go index 6c86b65..9196283 100644 --- a/internal/module/upload/logic/service.go +++ b/internal/module/upload/logic/service.go @@ -5,7 +5,10 @@ import ( "strconv" "time" + "spark-server/internal/pkg/media" "spark-server/internal/pkg/ratelimit" + + "go.uber.org/zap" ) // Presigner issues short-lived object-storage URLs. Infrastructure implements it. @@ -23,6 +26,8 @@ type Options struct { Limit *ratelimit.Limiter Now func() time.Time Groups AvatarACL + Media media.Policy + Log *zap.Logger } // Service issues upload/download credentials. HTTP and TCP share it. @@ -32,6 +37,8 @@ type Service struct { limit *ratelimit.Limiter now func() time.Time groups AvatarACL + media media.Policy + log *zap.Logger } func NewService(store Presigner, opt Options) *Service { @@ -43,7 +50,11 @@ func NewService(store Presigner, opt Options) *Service { if clock == nil { clock = func() time.Time { return time.Now().UTC() } } - return &Service{store: store, ttl: ttl, limit: opt.Limit, now: clock, groups: opt.Groups} + log := opt.Log + if log == nil { + log = zap.NewNop() + } + return &Service{store: store, ttl: ttl, limit: opt.Limit, now: clock, groups: opt.Groups, media: opt.Media, log: log} } func (s *Service) ready() bool {