105040 Update

This commit is contained in:
lihanbo 2024-10-22 10:14:13 +08:00
parent 250ba4a01a
commit 5ed583a006
5 changed files with 24 additions and 8 deletions

View File

@ -1,4 +1,5 @@
{ {
"Urls": "https://127.0.0.1:8443;http://127.0.0.1:8088",
"Serilog": { "Serilog": {
"MinimumLevel": { "MinimumLevel": {
"Default": "Debug", "Default": "Debug",

View File

@ -68,8 +68,8 @@ public class VersionManagementController(IVersionManagementService service) : Ba
//} //}
[HttpGet] [HttpGet]
public ApiResult<VersionDto> GetLastUpdate(VersionType type, VersionChannel channel, UpgradeTargetType targetType) public ApiResult<VersionDto> GetLastUpdate(VersionChannel channel, UpgradeTargetType targetType)
{ {
return ApiResult<VersionDto>.SuccessResult(service.GetLastVersion(type, channel, targetType)); return ApiResult<VersionDto>.SuccessResult(service.GetLastVersion(channel, targetType));
} }
} }

View File

@ -7,12 +7,22 @@ using SqlSugar;
namespace LFlow.VersionManagement.Repository; namespace LFlow.VersionManagement.Repository;
public class VersionManagementRepo(ISqlSugarClient db) : DefaultCurdRepo<VersionModel, string>(db) public class VersionManagementRepo(ISqlSugarClient db) : DefaultCurdRepo<VersionModel, string>(db)
{ {
/// <summary>
/// 根据条件搜索
/// </summary>
/// <param name="whereObj"></param>
/// <returns></returns>
public override List<VersionModel> Search(VersionModel whereObj) public override List<VersionModel> Search(VersionModel whereObj)
{ {
return db.Queryable<VersionModel>() return db.Queryable<VersionModel>()
.Where(whereObj.ToWhereExp()) .Where(whereObj.ToWhereExp())
.ToList(); .ToList();
} }
/// <summary>
/// 根据条件搜索ID
/// </summary>
/// <param name="whereObj"></param>
/// <returns></returns>
public override List<string> WhereSearchId(VersionModel whereObj) public override List<string> WhereSearchId(VersionModel whereObj)
{ {
return db.Queryable<VersionModel>() return db.Queryable<VersionModel>()
@ -21,11 +31,16 @@ public class VersionManagementRepo(ISqlSugarClient db) : DefaultCurdRepo<Version
.Select(x => x.ID) .Select(x => x.ID)
.ToList(); .ToList();
} }
/// <summary>
public VersionModel GetLatestVersion(VersionType type, VersionChannel channel, UpgradeTargetType targetType) /// 获取最新版本
/// </summary>
/// <param name="channel"></param>
/// <param name="targetType"></param>
/// <returns></returns>
public VersionModel GetLatestVersion(VersionChannel channel, UpgradeTargetType targetType)
{ {
return db.Queryable<VersionModel>() return db.Queryable<VersionModel>()
.Where(mt => type == mt.VersionType && channel == mt.VersionChannel && targetType == mt.UpgradeTargetType) .Where(mt => channel == mt.VersionChannel && targetType == mt.UpgradeTargetType)
.GroupBy(mt => mt.CurrentVersion) .GroupBy(mt => mt.CurrentVersion)
.OrderBy(mt => mt.LastPublishTime, OrderByType.Desc) .OrderBy(mt => mt.LastPublishTime, OrderByType.Desc)
.First(); .First();

View File

@ -13,5 +13,5 @@ public interface IVersionManagementService : IService//<VersionDto>
List<VersionDto> GetAll(int pageIndex, int pageSize, ref int total); List<VersionDto> GetAll(int pageIndex, int pageSize, ref int total);
VersionDto? GetLastVersion(VersionType type, VersionChannel channel, UpgradeTargetType targetType); VersionDto? GetLastVersion(VersionChannel channel, UpgradeTargetType targetType);
} }

View File

@ -23,11 +23,11 @@ public class VersionManagementService : IVersionManagementService
// 搜索需要增加分页 // 搜索需要增加分页
public List<VersionDto> Search(VersionDto whereObj) public List<VersionDto> Search(VersionDto whereObj)
=> _repo.Search(whereObj.Adapt<VersionModel>()).Adapt<List<VersionDto>>(); => _repo.Search(whereObj.Adapt<VersionModel>()).Adapt<List<VersionDto>>();
public VersionDto? GetLastVersion(VersionType type, VersionChannel channel, UpgradeTargetType targetType) public VersionDto? GetLastVersion(VersionChannel channel, UpgradeTargetType targetType)
{ {
if (_repo is VersionManagementRepo versionRepo) if (_repo is VersionManagementRepo versionRepo)
{ {
return versionRepo.GetLatestVersion(type, channel, targetType).Adapt<VersionDto>(); return versionRepo.GetLatestVersion(channel, targetType).Adapt<VersionDto>();
} }
else else
{ {