fix 修改下载链接域名
This commit is contained in:
@@ -49,12 +49,12 @@ public class ApkFileController : ControllerBase
|
||||
/// <summary>
|
||||
/// 获取最新版本
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="productCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("lastverison")]
|
||||
public async Task<ApkFileResponse> GetLastVersionAsync(string fileName)
|
||||
public async Task<ApkFileResponse> GetLastVersionAsync(string productCode)
|
||||
{
|
||||
return await _apkFIileService.GetLastVersionAsync(fileName);
|
||||
return await _apkFIileService.GetLastVersionAsync(productCode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,5 +23,15 @@ namespace Dlhis.Common.FileOperation.Response
|
||||
/// 修改信息
|
||||
/// </summary>
|
||||
public string UpdateMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品代码
|
||||
/// </summary>
|
||||
public string ProductCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// url
|
||||
/// </summary>
|
||||
public string? Url { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface IApkFIileService : IScopeDependency
|
||||
Task<string> RequestDownloadFile(string fileName);
|
||||
|
||||
|
||||
Task<ApkFileResponse> GetLastVersionAsync(string fileName);
|
||||
Task<ApkFileResponse> GetLastVersionAsync(string productCode);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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<ApkFileEntity>().Where(x => x.Name == fileName).FirstAsync();
|
||||
var entity = await _dbContext.Queryable<ApkFileEntity>().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<ApkFileEntity>().Where(x => x.Name == fileName).FirstAsync();
|
||||
var newEntity = await _dbContext.Queryable<ApkFileEntity>().Where(x => x.ProductCode == request.ProductCode).FirstAsync();
|
||||
var res = newEntity.Adapt<ApkFileResponse>();
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task<ApkFileResponse> GetLastVersionAsync(string fileName)
|
||||
public async Task<ApkFileResponse> GetLastVersionAsync(string productCode)
|
||||
{
|
||||
var info = await _dbContext.Queryable<ApkFileEntity>()
|
||||
.Where(x => x.Name == fileName)
|
||||
.Where(x => x.ProductCode == productCode)
|
||||
.Select<ApkFileResponse>()
|
||||
.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;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,5 +21,10 @@
|
||||
/// 修改信息
|
||||
/// </summary>
|
||||
public string UpdateMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品代码
|
||||
/// </summary>
|
||||
public string? ProductCode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,12 @@ public class ApkFileEntity : SugarBaseEntity
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "修改信息")]
|
||||
public string UpdateMessage { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 产品代码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "产品代码")]
|
||||
public string? ProductCode { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user