左连接查询加isdeleted==false

This commit is contained in:
moyongzhen 2024-03-01 18:34:05 +08:00
parent 8ac687a9be
commit 6e487a60c3
6 changed files with 28 additions and 23 deletions

View File

@ -20,6 +20,7 @@ namespace SJZY.Track.Application.Services.TrackContents
public TrackContentService(
IStringLocalizer<TrackLocalizationResource> stringLocalizer,
ITrackContentRepository trackContentRepository
)
{
this._stringLocalizer = stringLocalizer;
@ -103,7 +104,6 @@ namespace SJZY.Track.Application.Services.TrackContents
private async Task<UnifyResultDto> UpdateAsync(EditTrackContentInput input)
{
#region 业务逻辑校验
var trackContentEntity = await _trackContentRepository.GetFirstAsync(a => a.Id != input.Id &&
a.SubSystemId == input.SubSystemId && (a.Code == input.Code ||
a.Content == input.Content || a.EnContent == input.EnContent));
@ -111,6 +111,7 @@ namespace SJZY.Track.Application.Services.TrackContents
{
throw new BusinessException(message: _stringLocalizer["TrackContentExist"]);
}
//更新的时候需要覆盖内容映射轨迹代码
#endregion

View File

@ -102,8 +102,8 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
public async Task<UnifyPageResultDto<TrackOrderVO>> GetPageTrackOrder(GetPageTrackOrderInputVO input)
{
var pageList = await Context.Queryable<OrderEntity>()
.LeftJoin<VExternalSubjectEntity>((a, b) => a.CustomId == b.Id)
.LeftJoin<VSystemEntity>((a, b, c) => a.SubSystemId == c.Id)
.LeftJoin<VExternalSubjectEntity>((a, b) => a.CustomId == b.Id && b.IsDeleted == false)
.LeftJoin<VSystemEntity>((a, b, c) => a.SubSystemId == c.Id && c.IsDeleted == false)
.WhereIF(input.SubSystemId > 0, (a, b, c) => a.SubSystemId == input.SubSystemId)
.WhereIF(!input.OrderNos.IsNullOrEmpty(), (a, b, c) => input.OrderNos.Contains(a.OrderNo))
.WhereIF(input.CreateTimeStart.HasValue && input.CreateTimeEnd.HasValue,

View File

@ -22,9 +22,9 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
public async Task<GetTrackContentDetailVO?> GetDetailAsync(int id)
{
var detail = await Context.Queryable<TrackContentEntity>()
.LeftJoin<TrackStatusEntity>((a, b) => a.TrackStatusId==b.Id)
.LeftJoin<TrackFlagEntity>((a, b, c) => a.TrackFlagId==c.Id)
.LeftJoin<VSystemEntity>((a, b, c, d) => a.SubSystemId == d.Id)
.LeftJoin<TrackStatusEntity>((a, b) => a.TrackStatusId == b.Id && b.IsDeleted == false)
.LeftJoin<TrackFlagEntity>((a, b, c) => a.TrackFlagId == c.Id && c.IsDeleted == false)
.LeftJoin<VSystemEntity>((a, b, c, d) => a.SubSystemId == d.Id&&d.IsDeleted==false)
.Where((a, b, c, d) => a.Id == id)
.Select((a, b, c, d) => new GetTrackContentDetailVO
{
@ -52,11 +52,11 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
{
UnifyPageResultDto<GetTrackContentListVO> pagedList = new UnifyPageResultDto<GetTrackContentListVO>();
pagedList = await Context.Queryable<TrackContentEntity>()
.LeftJoin<TrackStatusEntity>((a, b) => a.TrackStatusId==b.Id)
.LeftJoin<TrackFlagEntity>((a, b, c) => a.TrackFlagId==c.Id)
.LeftJoin<VSystemEntity>((a, b, c, d) => a.SubSystemId == d.Id)
.LeftJoin<VUserEntity>((a, b, c, d, e) => a.CreateUserId == e.Id)
.LeftJoin<VUserEntity>((a, b, c, d, e, f) => a.UpdateUserId == f.Id)
.LeftJoin<TrackStatusEntity>((a, b) => a.TrackStatusId==b.Id&&b.IsDeleted==false)
.LeftJoin<TrackFlagEntity>((a, b, c) => a.TrackFlagId==c.Id&&c.IsDeleted==false)
.LeftJoin<VSystemEntity>((a, b, c, d) => a.SubSystemId == d.Id && d.IsDeleted == false)
.LeftJoin<VUserEntity>((a, b, c, d, e) => a.CreateUserId == e.Id && e.IsDeleted == false)
.LeftJoin<VUserEntity>((a, b, c, d, e, f) => a.UpdateUserId == f.Id && f.IsDeleted == false)
.WhereIF(input.SubSystemId > 0, (a, b, c, d, e, f) => a.SubSystemId == input.SubSystemId)
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(),
(a, b, c, d, e, f) => a.Code.Contains(input.Keywords) || a.Content.Contains(input.Keywords)
@ -83,6 +83,10 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
})
.ToPagedListAsync(input.PageIndex, input.PageSize);
var ff = await Context.Queryable<TrackContentEntity>().Where(a => 1==1).ToListAsync();
return pagedList;
}
}

View File

@ -18,7 +18,7 @@ public class TrackFlagRepository : BasicRepository<TrackFlagEntity>, ITrackFlagR
public async Task<GetTrackFlagDetailVO?> GetDetailAsync(int id)
{
var detail = await Context.Queryable<TrackFlagEntity>()
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id && b.IsDeleted == false)
.Where((a, b) => a.Id == id)
.Select((a, b) => new GetTrackFlagDetailVO
{
@ -42,9 +42,9 @@ public class TrackFlagRepository : BasicRepository<TrackFlagEntity>, ITrackFlagR
{
UnifyPageResultDto<GetTrackFlagListVO> pagedList = new UnifyPageResultDto<GetTrackFlagListVO>();
pagedList = await Context.Queryable<TrackFlagEntity>()
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
.LeftJoin<VUserEntity>((a, b, c) => a.CreateUserId == c.Id)
.LeftJoin<VUserEntity>((a, b, c, d) => a.UpdateUserId == d.Id)
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id && b.IsDeleted == false)
.LeftJoin<VUserEntity>((a, b, c) => a.CreateUserId == c.Id && c.IsDeleted == false)
.LeftJoin<VUserEntity>((a, b, c, d) => a.UpdateUserId == d.Id && d.IsDeleted == false)
.WhereIF(input.SubSystemId > 0, (a, b, c, d) => a.SubSystemId == input.SubSystemId)
.OrderByIF(input.SelectIds.IsNullOrEmpty(), (a, b, c, d) => a.CreateTime, OrderByType.Desc)
.OrderByIF(!input.SelectIds.IsNullOrEmpty(), (a, b, c, d) => SqlFunc.IIF(input.SelectIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), a.CreateTime), OrderByType.Desc)

View File

@ -14,7 +14,7 @@ public class TrackStatusRepository : BasicRepository<TrackStatusEntity>, ITrackS
public async Task<GetTrackStatusDetailVO?> GetDetailAsync(int id)
{
var detail = await Context.Queryable<TrackStatusEntity>()
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id&&b.IsDeleted==false)
.Where((a, b) => a.Id == id)
.Select((a, b) => new GetTrackStatusDetailVO
{
@ -38,9 +38,9 @@ public class TrackStatusRepository : BasicRepository<TrackStatusEntity>, ITrackS
public async Task<UnifyPageResultDto<GetTrackStatusListVO>> GetPageTrackStatus(GetPageTrackStatusVO input)
{
UnifyPageResultDto<GetTrackStatusListVO> pagedList = await Context.Queryable<TrackStatusEntity>()
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
.LeftJoin<VUserEntity>((a, b, c) => a.CreateUserId == c.Id)
.LeftJoin<VUserEntity>((a, b, c, d) => a.UpdateUserId == d.Id)
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id && b.IsDeleted == false)
.LeftJoin<VUserEntity>((a, b, c) => a.CreateUserId == c.Id && c.IsDeleted == false)
.LeftJoin<VUserEntity>((a, b, c, d) => a.UpdateUserId == d.Id && d.IsDeleted == false)
.WhereIF(input.SubSystemId > 0, (a, b, c, d) => a.SubSystemId == input.SubSystemId)
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(),
(a, b, c, d) => a.Status.Contains(input.Keywords) || a.EnStatus.Contains(input.Keywords) ||

View File

@ -20,7 +20,7 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
public async Task<GetTrackTemplateDetailVO?> GetDetailAsync(int id)
{
var detail = await Context.Queryable<TrackTemplateEntity>()
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id&&b.IsDeleted==false)
.Where((a, b) => a.Id == id)
.Select((a, b) => new
GetTrackTemplateDetailVO
@ -43,7 +43,7 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
public async Task<UnifyPageResultDto<GetTrackTemplateListVO>> GetPageTrackTemplate(GetPageTrackTemplateVO input)
{
UnifyPageResultDto<GetTrackTemplateListVO> pagedList = await Context.Queryable<TrackTemplateEntity>()
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id && b.IsDeleted == false)
.WhereIF(input.SubSystemId > 0, (a, b) => a.SubSystemId == input.SubSystemId)
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(),
(a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords))