50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using LFlow.Base.Default;
|
|
using LFlow.Base.Utils;
|
|
using LFlow.VersionManagement.Enums;
|
|
using LFlow.VersionManagement.Model;
|
|
using SqlSugar;
|
|
|
|
namespace LFlow.VersionManagement.Repository;
|
|
public class VersionManagementRepo(ISqlSugarClient db) : DefaultCurdRepo<VersionModel, string>(db)
|
|
{
|
|
/// <summary>
|
|
/// 根据条件搜索
|
|
/// </summary>
|
|
/// <param name="whereObj"></param>
|
|
/// <returns></returns>
|
|
public override List<VersionModel> Search(VersionModel whereObj)
|
|
{
|
|
return db.Queryable<VersionModel>()
|
|
.Where(whereObj.ToWhereExp())
|
|
.ToList();
|
|
}
|
|
/// <summary>
|
|
/// 根据条件搜索ID
|
|
/// </summary>
|
|
/// <param name="whereObj"></param>
|
|
/// <returns></returns>
|
|
public override List<string> WhereSearchId(VersionModel whereObj)
|
|
{
|
|
return db.Queryable<VersionModel>()
|
|
.Where(whereObj.ToWhereExp())
|
|
.Where(x => x.ID != null)
|
|
.Select(x => x.ID)
|
|
.ToList();
|
|
}
|
|
/// <summary>
|
|
/// 获取最新版本
|
|
/// </summary>
|
|
/// <param name="channel"></param>
|
|
/// <param name="targetType"></param>
|
|
/// <returns></returns>
|
|
public VersionModel GetLatestVersion(VersionChannel channel, UpgradeTargetType targetType)
|
|
{
|
|
return db.Queryable<VersionModel>()
|
|
.Where(mt => channel == mt.VersionChannel && targetType == mt.UpgradeTargetType)
|
|
.GroupBy(mt => mt.CurrentVersion)
|
|
.OrderBy(mt => mt.LastPublishTime, OrderByType.Desc)
|
|
.First();
|
|
|
|
}
|
|
}
|