Merge pull request 'S01-轨迹中台' (#13) from S01-轨迹中台 into dev

Reviewed-on: http://192.168.80.50:3000/Dotnet/SJZY.Track.Api/pulls/13
This commit is contained in:
liuwenxiang 2024-03-02 10:08:22 +08:00
commit 130c8ce17a
8 changed files with 73 additions and 6 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

@ -0,0 +1,11 @@
using SJZY.Expand.ABP.Core.PublicMethords;
namespace SJZY.Track.Application.Contract.Dtos.TrackTemplates;
public class SortTrackTemplateContentInput
{
/// <summary>
/// 排序信息
/// </summary>
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

@ -1,6 +1,7 @@
using System.Linq.Expressions;
using Microsoft.Extensions.Localization;
using SJZY.Expand.ABP.Core.Localization;
using SJZY.Track.Application.Contract.Dtos.TrackPush;
using SJZY.Track.Application.Contract.Dtos.TrackTemplates;
using SJZY.Track.Application.Localization;
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
@ -34,7 +35,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
_stringLocalizer = stringLocalizer;
_trackTemplateRepository = trackTemplateRepository;
_trackPullConfigRepository = trackPullConfigRepository;
_trackPushConfigRepository=trackPushConfigRepository;
_trackPushConfigRepository = trackPushConfigRepository;
}
/// <summary>
@ -119,7 +120,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
var isExist = await _trackTemplateRepository.GetFirstAsync(a =>
a.Id != input.Id && a.SubSystemId == input.SubSystemId && a.Code == input.Code);
if (isExist != null)
{
{
throw new BusinessException(message: "模板代码已存在于当前选择的子系统下");
}
@ -140,7 +141,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
var isExisistTrackPullConfigs = await _trackPullConfigRepository.GetListAsync(a => a.TrackTemplateId == input.Id);
if (isExisistTrackPullConfigs.Any())
{
//throw new BusinessException(message: _stringLocalizer["IsExistTrackPullConfig"]);
//throw new BusinessException(message: _stringLocalizer["IsExistTrackPullConfig"]);
throw new BusinessException(message: "轨迹拉取配置里已经绑定模版,请检查");
}
//轨迹推送里看看是否被占用
@ -234,4 +235,26 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
return true;
}
/// <summary>
/// 轨迹模板内容排序
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("SortContent")]
public async Task<bool> SortContentAsync([FromBody] SortTrackTemplateContentInput input)
{
List<int> ids = input.SortInfo.Select(x => int.Parse(x.Key)).ToList();
var trackTemplateContentEntities = await _trackTemplateRepository.GetContentListAsync(x => ids.Contains(x.Id));
trackTemplateContentEntities.ForEach(item =>
{
item.Sort = input.SortInfo.Single(x => x.Key == item.Id.ToString()).Value;
});
await _trackTemplateRepository.UpdateContentRangeAsync(trackTemplateContentEntities);
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

@ -35,4 +35,6 @@ public interface ITrackTemplateRepository : IBasicRepository<TrackTemplateEntity
Task<List<TrackTemplateContentEntity>> GetContentListAsync(
Expression<Func<TrackTemplateContentEntity, bool>> whereExpression);
Task<bool> UpdateContentRangeAsync(List<TrackTemplateContentEntity> 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();
}
}

View File

@ -158,4 +158,9 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
{
return await Context.Queryable<TrackTemplateContentEntity>().Where(whereExpression).ToListAsync();
}
public async Task<bool> UpdateContentRangeAsync(List<TrackTemplateContentEntity> updateObjs)
{
return await Context.Updateable(updateObjs).ExecuteCommandHasChangeAsync();
}
}