From 827f5bf09c0f14651d9cad5f975674e17ac4aba0 Mon Sep 17 00:00:00 2001 From: qhd <1766646056@qq.com> Date: Wed, 31 Dec 2025 09:53:21 +0800 Subject: [PATCH] =?UTF-8?q?oss=E6=96=87=E4=BB=B6=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1-=E7=A7=9F=E6=88=B7=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E7=A9=BA=E9=97=B4=E4=BF=A1=E6=81=AF=E5=90=8C=E6=AD=A5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yml | 2 +- main.go | 2 +- service/file_service.go | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/config.yml b/config.yml index 9f37e8e..b37cce7 100644 --- a/config.yml +++ b/config.yml @@ -37,4 +37,4 @@ minio: # 文件存储初始化容量大小配置 oss: - capacitySize: 10 #文件存储初始化容量(单位G) \ No newline at end of file + capacitySize: 500 #文件存储初始化容量(单位MB) \ No newline at end of file diff --git a/main.go b/main.go index 6bc49bf..3e7e14e 100644 --- a/main.go +++ b/main.go @@ -23,7 +23,7 @@ func main() { controller.File, }) - gtimer.AddSingleton(ctx, time.Minute*1, func(ctx context.Context) { + gtimer.AddSingleton(ctx, time.Minute*5, func(ctx context.Context) { err := service.TenantOssTotal.UpdateUsedOssSize(ctx) if err != nil { glog.Error(ctx, "UpdateUsedOssSize err: %v", err) diff --git a/service/file_service.go b/service/file_service.go index a74c1e1..19c2fc1 100644 --- a/service/file_service.go +++ b/service/file_service.go @@ -59,7 +59,7 @@ func (f *file) UploadFile(ctx context.Context, req *dto.UploadFileReq) (res *dto if tenantOssTotal.Id.IsZero() { tenantOssTotalEntity.TenantId = user.TenantId tenantOssTotalEntity.UsedOssSize = 0 - tenantOssTotalEntity.TotalOssSize = g.Cfg().MustGet(ctx, "oss.capacitySize").Int() * 1024 * 1024 * 1024 + tenantOssTotalEntity.TotalOssSize = g.Cfg().MustGet(ctx, "oss.capacitySize").Int() * 1024 * 1024 } else { tenantOssTotalEntity = tenantOssTotal.TenantOssTotal } @@ -107,8 +107,7 @@ func (f *file) UploadFile(ctx context.Context, req *dto.UploadFileReq) (res *dto FileURL: fileURL, FileSize: fileSize, } - err = dao.File.Insert(ctx, ossEntity) - if err != nil { + if err = dao.File.Insert(ctx, ossEntity); err != nil { return nil, err } // 返回图片url