diff --git a/IRaCIS.Core.Application/Resources/en-US.json b/IRaCIS.Core.Application/Resources/en-US.json index f6f50df03..79ffad22a 100644 --- a/IRaCIS.Core.Application/Resources/en-US.json +++ b/IRaCIS.Core.Application/Resources/en-US.json @@ -128,6 +128,7 @@ //UserWLTemplateService "UserWLTS_MaxTemplate": "The same user can add a maximum of 10 templates.", "UserWLTS_NameRepeated": "The template name is repeated", + "UserWLTS_ContentRepeated": "The template content is repeated", // ------------------------------------------------------------Allocation-------------------------------------------------------------------- //TaskAllocationRuleService diff --git a/IRaCIS.Core.Application/Resources/zh-CN.json b/IRaCIS.Core.Application/Resources/zh-CN.json index 7b0e809de..339ed9903 100644 --- a/IRaCIS.Core.Application/Resources/zh-CN.json +++ b/IRaCIS.Core.Application/Resources/zh-CN.json @@ -128,6 +128,7 @@ //UserWLTemplateService "UserWLTS_MaxTemplate": "同一个用户最多只能添加10个模板", "UserWLTS_NameRepeated": "模板名称存在重复", + "UserWLTS_ContentRepeated": "模板内容存在重复", // ------------------------------------------------------------Allocation-------------------------------------------------------------------- //TaskAllocationRuleService diff --git a/IRaCIS.Core.Application/Service/Reading/ShortcutKey/UserWLTemplateService.cs b/IRaCIS.Core.Application/Service/Reading/ShortcutKey/UserWLTemplateService.cs index 9ae14cf62..8fd25bc66 100644 --- a/IRaCIS.Core.Application/Service/Reading/ShortcutKey/UserWLTemplateService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ShortcutKey/UserWLTemplateService.cs @@ -65,8 +65,11 @@ namespace IRaCIS.Core.Application.Service { throw new BusinessValidationFailedException(_localizer["UserWLTS_NameRepeated"]); } - + if (await _userWLTemplateRepository.AnyAsync(x => x.UserId == _userInfo.Id && x.WW == addOrEditUserWLTemplate.WW && x.WL == addOrEditUserWLTemplate.WL && x.Id != addOrEditUserWLTemplate.Id)) + { + throw new BusinessValidationFailedException(_localizer["UserWLTS_ContentRepeated"]); + } var entity = await _userWLTemplateRepository.InsertOrUpdateAsync(addOrEditUserWLTemplate, true); return ResponseOutput.Ok(entity.Id.ToString());