完成 轨迹推送配置内容排序 接口

This commit is contained in:
柳文翔 2024-03-02 10:00:08 +08:00
parent 51099d850b
commit 92f61e1a1b
4 changed files with 29 additions and 3 deletions

View File

@ -1,9 +1,11 @@
namespace SJZY.Track.Application.Contract.Dtos.TrackPush;
using SJZY.Expand.ABP.Core.PublicMethords;
namespace SJZY.Track.Application.Contract.Dtos.TrackPush;
public class SortTrackPushContentInput
{
/// <summary>
/// 排序信息
/// </summary>
public List<Dictionary<int, int>> SortInfo { get; set; }
public List<DropdownListDataDto> SortInfo { get; set; }
}

View File

@ -4,7 +4,6 @@ using SJZY.Expand.ABP.Core.Localization;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Application.Contract.Dtos.TrackPush;
using SJZY.Track.Application.Localization;
using SJZY.Track.Domain.Aggregates.DemoAggregate;
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
@ -246,6 +245,17 @@ public class TrackPushService : ApplicationService, ITransientDependency
[HttpPost("SortContent")]
public async Task<bool> SortContentAsync([FromBody] SortTrackPushContentInput input)
{
List<int> ids = input.SortInfo.Select(x => int.Parse(x.Key)).ToList();
var trackPushContentEntities = await _trackPushConfigRepository.GetContentListAsync(x => ids.Contains(x.Id));
trackPushContentEntities.ForEach(item =>
{
item.Sort = input.SortInfo.Single(x => x.Key == item.Id.ToString()).Value;
});
await _trackPushConfigRepository.UpdateContentRangeAsync(trackPushContentEntities);
return true;
}
}

View File

@ -22,4 +22,8 @@ public interface ITrackPushConfigRepository : IBasicRepository<TrackPushConfigEn
Task<TrackPushContentConfigEntity> GetContentByIdAsync(int id);
Task<bool> UpdateContentAsync(TrackPushContentConfigEntity updateObj);
Task<List<TrackPushContentConfigEntity>> GetContentListAsync(Expression<Func<TrackPushContentConfigEntity, bool>> whereExpression);
Task<bool> UpdateContentRangeAsync(List<TrackPushContentConfigEntity> updateObjs);
}

View File

@ -114,4 +114,14 @@ public class TrackPushConfigRepository : BasicRepository<TrackPushConfigEntity>,
{
return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync();
}
public async Task<List<TrackPushContentConfigEntity>> GetContentListAsync(Expression<Func<TrackPushContentConfigEntity, bool>> whereExpression)
{
return await Context.Queryable<TrackPushContentConfigEntity>().Where(whereExpression).ToListAsync();
}
public async Task<bool> UpdateContentRangeAsync(List<TrackPushContentConfigEntity> updateObjs)
{
return await Context.Updateable(updateObjs).ExecuteCommandHasChangeAsync();
}
}