轨迹内容调整

This commit is contained in:
moyongzhen 2024-03-04 16:42:52 +08:00
parent 2177f0741f
commit cc325aa496
6 changed files with 45 additions and 14 deletions

View File

@ -7,8 +7,8 @@
}
},
"ConnectionStrings": {
"DefaultConnection": "server=192.168.80.84;Database=sjzy_package_setting;Uid=sjzy_test_user;Pwd=848c1c31;AllowLoadLocalInfile=true;SslMode=None;Charset=utf8mb4;",
"canalView": "server=192.168.80.84;Database=sjzy_data_center;Uid=sjzy_test_user;Pwd=848c1c31;AllowLoadLocalInfile=true;SslMode=None;Charset=utf8mb4;"
"DefaultConnection": "server=mysql-test.default.svc.cluster.local;Database=sjzy_track;Uid=sjzy_test_user;Pwd=848c1c31;AllowLoadLocalInfile=true;SslMode=None;Charset=utf8mb4;",
"canalView": "server=mysql-test.default.svc.cluster.local;Database=sjzy_track;Uid=sjzy_test_user;Pwd=848c1c31;AllowLoadLocalInfile=true;SslMode=None;Charset=utf8mb4;"
},
"Redis": {
"ConnectionString": "192.168.80.58:6379,abortConnect=false",

View File

@ -193,21 +193,24 @@ namespace SJZY.Track.Application.Services.TrackContents
private async Task<UnifyResultDto> DeleteAsync(EditTrackContentInput input)
{
#region 业务校验
//查询是否关联了轨迹模版内容
var trackTemplateContents = await _trackTemplateContentBasicQuery.GetListAsync(a => a.TrackContentId == input.Id);
if (trackTemplateContents.Any())
var isExistTemplate = await _trackContentRepository.GetTemplateIsExist(input.Id);
if (isExistTemplate)
{
throw new BusinessException(message: "该轨迹内容关联轨迹模板,禁止删除");
}
//var trackTemplateContents = await _trackTemplateContentBasicQuery.GetListAsync(a => a.TrackContentId == input.Id);
//if (trackTemplateContents.Any())
//{
// throw new BusinessException(message: "该轨迹内容关联轨迹模板,禁止删除");
//}
//需要加个判断,存在内容映射,则出提示
var trackContentMapEntities = await _trackContentMapBasicQuery.GetListAsync(a => a.TrackContentId == input.Id || a.MapTrackContentId == input.Id);
if (trackContentMapEntities.Any())
{
throw new BusinessException(message: "无法删除该内容,该轨迹内容已在轨迹内容映射中使用了,请检查");
}
//var trackContentMapEntities = await _trackContentMapBasicQuery.GetListAsync(a => a.TrackContentId == input.Id || a.MapTrackContentId == input.Id);
//if (trackContentMapEntities.Any())
//{
// throw new BusinessException(message: "无法删除该内容,该轨迹内容已在轨迹内容映射中使用了,请检查");
//}
#endregion 业务校验
var isTrue = await _trackContentRepository.SoftDeleteAsync(x => x.Id == input.Id);

View File

@ -163,7 +163,7 @@ public class TrackStatusService : ApplicationService, ITransientDependency
if (isExistStatus!=null)
{
//throw new BusinessException(message: _stringLocalizer["IsExistTrackStatus"]);
throw new BusinessException(message: "轨迹内容已经绑定了该轨迹状态,请先删除轨迹内容后再删除该轨迹状态");
throw new BusinessException(message: "该状态关联轨迹内容,禁止删除");
}
#endregion
var isTrue = await _trackStatusRepository.SoftDeleteAsync(x => x.Id == input.Id);

View File

@ -163,13 +163,13 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
if (isExisistTrackPullConfigs.Any())
{
//throw new BusinessException(message: _stringLocalizer["IsExistTrackPullConfig"]);
throw new BusinessException(message: "轨迹拉取配置里已经绑定模版,请检查");
throw new BusinessException(message: "该模板存在映射,禁止删除");
}
//轨迹推送里看看是否被占用
var isExisistTrackPushConfigs = await _trackPushConfigRepository.GetListAsync(a => a.TrackTemplateId.Contains(input.Id.ToString()));
if (isExisistTrackPushConfigs.Any())
{
throw new BusinessException(message: "轨迹推送配置里已经绑定模版,请检查");
throw new BusinessException(message: "该模板存在映射,禁止删除");
}
#endregion 业务校验

View File

@ -23,4 +23,5 @@ public interface ITrackContentRepository : IBasicRepository<TrackContentEntity>
Task<bool> SoftDeleteMapAsync(Expression<Func<TrackContentMapEntity, bool>> whereExpression);
Task<bool> UpdateMapAsync(Expression<Func<TrackContentMapEntity, TrackContentMapEntity>> columns, Expression<Func<TrackContentMapEntity, bool>> whereExpression);
Task<bool> GetTemplateIsExist(int trackContentId);
}

View File

@ -1,6 +1,7 @@
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
using SJZY.Track.Domain.Aggregates.TrackFlagAggregate;
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
using SJZY.Track.Domain.Dtos.TrackContents;
using SJZY.Track.Domain.VEntities;
using System.Linq;
@ -88,6 +89,32 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
return pagedList;
}
/// <summary>
/// 获取轨迹模版是否存在
/// </summary>
/// <param name="trackContentId"></param>
/// <returns></returns>
public async Task<bool> GetTemplateIsExist(int trackContentId)
{
//var trackTemplateContents = await _trackTemplateContentBasicQuery.GetListAsync(a => a.TrackContentId == input.Id);
var trackContentEntities = await Context.Queryable<TrackContentEntity>().LeftJoin<TrackTemplateContentEntity>((a, b) => a.Id==b.TrackContentId && b.IsDeleted==false)
.LeftJoin<TrackTemplateEntity>((a, b, c) => b.TrackTemplateId==c.Id&& c.IsDeleted==false)
.Where((a, b, c) => a.Id==trackContentId)
.Select((a, b, c) => new
{
TrackContentId = a.Id,
TemplateId = c.Id
})
.ToListAsync();
if (trackContentEntities.Any(a => a.TemplateId>0))
{
return true;
}
return false;
}
public async Task<UnifyPageResultDto<GetTrackContentMapPageOutputVO>> GetMapPageAsync(GetTrackContentMapPageInputVO input)
{
return await Context.Queryable<TrackContentMapEntity>()