38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using LFlow.Base.Interfaces;
|
|
using LFlow.VersionManagement.Enums;
|
|
using LFlow.VersionManagement.Model;
|
|
using LFlow.VersionManagement.Repository;
|
|
using Mapster;
|
|
|
|
namespace LFlow.VersionManagement.Service;
|
|
/// <summary>
|
|
/// 版本管理服务
|
|
/// </summary>
|
|
public class VersionManagementService : IVersionManagementService
|
|
{
|
|
private readonly IRepo<VersionModel, string> _repo;
|
|
public VersionManagementService(IRepo<VersionModel, string> repo)
|
|
{
|
|
_repo = repo;
|
|
}
|
|
|
|
public int DeleteById(string id) => _repo.DeleteById(id);
|
|
public List<VersionDto> GetAll(int pageIndex, int pageSize, ref int total) => _repo.GetAll(pageIndex, pageSize, ref total).Adapt<List<VersionDto>>();
|
|
public VersionDto GetById(string id) => _repo.Get(id).Adapt<VersionDto>();
|
|
public VersionDto Save(VersionDto entity, bool isUpdate) => _repo.SaveOrUpdate(entity.Adapt<VersionModel>(), isUpdate).Adapt<VersionDto>();
|
|
// 搜索需要增加分页
|
|
public List<VersionDto> Search(VersionDto whereObj)
|
|
=> _repo.Search(whereObj.Adapt<VersionModel>()).Adapt<List<VersionDto>>();
|
|
public VersionDto? GetLastVersion(VersionChannel channel, UpgradeTargetType targetType)
|
|
{
|
|
if (_repo is VersionManagementRepo versionRepo)
|
|
{
|
|
return versionRepo.GetLatestVersion(channel, targetType).Adapt<VersionDto>();
|
|
}
|
|
else
|
|
{
|
|
return default;
|
|
}
|
|
}
|
|
}
|