From c17a29db276a46d9c57af0b450d7327e4cf88ff6 Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Tue, 30 Jan 2024 14:14:17 +0800
Subject: [PATCH] =?UTF-8?q?fix=20=E6=9C=AC=E5=9C=B0=E4=B8=8A=E4=BC=A0?=
=?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/ApkFileController.cs | 82 -------------------
.../Controllers/ApkFileController.cs | 19 ++++-
.../Services/IApkFIileService.cs | 8 +-
.../Services/Implements/ApkFIileService.cs | 29 ++++++-
...ApkFileResponse.cs => ApkFile1Response.cs} | 2 +-
Src/Dlhis.Common/Services/IApkFIileService.cs | 2 +-
.../Services/Implements/ApkFIileService.cs | 4 +-
7 files changed, 51 insertions(+), 95 deletions(-)
delete mode 100644 Src/Dlhis.Common/Controllers/ApkFileController.cs
rename Src/Dlhis.Common/Response/{ApkFileResponse.cs => ApkFile1Response.cs} (94%)
diff --git a/Src/Dlhis.Common/Controllers/ApkFileController.cs b/Src/Dlhis.Common/Controllers/ApkFileController.cs
deleted file mode 100644
index eae38eb0..00000000
--- a/Src/Dlhis.Common/Controllers/ApkFileController.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-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 ApkFileController : ControllerBase
-{
- private IApkFIileService _apkFIileService;
-
- public ApkFileController(IApkFIileService apkFIileService)
- {
- _apkFIileService = apkFIileService;
- }
- ///
- /// minlo文件上传
- ///
- ///
- ///
- [HttpPost("minio")]
- public async Task FormSingleFileUpload([FromForm] ApkRequest request)
- {
- return await _apkFIileService.FormSingleFileUpload(request);
- }
-
- ///
- /// minlo文件下载
- ///
- ///
- ///
- [HttpGet("miniourl")]
- public async Task RequestDownloadFile(string fileName)
- {
- return await _apkFIileService.RequestDownloadFile(fileName);
- }
-
-
- ///
- /// 本地文件上传
- ///
- ///
- ///
- [HttpPost("uploadlocal")]
- [RequestSizeLimit(100_000_0000)]
-
- public async Task FormLocalFileUpload([FromForm] ApkRequest request)
- {
- return await _apkFIileService.FormLocalFileUpload(request);
- }
- ///
- /// 查看最新版本
- ///
- ///
- ///
- [HttpGet("lateFile")]
- public async Task LatestFile(string fileName)
- {
- return await _apkFIileService.LatestFile(fileName);
- }
-
- ///
- /// 本地文件下载
- ///
- ///
- ///
- [HttpGet("downlocal")]
- public IActionResult FormLocalDownloadFile(string fileName)
- {
- return _apkFIileService.FormLocalDownloadFile(fileName);
- }
-}
-
-
-
diff --git a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
index fceeb505..7646dd3e 100644
--- a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
+++ b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
@@ -2,8 +2,10 @@
using Dlhis.Common.FileOperation.Response;
using Dlhis.Common.FileOperation.Services;
using Dlhis.Common.Request;
+using Dlhis.Common.Response;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using Org.BouncyCastle.Asn1.Ocsp;
namespace Dlhis.Common.FileOperation.Controllers;
@@ -57,15 +59,26 @@ public class ApkFileController : ControllerBase
return await _apkFIileService.FormLocalFileUpload(request);
}
+ ///
+ /// 查看最新版本
+ ///
+ ///
+ ///
+ [HttpGet("lastfile")]
+ public async Task LatestFile(string fileName)
+ {
+ return await _apkFIileService.LatestFile(fileName);
+ }
+
///
/// 本地文件下载
///
- ///
+ ///
///
[HttpGet("local")]
- public IActionResult FormLocalDownloadFile(string filePath)
+ public IActionResult FormLocalDownloadFile(string fileName)
{
- return _apkFIileService.FormLocalDownloadFile(filePath);
+ return _apkFIileService.FormLocalDownloadFile(fileName);
}
}
diff --git a/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs b/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
index e53ab808..f9f29d73 100644
--- a/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
+++ b/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
@@ -1,6 +1,7 @@
using Dlhis.Common.FileOperation.Request;
using Dlhis.Common.FileOperation.Response;
using Dlhis.Common.Request;
+using Dlhis.Common.Response;
using Microsoft.AspNetCore.Mvc;
namespace Dlhis.Common.FileOperation.Services;
@@ -26,12 +27,15 @@ public interface IApkFIileService : IScopeDependency
///
///
Task FormLocalFileUpload(ApkRequest request);
+
+ Task LatestFile(string fileName);
+
///
/// 本地下载
///
- ///
+ ///
///
- IActionResult FormLocalDownloadFile(string filePath);
+ IActionResult FormLocalDownloadFile(string fileName);
}
diff --git a/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs b/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
index ab146490..28726ace 100644
--- a/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
+++ b/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
@@ -2,6 +2,7 @@
using Dlhis.Common.FileOperation.Response;
using Dlhis.Common.FileOperation.Services;
using Dlhis.Common.Request;
+using Dlhis.Common.Response;
using Dlhis.Entity.Common;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.SqlSugar.Services;
@@ -90,6 +91,7 @@ public class ApkFIileService : IApkFIileService
Name = fileName,
Url = completeFilePath,
VersionCode = request.VersionCode,
+ VersionName = request.VersionName,
UpdateMessage = request.UpdateMessage,
};
await _dbContext.InsertAsync(info);
@@ -99,6 +101,7 @@ public class ApkFIileService : IApkFIileService
entity.Url = completeFilePath;
entity.VersionCode = request.VersionCode;
entity.UpdateMessage = request.UpdateMessage;
+ entity.VersionName = request.VersionName;
await _dbContext.UpdateAsync(entity);
}
var newEntity = await _dbContext.Queryable().Where(x => x.Name == fileName).FirstAsync();
@@ -110,7 +113,7 @@ public class ApkFIileService : IApkFIileService
{
try
{
- var filePath = "D:\\apk\\";
+ var filePath = "C:\\apk\\";
// 创建存储文件夹
if (!Directory.Exists(filePath))
@@ -146,15 +149,33 @@ public class ApkFIileService : IApkFIileService
}
}
+ ///
+ /// 返回最新版本信息
+ ///
+ ///
+ ///
+ public async Task LatestFile(string fileName)
+ {
+ var info = await _dbContext.Queryable()
+ .Where(x => x.Name == fileName)
+ .OrderByDescending(x => x.VersionCode)
+ .FirstAsync();
+ info.ThrowIfNull($"没有{fileName}信息");
+ var res = info.Adapt();
+ return res;
+ }
+
///
/// 本地下载
///
- ///
+ ///
///
- public IActionResult FormLocalDownloadFile(string filePath)
+ public IActionResult FormLocalDownloadFile(string fileName)
{
- string fileName = Path.GetFileName(filePath);
+
+ var Path = "C:\\apk\\";
+ var filePath = Path + fileName;
return new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = fileName };
}
}
diff --git a/Src/Dlhis.Common/Response/ApkFileResponse.cs b/Src/Dlhis.Common/Response/ApkFile1Response.cs
similarity index 94%
rename from Src/Dlhis.Common/Response/ApkFileResponse.cs
rename to Src/Dlhis.Common/Response/ApkFile1Response.cs
index f102220f..560d4356 100644
--- a/Src/Dlhis.Common/Response/ApkFileResponse.cs
+++ b/Src/Dlhis.Common/Response/ApkFile1Response.cs
@@ -2,7 +2,7 @@
namespace Dlhis.Common.Response
{
- public class ApkFileResponse
+ public class ApkFile1Response
{
///
/// 文件名称
diff --git a/Src/Dlhis.Common/Services/IApkFIileService.cs b/Src/Dlhis.Common/Services/IApkFIileService.cs
index af881edb..c6d9624b 100644
--- a/Src/Dlhis.Common/Services/IApkFIileService.cs
+++ b/Src/Dlhis.Common/Services/IApkFIileService.cs
@@ -11,7 +11,7 @@ namespace Dlhis.Common.Services;
///
///
///
- Task FormSingleFileUpload(ApkRequest request);
+ Task FormSingleFileUpload(ApkRequest request);
///
/// 文件下载
diff --git a/Src/Dlhis.Common/Services/Implements/ApkFIileService.cs b/Src/Dlhis.Common/Services/Implements/ApkFIileService.cs
index d0f17568..bdd03d8f 100644
--- a/Src/Dlhis.Common/Services/Implements/ApkFIileService.cs
+++ b/Src/Dlhis.Common/Services/Implements/ApkFIileService.cs
@@ -25,7 +25,7 @@ public class ApkFIileService : IApkFIileService
///
///
///
- public async Task FormSingleFileUpload(ApkRequest request)
+ public async Task FormSingleFileUpload(ApkRequest request)
{
//上传
var fileUrl = await _minioService.MinloUploadFileAsync(request);
@@ -53,7 +53,7 @@ public class ApkFIileService : IApkFIileService
await _dbContext.UpdateAsync(entity);
}
var newEntity = await _dbContext.Queryable().Where(x => x.Name == fileName).FirstAsync();
- var res = newEntity.Adapt();
+ var res = newEntity.Adapt();
return res;
}