147 lines
7.0 KiB
C#
147 lines
7.0 KiB
C#
using System.Linq.Expressions;
|
|
using SJZY.Expand.ABP.Core.PublicMethords;
|
|
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
|
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
|
using SJZY.Track.Domain.Dtos.Common;
|
|
using SJZY.Track.Domain.Dtos.TrackPull;
|
|
using SJZY.Track.Domain.Enums;
|
|
using SJZY.Track.Domain.VEntities;
|
|
|
|
namespace SJZY.Track.Repository.Repositories;
|
|
|
|
public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>, ITrackPullConfigRepository,
|
|
IScopedDependency
|
|
{
|
|
public async Task<UnifyPageResultDto<GetTrackPullConfigPageOutputVO>> GetPageAsync(KeywordsInputVO input)
|
|
{
|
|
return await AsQueryable()
|
|
.LeftJoin<VSystemEntity>((trackPull, system) => trackPull.SubSystemId == system.Id && !system.IsDeleted)
|
|
.LeftJoin<VServiceProviderEntity>((trackPull, system, service) => trackPull.ServiceProviderId == service.Id && !service.IsDeleted)
|
|
.Filter(null, true)
|
|
.Where(trackPull => !trackPull.IsDeleted)
|
|
.WhereIF(input.SubSystemId.HasValue, trackPull => trackPull.SubSystemId == input.SubSystemId)
|
|
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (trackPull, system, service) => service.Name.Contains(input.Keywords!))
|
|
.OrderByDescending(trackPull => trackPull.CreateTime)
|
|
.Select((trackPull, system, service) => new GetTrackPullConfigPageOutputVO
|
|
{
|
|
Id = trackPull.Id,
|
|
SubSystem = system.CnName,
|
|
ServiceProvider = service.Name,
|
|
CreateTime = trackPull.CreateTime
|
|
})
|
|
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
|
}
|
|
|
|
public async Task<UnifyPageResultDto<GetTrackPullContentPageOutputVO>> GetContentPageAsync(GetTrackPullContentPageInputVO input)
|
|
{
|
|
return await Context.Queryable<TrackPullContentConfigEntity>()
|
|
.InnerJoin<TrackContentEntity>((pullContent, trackContent) => pullContent.TrackContentId == trackContent.Id)
|
|
.LeftJoin<VEnumValueInfoEntity>((pullContent, trackContent, enumValue) => enumValue.Property == EnumPropertyEnums.轨迹发生地.GetDescription() && pullContent.TrackPlaceValue == enumValue.Enumkey)
|
|
.Where(pullContent => pullContent.TrackPullConfigId == input.TrackPullConfigId)
|
|
.OrderBy(pullContent => pullContent.CreateTime)
|
|
.Select((pullContent, trackContent, enumValue) => new GetTrackPullContentPageOutputVO
|
|
{
|
|
Id = pullContent.Id,
|
|
TrackPlaceValue = enumValue.Disp
|
|
}, true)
|
|
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
|
}
|
|
|
|
public async Task<List<GetTrackPullContentListCacheVO>> GetContentListCacheAsync(int trackPullConfigId)
|
|
{
|
|
return await Context.Queryable<TrackPullContentConfigEntity>()
|
|
.InnerJoin<TrackContentEntity>((pullContent, trackContent) => pullContent.TrackContentId == trackContent.Id)
|
|
.Where(pullContent => pullContent.TrackPullConfigId == trackPullConfigId)
|
|
.Select((pullContent, trackContent) => new GetTrackPullContentListCacheVO
|
|
{
|
|
TrackContentCode = trackContent.Code
|
|
}, true)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public async Task<GetTrackPullConfigDetailOutputVO> GetDetailAsync(int id)
|
|
{
|
|
return await AsQueryable()
|
|
.LeftJoin<VSystemEntity>((trackPull, system) => trackPull.SubSystemId == system.Id && !system.IsDeleted)
|
|
.LeftJoin<VServiceProviderEntity>((trackPull, system, service) => trackPull.ServiceProviderId == service.Id && !service.IsDeleted)
|
|
.InnerJoin<TrackPushPullParamsConfigEntity>((trackPull, system, service, paramsConfig) => trackPull.Id == paramsConfig.PullOrPushConfigId && !paramsConfig.IsPush && !paramsConfig.IsDeleted)
|
|
.Filter(null, true)
|
|
.Where(trackPull => trackPull.Id == id && !trackPull.IsDeleted)
|
|
.Select((trackPull, system, service, paramsConfig) => new GetTrackPullConfigDetailOutputVO
|
|
{
|
|
Id = trackPull.Id,
|
|
SubSystem = system.CnName,
|
|
ServiceProvider = service.Name
|
|
}, true)
|
|
.SingleAsync();
|
|
}
|
|
|
|
public async Task<GetTrackPullContentDetailOutputVO> GetContentDetailAsync(int id)
|
|
{
|
|
return await Context.Queryable<TrackPullContentConfigEntity>()
|
|
.InnerJoin<TrackContentEntity>((pullContent, trackContent) => pullContent.TrackContentId == trackContent.Id)
|
|
.Where(pullContent => pullContent.Id == id)
|
|
.Select((pullContent, trackContent) => new GetTrackPullContentDetailOutputVO
|
|
{
|
|
Id = pullContent.Id,
|
|
Code = trackContent.Code + "-" + trackContent.Content,
|
|
}, true)
|
|
.Mapper(x =>
|
|
{
|
|
x.TrackKeywords = x.TrackKeyword?.Split(',').ToList();
|
|
x.TrackKeywordReverses = x.TrackKeywordReverse?.Split(',').ToList();
|
|
})
|
|
.SingleAsync();
|
|
}
|
|
|
|
public async Task<bool> InsertParamsAsync(TrackPushPullParamsConfigEntity insertObj)
|
|
{
|
|
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
|
|
}
|
|
|
|
public async Task<bool> InsertContentAsync(TrackPullContentConfigEntity insertObj)
|
|
{
|
|
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
|
|
}
|
|
|
|
public async Task<TrackPushPullParamsConfigEntity> GetParamsSingleAsync(Expression<Func<TrackPushPullParamsConfigEntity, bool>> whereExpression)
|
|
{
|
|
return await Context.Queryable<TrackPushPullParamsConfigEntity>().SingleAsync(whereExpression);
|
|
}
|
|
|
|
public async Task<bool> UpdateParamsAsync(TrackPushPullParamsConfigEntity updateObj)
|
|
{
|
|
return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync();
|
|
}
|
|
|
|
public async Task<bool> SoftDeleteContentAsync(Expression<Func<TrackPullContentConfigEntity, bool>> whereExpression)
|
|
{
|
|
return await Context.Updateable<TrackPullContentConfigEntity>()
|
|
.Where(whereExpression)
|
|
.SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true)
|
|
.ExecuteCommandHasChangeAsync();
|
|
}
|
|
|
|
public async Task<bool> SoftDeleteParamsAsync(Expression<Func<TrackPushPullParamsConfigEntity, bool>> whereExpression)
|
|
{
|
|
return await Context.Updateable<TrackPushPullParamsConfigEntity>()
|
|
.Where(whereExpression)
|
|
.SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true)
|
|
.ExecuteCommandHasChangeAsync();
|
|
}
|
|
|
|
public async Task<TrackPullContentConfigEntity> GetContentByIdAsync(int id)
|
|
{
|
|
return await Context.Queryable<TrackPullContentConfigEntity>().InSingleAsync(id);
|
|
}
|
|
|
|
public async Task<bool> UpdateContentAsync(TrackPullContentConfigEntity updateObj)
|
|
{
|
|
return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync();
|
|
}
|
|
|
|
public async Task<bool> IsContentAnyAsync(Expression<Func<TrackPullContentConfigEntity, bool>> whereExpression)
|
|
{
|
|
return await Context.Queryable<TrackPullContentConfigEntity>().Where(whereExpression).AnyAsync();
|
|
}
|
|
} |