diff --git a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
index accb0bba..5417f68f 100644
--- a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
+++ b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
@@ -49,12 +49,12 @@ public class ApkFileController : ControllerBase
///
/// 获取最新版本
///
- ///
+ ///
///
[HttpGet("lastverison")]
- public async Task GetLastVersionAsync(string fileName)
+ public async Task GetLastVersionAsync(string productCode)
{
- return await _apkFIileService.GetLastVersionAsync(fileName);
+ return await _apkFIileService.GetLastVersionAsync(productCode);
}
diff --git a/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs b/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs
index 7198cf6b..763f5cf9 100644
--- a/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs
+++ b/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs
@@ -23,5 +23,15 @@ namespace Dlhis.Common.FileOperation.Response
/// 修改信息
///
public string UpdateMessage { get; set; }
+
+ ///
+ /// 产品代码
+ ///
+ public string ProductCode { get; set; }
+
+ ///
+ /// url
+ ///
+ public string? Url { get; set; }
}
}
diff --git a/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs b/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
index 0f8afb8a..5dfa8536 100644
--- a/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
+++ b/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
@@ -22,7 +22,7 @@ public interface IApkFIileService : IScopeDependency
Task RequestDownloadFile(string fileName);
- Task GetLastVersionAsync(string fileName);
+ Task GetLastVersionAsync(string productCode);
}
diff --git a/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs b/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
index 202dd65f..893859c7 100644
--- a/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
+++ b/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
@@ -15,11 +15,13 @@ public class ApkFIileService : IApkFIileService
{
private readonly IMinioService _minioService;
private readonly IDbContext _dbContext;
+ private readonly IConfiguration Configuration;
- public ApkFIileService(IMinioService minioService, IDbContext dbContext)
+ public ApkFIileService(IMinioService minioService, IDbContext dbContext, IConfiguration configuration)
{
_minioService = minioService;
_dbContext = dbContext;
+ Configuration = configuration;
}
///
@@ -34,13 +36,21 @@ public class ApkFIileService : IApkFIileService
string fileName = request.formFile.FileName;
+ var lenFive = request.formFile.FileName.Length >= 5;
+
+ lenFive.ThrowIfFalse("文件名长度不能小于5");
+ var houzhui = request.formFile.FileName.Substring(request.formFile.FileName.Length - 4, 4).ToLower();
+ var isApk = request.formFile.FileName.Substring(request.formFile.FileName.Length - 4, 4) == ".apk";
+ isApk.ThrowIfFalse("文件不是apk类型");
+
//更新数据库
- var entity = await _dbContext.Queryable().Where(x => x.Name == fileName).FirstAsync();
+ var entity = await _dbContext.Queryable().Where(x => x.ProductCode == request.ProductCode).FirstAsync();
if (entity == null)
{
var info = new ApkFileEntity
{
Name = fileName,
+ ProductCode = request.ProductCode,
VersionCode = request.VersionCode,
UpdateMessage = request.UpdateMessage,
VersionName = request.VersionName,
@@ -54,17 +64,25 @@ public class ApkFIileService : IApkFIileService
entity.VersionName = request.VersionName;
await _dbContext.UpdateAsync(entity);
}
- var newEntity = await _dbContext.Queryable().Where(x => x.Name == fileName).FirstAsync();
+ var newEntity = await _dbContext.Queryable().Where(x => x.ProductCode == request.ProductCode).FirstAsync();
var res = newEntity.Adapt();
return res;
}
- public async Task GetLastVersionAsync(string fileName)
+ public async Task GetLastVersionAsync(string productCode)
{
var info = await _dbContext.Queryable()
- .Where(x => x.Name == fileName)
+ .Where(x => x.ProductCode == productCode)
.Select()
.FirstAsync();
+ var url =await RequestDownloadFile(info.Name);
+
+ var host = Configuration["MinIO:Endpoint"];
+
+ var modified_url = url.Replace(host, "https://yikatong.isawesome.cn/m");
+
+ info.Url = modified_url;
+
return info;
}
diff --git a/Src/Dlhis.Common/Request/ApkRequest.cs b/Src/Dlhis.Common/Request/ApkRequest.cs
index af368cce..86156c02 100644
--- a/Src/Dlhis.Common/Request/ApkRequest.cs
+++ b/Src/Dlhis.Common/Request/ApkRequest.cs
@@ -21,5 +21,10 @@
/// 修改信息
///
public string UpdateMessage { get; set; }
+
+ ///
+ /// 产品代码
+ ///
+ public string? ProductCode { get; set; }
}
}
diff --git a/Src/Dlhis.Entity/Common/ApkFileEntity.cs b/Src/Dlhis.Entity/Common/ApkFileEntity.cs
index cf1735ec..2c15bf57 100644
--- a/Src/Dlhis.Entity/Common/ApkFileEntity.cs
+++ b/Src/Dlhis.Entity/Common/ApkFileEntity.cs
@@ -37,6 +37,12 @@ public class ApkFileEntity : SugarBaseEntity
///
[SugarColumn(ColumnDescription = "修改信息")]
public string UpdateMessage { get; set; }
- }
+
+ ///
+ /// 产品代码
+ ///
+ [SugarColumn(ColumnDescription = "产品代码")]
+ public string? ProductCode { get; set; }
+}