From a36ff467223063263364e205ac8f2df081c4106c Mon Sep 17 00:00:00 2001 From: cheche <717840555@qq.com> Date: Wed, 24 Jan 2024 19:08:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=A0=B9=E6=8D=AE=E8=90=A5=E4=B8=9A?= =?UTF-8?q?=E7=82=B9=E5=8F=B7=E8=8E=B7=E5=8F=96=E9=A4=90=E6=AC=A1=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E4=B8=BAnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/BusinessPlaceShiftService.cs | 4 +- .../Controllers/ApkFIileController.cs | 35 ++++++++++ Src/Dlhis.Common/Dlhis.Common.csproj | 1 + Src/Dlhis.Common/Packs/MinioPack.cs | 22 +++++++ Src/Dlhis.Common/Request/ApkRequest.cs | 20 ++++++ Src/Dlhis.Common/Response/ApkFileResponse.cs | 22 +++++++ Src/Dlhis.Common/Services/IApkFIileService.cs | 17 +++++ .../Services/Implements/ApkFIileService.cs | 66 +++++++++++++++++++ Src/Dlhis.Common/appsettings.Development.json | 11 ++++ Src/Dlhis.Entity/Common/ApkFIileEntity.cs | 35 ++++++++++ 10 files changed, 231 insertions(+), 2 deletions(-) create mode 100644 Src/Dlhis.Common/Controllers/ApkFIileController.cs create mode 100644 Src/Dlhis.Common/Packs/MinioPack.cs create mode 100644 Src/Dlhis.Common/Request/ApkRequest.cs create mode 100644 Src/Dlhis.Common/Response/ApkFileResponse.cs create mode 100644 Src/Dlhis.Common/Services/IApkFIileService.cs create mode 100644 Src/Dlhis.Common/Services/Implements/ApkFIileService.cs create mode 100644 Src/Dlhis.Entity/Common/ApkFIileEntity.cs diff --git a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs index 56d3ecec..d856a3bd 100644 --- a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs +++ b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs @@ -98,10 +98,10 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService var tenantInfo = tenantResult.Data; var list = new List(); - foreach (var shiftinfo in shifts) + foreach (CanteenBusinessShiftEntity shiftinfo in shifts) { var name = _dbContext.Queryable() - .Where(x => x.Code == shiftinfo.Code.ToString()) + .Where(x => x.Code == shiftinfo.CustomCode.ToString()) .Select(x => x.Display) .First(); var shift = new BusinessPlaceShiftTinyResponse diff --git a/Src/Dlhis.Common/Controllers/ApkFIileController.cs b/Src/Dlhis.Common/Controllers/ApkFIileController.cs new file mode 100644 index 00000000..15601144 --- /dev/null +++ b/Src/Dlhis.Common/Controllers/ApkFIileController.cs @@ -0,0 +1,35 @@ +using Dlhis.Common.Request; +using Dlhis.Common.Response; +using Dlhis.Common.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace Dlhis.Common.Controllers; + + /// + /// 文件上传/下载 + /// + [Authorize] + [Route("api/[controller]")] + [ApiController] + public class ApkFIileController : ControllerBase +{ + private IApkFIileService _apkFIileService; + + public ApkFIileController(IApkFIileService apkFIileService) + { + _apkFIileService = apkFIileService; + } + /// + /// 文件上传 + /// + /// + /// + [HttpPost] + public async Task FormSingleFileUpload(ApkRequest request) + { + await _apkFIileService.FormSingleFileUpload(request); + } +} + + diff --git a/Src/Dlhis.Common/Dlhis.Common.csproj b/Src/Dlhis.Common/Dlhis.Common.csproj index 484aa417..e3687200 100644 --- a/Src/Dlhis.Common/Dlhis.Common.csproj +++ b/Src/Dlhis.Common/Dlhis.Common.csproj @@ -26,6 +26,7 @@ + diff --git a/Src/Dlhis.Common/Packs/MinioPack.cs b/Src/Dlhis.Common/Packs/MinioPack.cs new file mode 100644 index 00000000..1421de5e --- /dev/null +++ b/Src/Dlhis.Common/Packs/MinioPack.cs @@ -0,0 +1,22 @@ +using Kurisu.AspNetCore.Startup; +using Kurisu.SqlSugar.Extensions; +using Minio; + +namespace Dlhis.Common.Packs +{ + public class MinioPack : BaseAppPack + { + public override bool IsBeforeUseRouting { get; } + + public override void ConfigureServices(IServiceCollection services) + { + //注入minioClient + var minioClient = (MinioClient)new MinioClient() + .WithEndpoint(Configuration["MinIO:Endpoint"]) + .WithCredentials(Configuration["MinIO:AccessKey"], Configuration["MinIO:SecretKey"]) + .WithSSL() + .Build(); + services.AddSingleton(minioClient); + } + } +} diff --git a/Src/Dlhis.Common/Request/ApkRequest.cs b/Src/Dlhis.Common/Request/ApkRequest.cs new file mode 100644 index 00000000..18dc4282 --- /dev/null +++ b/Src/Dlhis.Common/Request/ApkRequest.cs @@ -0,0 +1,20 @@ +namespace Dlhis.Common.Request +{ + public class ApkRequest + { + /// + /// 文件 + /// + public IFormFile formFile { get; set; } + + /// + /// 版本号 + /// + public int VersionCode { get; set; } + + /// + /// 修改信息 + /// + public string UpdateMessage { get; set; } + } +} diff --git a/Src/Dlhis.Common/Response/ApkFileResponse.cs b/Src/Dlhis.Common/Response/ApkFileResponse.cs new file mode 100644 index 00000000..8a8166a7 --- /dev/null +++ b/Src/Dlhis.Common/Response/ApkFileResponse.cs @@ -0,0 +1,22 @@ +using SqlSugar; + +namespace Dlhis.Common.Response +{ + public class ApkFileResponse + { + /// + /// 地址 + /// + public string Url { get; set; } + + /// + /// 版本号 + /// + public int VersionCode { get; set; } + + /// + /// 修改信息 + /// + public string UpdateMessage { get; set; } + } +} diff --git a/Src/Dlhis.Common/Services/IApkFIileService.cs b/Src/Dlhis.Common/Services/IApkFIileService.cs new file mode 100644 index 00000000..06a39a2f --- /dev/null +++ b/Src/Dlhis.Common/Services/IApkFIileService.cs @@ -0,0 +1,17 @@ +using Dlhis.Common.Request; +using Dlhis.Common.Response; + +namespace Dlhis.Common.Services; + + public interface IApkFIileService : IScopeDependency +{ + /// + /// 文件上传 + /// + /// + /// + Task FormSingleFileUpload(ApkRequest request); +} + + + diff --git a/Src/Dlhis.Common/Services/Implements/ApkFIileService.cs b/Src/Dlhis.Common/Services/Implements/ApkFIileService.cs new file mode 100644 index 00000000..1cf176d8 --- /dev/null +++ b/Src/Dlhis.Common/Services/Implements/ApkFIileService.cs @@ -0,0 +1,66 @@ +using Dlhis.Common.Request; +using Dlhis.Common.Response; +using Dlhis.Entity.Common; +using Kurisu.SqlSugar.Services; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Minio; +using Minio.DataModel; +using Minio.DataModel.Args; +using Minio.Exceptions; +using System.Xml.Linq; +using System; + +namespace Dlhis.Common.Services.Implements; + +public class ApkFIileService : IApkFIileService +{ + + private readonly IDbContext _dbContext; + private readonly MinioClient _client; + + public ApkFIileService(IDbContext dbContext, MinioClient client) + { + _dbContext = dbContext; + _client = client; + } + + + /// + /// 文件上传 + /// + /// + /// + public async Task FormSingleFileUpload(ApkRequest request) + { + //上传文件返回地址 + var url = "https://raw.githubusercontent.com/feicien/android-auto-update/develop/extras/android-auto-update-v1.3.apk"; + + var apkInfo = new ApkFIileEntity + { + Url = url, + VersionCode = request.VersionCode, + UpdateMessage = request.UpdateMessage, + }; + await _dbContext.InsertAsync(apkInfo); + } + + public async Task UploadFile(IFormFile formFile,string bucketName = "test") + { + + + } + + + //文件下载 + [HttpGet] + public IActionResult RequestDownloadFile(string filename) + { + + var FilePath =" "; + + return new FileStreamResult(new FileStream(FilePath, FileMode.Open), "application/octet-stream") { FileDownloadName = filename }; + } +} + + diff --git a/Src/Dlhis.Common/appsettings.Development.json b/Src/Dlhis.Common/appsettings.Development.json index 17b935d5..78225481 100644 --- a/Src/Dlhis.Common/appsettings.Development.json +++ b/Src/Dlhis.Common/appsettings.Development.json @@ -27,5 +27,16 @@ "ClientId": "reference", "ClientSecret": "123456" } + }, + //minIO配置 + "MinIO": { + //服务器IP + "Endpoint": "http://192.168.199.124:9001", + //账号 + "AccessKey": "Zbjj05OFtR19e5TJopQU", + //密码 + "SecretKey": "UMXtNdZhufhAAyYJ3XND4cEgZNUsgOWtbUzksizK", + //默认存储桶 + "Bucket": "tests" } } diff --git a/Src/Dlhis.Entity/Common/ApkFIileEntity.cs b/Src/Dlhis.Entity/Common/ApkFIileEntity.cs new file mode 100644 index 00000000..80f37c90 --- /dev/null +++ b/Src/Dlhis.Entity/Common/ApkFIileEntity.cs @@ -0,0 +1,35 @@ +using Kurisu.SqlSugar; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Dlhis.Entity.Common +{ + /// + /// Apk文件表 + /// + [SugarTable(TableName = "ApkFIile", TableDescription = "Apk文件表")] + public class ApkFIileEntity : SugarBaseEntity + { + /// + /// 地址 + /// + [SugarColumn(ColumnDescription = "地址")] + public string Url { get; set; } + + /// + /// 版本号 + /// + [SugarColumn(ColumnDescription = "版本号")] + public int VersionCode { get; set; } + + /// + /// 修改信息 + /// + [SugarColumn(ColumnDescription = "修改信息")] + public string UpdateMessage { get; set; } + } +}