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