修改轨迹内容时同步修改轨迹内容映射
This commit is contained in:
parent
ad56431c39
commit
e40ea3bdba
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using SJZY.Expand.ABP.Core.Common.Dto;
|
using SJZY.Expand.ABP.Core.Common.Dto;
|
||||||
using SJZY.Expand.ABP.Core.Localization;
|
using SJZY.Expand.ABP.Core.Localization;
|
||||||
|
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||||
using SJZY.Track.Application.Contract.Dtos.TrackContents;
|
using SJZY.Track.Application.Contract.Dtos.TrackContents;
|
||||||
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||||
using SJZY.Track.Application.Localization;
|
using SJZY.Track.Application.Localization;
|
||||||
@ -122,8 +123,33 @@ namespace SJZY.Track.Application.Services.TrackContents
|
|||||||
|
|
||||||
//更新的时候需要覆盖内容映射轨迹代码
|
//更新的时候需要覆盖内容映射轨迹代码
|
||||||
var templateEntity = await _trackContentRepository.GetFirstAsync(a => a.Id == input.Id);
|
var templateEntity = await _trackContentRepository.GetFirstAsync(a => a.Id == input.Id);
|
||||||
ObjectMapper.Map(input, templateEntity);
|
|
||||||
var isTrue = await _trackContentRepository.UpdateAsync(templateEntity);
|
bool isTrue = false;
|
||||||
|
|
||||||
|
using (var ts = TransactionScopeHelper.Create())
|
||||||
|
{
|
||||||
|
// 如果轨迹内容的子系统和code发生变化,同步到轨迹映射表
|
||||||
|
if (templateEntity.SubSystemId != input.SubSystemId || templateEntity.Code != input.Code)
|
||||||
|
{
|
||||||
|
await _trackContentRepository.UpdateMapAsync(x => new TrackContentMapEntity
|
||||||
|
{
|
||||||
|
SubSystemId = input.SubSystemId,
|
||||||
|
TrackContentCode = input.Code
|
||||||
|
}, x => x.TrackContentId == input.Id);
|
||||||
|
|
||||||
|
await _trackContentRepository.UpdateMapAsync(x => new TrackContentMapEntity
|
||||||
|
{
|
||||||
|
MapSubSystemId = input.SubSystemId,
|
||||||
|
MapTrackContentCode = input.Code
|
||||||
|
}, x => x.MapTrackContentId == input.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectMapper.Map(input, templateEntity);
|
||||||
|
|
||||||
|
isTrue = await _trackContentRepository.UpdateAsync(templateEntity);
|
||||||
|
|
||||||
|
ts.Complete();
|
||||||
|
}
|
||||||
|
|
||||||
return new UnifyResultDto("200", "修改成功", isTrue);
|
return new UnifyResultDto("200", "修改成功", isTrue);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,4 +21,6 @@ public interface ITrackContentRepository : IBasicRepository<TrackContentEntity>
|
|||||||
Task<bool> UpdateMapAsync(TrackContentMapEntity updateObj);
|
Task<bool> UpdateMapAsync(TrackContentMapEntity updateObj);
|
||||||
|
|
||||||
Task<bool> SoftDeleteMapAsync(Expression<Func<TrackContentMapEntity, bool>> whereExpression);
|
Task<bool> SoftDeleteMapAsync(Expression<Func<TrackContentMapEntity, bool>> whereExpression);
|
||||||
|
|
||||||
|
Task<bool> UpdateMapAsync(Expression<Func<TrackContentMapEntity, TrackContentMapEntity>> columns, Expression<Func<TrackContentMapEntity, bool>> whereExpression);
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@ using SJZY.Track.Domain.Aggregates.TrackFlagAggregate;
|
|||||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||||
using SJZY.Track.Domain.Dtos.TrackContents;
|
using SJZY.Track.Domain.Dtos.TrackContents;
|
||||||
using SJZY.Track.Domain.VEntities;
|
using SJZY.Track.Domain.VEntities;
|
||||||
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
namespace SJZY.Track.Repository.Repositories;
|
namespace SJZY.Track.Repository.Repositories;
|
||||||
@ -167,4 +168,10 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
|
|||||||
.SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true)
|
.SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true)
|
||||||
.ExecuteCommandHasChangeAsync();
|
.ExecuteCommandHasChangeAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateMapAsync(Expression<Func<TrackContentMapEntity, TrackContentMapEntity>> columns, Expression<Func<TrackContentMapEntity, bool>> whereExpression)
|
||||||
|
{
|
||||||
|
return await Context.Updateable<TrackContentMapEntity>().SetColumns(columns).Where(whereExpression)
|
||||||
|
.ExecuteCommandAsync() > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user