Merge branch 'S01-轨迹中台' of http://192.168.80.50:3000/Dotnet/SJZY.Track.Api into S01-轨迹中台
This commit is contained in:
commit
e5419ec2f9
@ -1,5 +1,6 @@
|
||||
using AutoMapper;
|
||||
using SJZY.Track.Application.Dtos.TrackTemplates;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
|
||||
namespace SJZY.Track.Application.AutoMapper
|
||||
@ -14,6 +15,8 @@ namespace SJZY.Track.Application.AutoMapper
|
||||
CreateMap<GetTrackTemplateDetailVO, GetTrackTemplateDetailDto>(MemberList.None);
|
||||
|
||||
//CreateMap<UnifyResultDto<GetTrackTemplateDetailVO>, UnifyResultDto<GetTrackTemplateDetailDto>>(MemberList.None);
|
||||
|
||||
CreateMap<EditTrackTemplateContentInput, TrackTemplateContentEntity>(MemberList.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
namespace SJZY.Track.Application.Dtos.TrackTemplates;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public class EditTrackTemplateContentInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作类型
|
||||
/// </summary>
|
||||
public OptionTypeNoNull Options { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否可删
|
||||
/// </summary>
|
||||
public bool IsCanDelete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否对外
|
||||
/// </summary>
|
||||
public bool IsExternal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int Sort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容id
|
||||
/// </summary>
|
||||
public int TrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板id
|
||||
/// </summary>
|
||||
public int TrackTemplateId { get; set; }
|
||||
}
|
||||
@ -1,8 +1,10 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SJZY.Expand.ABP.Core.Localization;
|
||||
using SJZY.Track.Application.Dtos.TrackTemplates;
|
||||
using SJZY.Track.Application.Localization;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
using System.Linq.Expressions;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackTemplates;
|
||||
@ -111,7 +113,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("GetContentPage")]
|
||||
public async Task<UnifyPageResultDto<GetContentPageOutputVO>> GetContentPageAsync([FromBody] GetContentPageInputVO input)
|
||||
public async Task<UnifyPageResultDto<GetTrackTemplateContentPageOutputVO>> GetContentPageAsync([FromBody] GetTrackTemplateContentPageInputVO input)
|
||||
{
|
||||
return await _trackTemplateRepository.GetContentPageAsync(input);
|
||||
}
|
||||
@ -122,8 +124,59 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetContentDetail")]
|
||||
public async Task<GetContentDetailOutputVO> GetContentDetailAsync(int id)
|
||||
public async Task<GetTrackTemplateContentDetailOutputVO> GetContentDetailAsync(int id)
|
||||
{
|
||||
return await _trackTemplateRepository.GetContentDetailAsync(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板内容编辑
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("EditContent")]
|
||||
public async Task<bool> EditContentAsync([FromBody] EditTrackTemplateContentInput input)
|
||||
{
|
||||
if (input.Options != OptionTypeNoNull.删除)
|
||||
{
|
||||
Expression<Func<TrackTemplateContentEntity, bool>> isAnyExp = x =>
|
||||
x.TrackTemplateId == input.TrackTemplateId && x.TrackContentId == input.TrackContentId;
|
||||
if (input.Options == OptionTypeNoNull.修改) isAnyExp.And(x => x.Id != input.Id);
|
||||
|
||||
if (await _trackTemplateRepository.IsAnyAsync(isAnyExp))
|
||||
throw new BusinessException(message: _stringLocalizer["IsTrackTemplateContentAny"]);
|
||||
}
|
||||
|
||||
switch (input.Options)
|
||||
{
|
||||
case OptionTypeNoNull.新增:
|
||||
|
||||
var entity = ObjectMapper.Map<EditTrackTemplateContentInput, TrackTemplateContentEntity>(input);
|
||||
|
||||
await _trackTemplateRepository.InsertAsync(entity);
|
||||
|
||||
break;
|
||||
|
||||
case OptionTypeNoNull.修改:
|
||||
|
||||
var oldEntity = await _trackTemplateRepository.GetByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||
|
||||
ObjectMapper.Map(input, oldEntity);
|
||||
|
||||
await _trackTemplateRepository.UpdateAsync(oldEntity);
|
||||
|
||||
break;
|
||||
|
||||
case OptionTypeNoNull.删除:
|
||||
|
||||
await _trackTemplateRepository.SoftDeleteContentAsync(input.Id!.Value);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum, nameof(EditTrackTemplateContentInput.Options)]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate.Dtos
|
||||
{
|
||||
public class GetContentDetailOutputVO
|
||||
public class GetTrackTemplateContentDetailOutputVO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
|
||||
public class GetContentPageInputVO : PageInfoInput
|
||||
public class GetTrackTemplateContentPageInputVO : PageInfoInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹模板id
|
||||
@ -1,6 +1,6 @@
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
|
||||
public class GetContentPageOutputVO
|
||||
public class GetTrackTemplateContentPageOutputVO
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹内容代码
|
||||
@ -15,12 +15,22 @@ public interface ITrackTemplateRepository : IBasicRepository<TrackTemplateEntity
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<UnifyPageResultDto<GetContentPageOutputVO>> GetContentPageAsync(GetContentPageInputVO input);
|
||||
Task<UnifyPageResultDto<GetTrackTemplateContentPageOutputVO>> GetContentPageAsync(GetTrackTemplateContentPageInputVO input);
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板内容详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<GetContentDetailOutputVO> GetContentDetailAsync(int id);
|
||||
Task<GetTrackTemplateContentDetailOutputVO> GetContentDetailAsync(int id);
|
||||
|
||||
Task<bool> IsAnyAsync(Expression<Func<TrackTemplateContentEntity, bool>> whereExpression);
|
||||
|
||||
Task<bool> InsertAsync(TrackTemplateContentEntity insertObj);
|
||||
|
||||
Task<TrackTemplateContentEntity> GetByIdAsync(int id);
|
||||
|
||||
Task<bool> UpdateAsync(TrackTemplateContentEntity updateObj);
|
||||
|
||||
Task<bool> SoftDeleteContentAsync(int id);
|
||||
}
|
||||
@ -7,9 +7,11 @@ using SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
using SJZY.Track.Domain.VEntities;
|
||||
using SJZY.Track.Repository.Enum;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITrackTemplateRepository, IScopedDependency
|
||||
{
|
||||
public Task<TemplateContentDto> GetTemplateContentsAsync(List<int> distinctTemplateIds)
|
||||
@ -98,9 +100,9 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<UnifyPageResultDto<GetContentPageOutputVO>> GetContentPageAsync(GetContentPageInputVO input)
|
||||
public async Task<UnifyPageResultDto<GetTrackTemplateContentPageOutputVO>> GetContentPageAsync(GetTrackTemplateContentPageInputVO input)
|
||||
{
|
||||
return await AsSugarClient().Queryable<TrackTemplateContentEntity>()
|
||||
return await Context.Queryable<TrackTemplateContentEntity>()
|
||||
.InnerJoin<TrackContentEntity>((templateContent, trackContent) => templateContent.TrackContentId == trackContent.Id && !trackContent.IsDeleted)
|
||||
.LeftJoin<TrackStatusEntity>((templateContent, trackContent, trackStatus) => trackContent.TrackStatusId == trackStatus.Id && !trackStatus.IsDeleted)
|
||||
.LeftJoin<VEnumValueInfoEntity>((templateContent, trackContent, trackStatus, enumValue) => enumValue.Property == EnumPropertyEnums.节点.GetDescription() && trackStatus.Node == enumValue.Enumkey && !enumValue.IsDeleted)
|
||||
@ -109,7 +111,7 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
.LeftJoin<VUserEntity>((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => templateContent.UpdateUserId == updateUser.Id && !updateUser.IsDeleted)
|
||||
.Filter(null, true)
|
||||
.Where(templateContent => templateContent.TrackTemplateId == input.TrackTemplateId && !templateContent.IsDeleted)
|
||||
.Select((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => new GetContentPageOutputVO
|
||||
.Select((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => new GetTrackTemplateContentPageOutputVO
|
||||
{
|
||||
Id = templateContent.Id,
|
||||
TrackStatus = trackStatus.Status,
|
||||
@ -124,14 +126,14 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<GetContentDetailOutputVO> GetContentDetailAsync(int id)
|
||||
public async Task<GetTrackTemplateContentDetailOutputVO> GetContentDetailAsync(int id)
|
||||
{
|
||||
return await AsSugarClient().Queryable<TrackTemplateContentEntity>()
|
||||
return await Context.Queryable<TrackTemplateContentEntity>()
|
||||
.InnerJoin<TrackContentEntity>((templateContent, trackContent) => templateContent.TrackContentId == trackContent.Id && !trackContent.IsDeleted)
|
||||
.LeftJoin<TrackStatusEntity>((templateContent, trackContent, trackStatus) => trackContent.TrackStatusId == trackStatus.Id && !trackStatus.IsDeleted)
|
||||
.Filter(null, true)
|
||||
.Where(templateContent => templateContent.Id == id && !templateContent.IsDeleted)
|
||||
.Select((templateContent, trackContent, trackStatus) => new GetContentDetailOutputVO
|
||||
.Select((templateContent, trackContent, trackStatus) => new GetTrackTemplateContentDetailOutputVO
|
||||
{
|
||||
Id = templateContent.Id,
|
||||
TrackContent = trackContent.Code + "-" + trackContent.Content,
|
||||
@ -139,4 +141,37 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
}, true)
|
||||
.SingleAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<bool> IsAnyAsync(Expression<Func<TrackTemplateContentEntity, bool>> whereExpression)
|
||||
{
|
||||
return await Context.Queryable<TrackTemplateContentEntity>().Where(whereExpression).AnyAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<bool> InsertAsync(TrackTemplateContentEntity insertObj)
|
||||
{
|
||||
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<TrackTemplateContentEntity> GetByIdAsync(int id)
|
||||
{
|
||||
return await Context.Queryable<TrackTemplateContentEntity>().InSingleAsync(id);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<bool> UpdateAsync(TrackTemplateContentEntity updateObj)
|
||||
{
|
||||
return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<bool> SoftDeleteContentAsync(int id)
|
||||
{
|
||||
return await Context.Updateable<TrackTemplateContentEntity>()
|
||||
.Where(x => x.Id == id)
|
||||
.SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true)
|
||||
.ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user