轨迹模版调整

This commit is contained in:
moyongzhen 2024-02-28 16:21:53 +08:00
parent 047e9b4885
commit 3f7a978ec6
4 changed files with 26 additions and 3 deletions

View File

@ -90,6 +90,6 @@
/// <summary> /// <summary>
/// 模板代码 /// 模板代码
/// </summary> /// </summary>
public int Code { set; get; } public string Code { set; get; }
} }
} }

View File

@ -3,6 +3,8 @@
"texts": { "texts": {
"NotNull1": "{0} is not null", "NotNull1": "{0} is not null",
"NotFindData": "No data found under the specified number", "NotFindData": "No data found under the specified number",
"ParameterDemo1": "{0} in {1} to do {2}" "ParameterDemo1": "{0} in {1} to do {2}",
"TemplateExist": "The template code already exists under the currently selected subsystem"
} }
} }

View File

@ -3,6 +3,7 @@
"texts": { "texts": {
"NotFindData": "未找到指定编号下的任何数据!", "NotFindData": "未找到指定编号下的任何数据!",
"ParameterDemo": "{0}在{1}地方做了{2}动作", "ParameterDemo": "{0}在{1}地方做了{2}动作",
"ParameterDemo1": "{0}在{1}地方做了{2}动作" "ParameterDemo1": "{0}在{1}地方做了{2}动作",
"TemplateExist": "模板代码已存在于当前选择的子系统下"
} }
} }

View File

@ -83,6 +83,15 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
private async Task<UnifyResultDto> AddAsync(EditTrackTemplateInput input) private async Task<UnifyResultDto> AddAsync(EditTrackTemplateInput input)
{ {
#region 业务校验
//校验模版代码唯一性
var templateEntity = await _trackTemplateRepository.GetFirstAsync(a => a.SubSystemId == input.SubSystemId &&a.Code==input.Code);
if (templateEntity != null)
{
throw new BusinessException(message: _stringLocalizer["TemplateExist"]);
}
#endregion
var entity = ObjectMapper.Map<EditTrackTemplateInput, TrackTemplateEntity>(input); var entity = ObjectMapper.Map<EditTrackTemplateInput, TrackTemplateEntity>(input);
var isTrue = await _trackTemplateRepository.InsertAsync(entity); var isTrue = await _trackTemplateRepository.InsertAsync(entity);
@ -91,6 +100,14 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
private async Task<UnifyResultDto> UpdateAsync(EditTrackTemplateInput input) private async Task<UnifyResultDto> UpdateAsync(EditTrackTemplateInput input)
{ {
#region 业务校验
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: _stringLocalizer["TemplateExist"]);
}
#endregion
var templateEntity = await _trackTemplateRepository.GetFirstAsync(a => a.Id == input.Id); var templateEntity = await _trackTemplateRepository.GetFirstAsync(a => a.Id == input.Id);
ObjectMapper.Map(input, templateEntity); ObjectMapper.Map(input, templateEntity);
var isTrue = await _trackTemplateRepository.UpdateAsync(templateEntity); var isTrue = await _trackTemplateRepository.UpdateAsync(templateEntity);
@ -100,6 +117,9 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
private async Task<UnifyResultDto> DeleteAsync(EditTrackTemplateInput input) private async Task<UnifyResultDto> DeleteAsync(EditTrackTemplateInput input)
{ {
#region 业务校验
//到时候,得判断这个模版有没有在轨迹映射里面被使用过,如果被使用就抛出提示
#endregion
var isTrue = await _trackTemplateRepository.SoftDeleteAsync(x => x.Id == input.Id); var isTrue = await _trackTemplateRepository.SoftDeleteAsync(x => x.Id == input.Id);
return new UnifyResultDto("200", "删除成功", isTrue); return new UnifyResultDto("200", "删除成功", isTrue);