Merge pull request '完成 轨迹内容映射编辑 接口' (#8) from S01-轨迹中台 into dev
Reviewed-on: http://192.168.80.50:3000/Dotnet/SJZY.Track.Api/pulls/8
This commit is contained in:
commit
7f7dab910c
@ -15,6 +15,7 @@ namespace SJZY.Track.Application.AutoMapper
|
|||||||
CreateMap<GetTrackContentListVO, GetTrackContentListDto>(MemberList.None);
|
CreateMap<GetTrackContentListVO, GetTrackContentListDto>(MemberList.None);
|
||||||
CreateMap<UnifyPageResultDto<GetTrackContentListVO>, UnifyPageResultDto<GetTrackContentListDto>>(
|
CreateMap<UnifyPageResultDto<GetTrackContentListVO>, UnifyPageResultDto<GetTrackContentListDto>>(
|
||||||
MemberList.None);
|
MemberList.None);
|
||||||
|
CreateMap<EditTrackContentMapInput, TrackContentMapEntity>(MemberList.None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,12 +186,25 @@ namespace SJZY.Track.Application.Services.TrackContents
|
|||||||
switch (input.Options)
|
switch (input.Options)
|
||||||
{
|
{
|
||||||
case OptionTypeNoNull.新增:
|
case OptionTypeNoNull.新增:
|
||||||
break;
|
{
|
||||||
|
var trackContentMapEntity = ObjectMapper.Map<EditTrackContentMapInput, TrackContentMapEntity>(input);
|
||||||
|
|
||||||
case OptionTypeNoNull.删除:
|
await _trackContentRepository.InsertMapAsync(trackContentMapEntity);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionTypeNoNull.修改:
|
case OptionTypeNoNull.修改:
|
||||||
|
{
|
||||||
|
var oldTrackContentMapEntity = await _trackContentRepository.GetMapByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||||
|
|
||||||
|
ObjectMapper.Map(input, oldTrackContentMapEntity);
|
||||||
|
|
||||||
|
await _trackContentRepository.UpdateMapAsync(oldTrackContentMapEntity);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OptionTypeNoNull.删除:
|
||||||
|
await _trackContentRepository.SoftDeleteMapAsync(x => x.Id == input.Id);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -13,4 +13,12 @@ public interface ITrackContentRepository : IBasicRepository<TrackContentEntity>
|
|||||||
Task<GetTrackContentMapDetailOutputVO> GetMapDetailAsync(int id);
|
Task<GetTrackContentMapDetailOutputVO> GetMapDetailAsync(int id);
|
||||||
|
|
||||||
Task<bool> IsMapAnyAsync(Expression<Func<TrackContentMapEntity, bool>> whereExpression);
|
Task<bool> IsMapAnyAsync(Expression<Func<TrackContentMapEntity, bool>> whereExpression);
|
||||||
|
|
||||||
|
Task<bool> InsertMapAsync(TrackContentMapEntity insertObj);
|
||||||
|
|
||||||
|
Task<TrackContentMapEntity> GetMapByIdAsync(int id);
|
||||||
|
|
||||||
|
Task<bool> UpdateMapAsync(TrackContentMapEntity updateObj);
|
||||||
|
|
||||||
|
Task<bool> SoftDeleteMapAsync(Expression<Func<TrackContentMapEntity, bool>> whereExpression);
|
||||||
}
|
}
|
||||||
@ -144,4 +144,27 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
|
|||||||
{
|
{
|
||||||
return await Context.Queryable<TrackContentMapEntity>().Where(whereExpression).AnyAsync();
|
return await Context.Queryable<TrackContentMapEntity>().Where(whereExpression).AnyAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> InsertMapAsync(TrackContentMapEntity insertObj)
|
||||||
|
{
|
||||||
|
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TrackContentMapEntity> GetMapByIdAsync(int id)
|
||||||
|
{
|
||||||
|
return await Context.Queryable<TrackContentMapEntity>().InSingleAsync(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateMapAsync(TrackContentMapEntity updateObj)
|
||||||
|
{
|
||||||
|
return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SoftDeleteMapAsync(Expression<Func<TrackContentMapEntity, bool>> whereExpression)
|
||||||
|
{
|
||||||
|
return await Context.Updateable<TrackContentMapEntity>()
|
||||||
|
.Where(whereExpression)
|
||||||
|
.SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true)
|
||||||
|
.ExecuteCommandHasChangeAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user