浏览代码

不能出现同名的部门

admin 2 年之前
父节点
当前提交
09af0fa0eb
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      src/Hotline.Api/Controllers/OrgController.cs

+ 5 - 0
src/Hotline.Api/Controllers/OrgController.cs

@@ -75,6 +75,11 @@ namespace Hotline.Api.Controllers
                 throw UserFriendlyException.SameMessage("无效组织架构");
             if (org.Id == dto.ParentId)
                 throw UserFriendlyException.SameMessage("父级不能为自己");
+            //验证名称是否重复
+            if (await _systemDomainService.IsNameRepeat(dto.OrgName, HttpContext.RequestAborted))
+            {
+                throw UserFriendlyException.SameMessage("组织名称重复");
+            }
             _mapper.Map(dto, org);
             await _systemOrganizeRepository.UpdateAsync(org, HttpContext.RequestAborted);
         }