From 026782caa556edf0e99a53497f498ce8eaf6ad64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BC=9F?= <421281095@qq.com> Date: Fri, 25 Jul 2025 10:06:58 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E5=9B=9E=E4=BC=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F=202.=20bugfix:=20=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=AD=97=E6=AE=B5=E6=9B=B4=E6=96=B0=E7=A9=BA=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ServiceApp/Subscribe/ConfigSubscribe.cs | 19 ++++++++++++------- OpenAuth.Repository/Domain/LasaMediaFile.cs | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs b/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs index 7beba85..8f93777 100644 --- a/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs +++ b/OpenAuth.App/ServiceApp/Subscribe/ConfigSubscribe.cs @@ -19,7 +19,6 @@ using SixLabors.ImageSharp.Processing; using SqlSugar; - namespace OpenAuth.App.BaseApp.Subscribe; public class ConfigSubscribe : IJob @@ -269,14 +268,14 @@ public class ConfigSubscribe : IJob string objectKey1 = data.file.object_key.ToString(); string suoluokey = "minipic/" + data.file.name.ToString(); //缩略图处理 - var imageStream = _minioService.GetObjectAsStream("", objectKey1); + var imageStream = _minioService.GetObjectAsStream("", objectKey1); var width = 0; var height = 0; + var size = 0L; using (var image = Image.Load(imageStream.Result)) { - - width = image.Width; - height = image.Height; + width = image.Width; + height = image.Height; var thumbnailSize = 100; // 缩略图大小,可以根据需要调整 var thumbnail = image.Clone(ctx => ctx.Resize(new ResizeOptions { @@ -287,13 +286,16 @@ public class ConfigSubscribe : IJob // 将缩略图保存到内存流中(为了上传) using (var memoryStream = new MemoryStream()) { + size = memoryStream.Length; thumbnail.SaveAsJpeg(memoryStream); // 可以根据需要选择不同的格式,如Png, Bmp等。 memoryStream.Position = 0; // 重置流的位置到开始处 // 上传缩略图到MinIO - await _minioService.PutObjectAsync("", data.file.name.ToString(), suoluokey, memoryStream); // 根据实际格式修改Content-Type + await _minioService.PutObjectAsync("", data.file.name.ToString(), suoluokey, + memoryStream); // 根据实际格式修改Content-Type } } + var fileUpload = new LasaMediaFile() { Id = Guid.NewGuid().ToString(), @@ -319,7 +321,10 @@ public class ConfigSubscribe : IJob FlightType = flightType, Width = width, Height = height, - minipic = suoluokey + minipic = suoluokey, + Size = size, + ShowOnMap = 1, + display = 1 }; // todo 添加事务 await _sqlSugarClient.Insertable(fileUpload).ExecuteCommandAsync(); diff --git a/OpenAuth.Repository/Domain/LasaMediaFile.cs b/OpenAuth.Repository/Domain/LasaMediaFile.cs index a6fd314..26cf4ef 100644 --- a/OpenAuth.Repository/Domain/LasaMediaFile.cs +++ b/OpenAuth.Repository/Domain/LasaMediaFile.cs @@ -106,7 +106,7 @@ public class LasaMediaFile public string FileTags { get; set; } - public int Size { get; set; } + public long Size { get; set; } public int Width { get; set; } public int Height { get; set; } public string Tid { get; set; }