轨迹模版功能
This commit is contained in:
parent
3de032803a
commit
60839dee12
@ -78,22 +78,26 @@ namespace SJZY.Track.Application.Services.TrackTemplates
|
||||
#region 私有方法
|
||||
private async Task<UnifyResultDto> AddAsync(EditTrackTemplateInput input)
|
||||
{
|
||||
var entity = ObjectMapper.Map<EditTrackTemplateInput, TrackTemplateEntity>(input);
|
||||
var isTrue = await _trackTemplateRepository.InsertAsync(entity);
|
||||
|
||||
return null;
|
||||
return new UnifyResultDto("200", "新增成功", isTrue);
|
||||
}
|
||||
|
||||
private async Task<UnifyResultDto> UpdateAsync(EditTrackTemplateInput input)
|
||||
{
|
||||
var templateEntity = await _trackTemplateRepository.GetFirstAsync(a => a.Id==input.Id);
|
||||
ObjectMapper.Map(input, templateEntity);
|
||||
var isTrue = await _trackTemplateRepository.UpdateAsync(templateEntity);
|
||||
|
||||
|
||||
return null;
|
||||
return new UnifyResultDto("200", "修改成功", isTrue);
|
||||
}
|
||||
|
||||
private async Task<UnifyResultDto> DeleteAsync(EditTrackTemplateInput input)
|
||||
{
|
||||
var isTrue = await _trackTemplateRepository.DeleteByIdAsync(input.Id);
|
||||
|
||||
|
||||
return null;
|
||||
return new UnifyResultDto("200", "删除成功", isTrue);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
using FluentValidation;
|
||||
using SJZY.Track.Application.Dtos.Demo;
|
||||
using SJZY.Track.Application.Dtos.TrackTemplates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SJZY.Track.Application.Validations.TrackTemplates
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹模版编辑校验
|
||||
/// </summary>
|
||||
public class EditTrackTemplateInputValidation : AbstractValidator<EditTrackTemplateInput>, IValidationEnabled
|
||||
{
|
||||
public EditTrackTemplateInputValidation()
|
||||
{
|
||||
//条件分支
|
||||
When(x => x.Options == OptionType.修改 || x.Options == OptionType.删除, () =>
|
||||
{
|
||||
RuleFor(x => x.Id).GreaterThan(0).WithMessage("修改或删除时Id必须大于0!");
|
||||
});
|
||||
|
||||
When(x => x.Options == OptionType.新增, () =>
|
||||
{
|
||||
RuleFor(x => x.Id).Equal(0).WithMessage("新增时Id必须等于0!");
|
||||
});
|
||||
|
||||
When(x => x.Options == OptionType.修改 || x.Options == OptionType.新增, () =>
|
||||
{
|
||||
RuleFor(x => x.Name).NotNull().WithMessage("模版名称必填!").NotEmpty().WithMessage("模版名称不能为空!");
|
||||
RuleFor(x => x.Code).NotNull().WithMessage("模版代码必填!").NotEmpty().WithMessage("模版代码不能为空!");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user