itfx/src/InterfaceForward.Repositories/Interface/Services/InterfaceMapPublishRepository.cs
2024-05-15 21:14:17 +08:00

55 lines
2.3 KiB
C#

using InterfaceForward.Repositories.Interface.Entitys;
using InterfaceForward.Repositories.Interface.ValueObjects;
namespace InterfaceForward.Repositories.Interface.Services;
public class InterfaceMapPublishRepository : BasicRepository<InterfaceMapPublishedEntity>,
IInterfaceMapPublishRepository,
IScopedDependency
{
public async Task<List<InterfaceMapPublishedOutPutVO>> GetPublishedListAsync(int interfaceId,
int serviceProviderId, int pageIndex,
int pageSize)
{
return await Context.Queryable<InterfaceMapPublishedEntity>()
//.LeftJoin<VUserEntity>((a, b) => a.CreateUserId == b.Id)
.Where(a => a.InterfaceId == interfaceId && a.ServiceProviderId == serviceProviderId)
.OrderByDescending(a => a.CreateTime)
.Select((a) => new InterfaceMapPublishedOutPutVO
{
Id = a.Id,
PublishedVersion = a.PublishedVersion,
PublishedContent = a.PublishedContent,
PrePublishedVersion = a.PrePublishedVersion,
DifferenceContent = a.DifferenceContent,
//PublishUser = b.Name,
PublishTime = a.CreateTime,
OperatorType = a.IsPublished ? "发布" : "回滚",
Description = a.Description
})
.ToPageListAsync(pageIndex, pageSize);
}
public async Task<string> GetPublishContentAsync(int interfaceId, int serviceProviderId, string version)
{
return await Context.Queryable<InterfaceMapPublishedEntity>()
.Where(a => a.InterfaceId == interfaceId && a.ServiceProviderId == serviceProviderId &&
a.PublishedVersion == version)
.Select(a => a.PublishedContent)
.FirstAsync();
}
}
public interface IInterfaceMapPublishRepository : IBasicRepository<InterfaceMapPublishedEntity>
{
/// <summary>
/// 获取接口映射发布记录
/// </summary>
/// <param name="interfaceId">系统接口Id</param>
/// <param name="serviceProviderId">服务商Id</param>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
Task<List<InterfaceMapPublishedOutPutVO>> GetPublishedListAsync(int interfaceId, int serviceProviderId,
int pageIndex, int pageSize);
}