Dun.Jason 1 рік тому
батько
коміт
57b7fe61a6
1 змінених файлів з 4 додано та 0 видалено
  1. 4 0
      src/Hotline.Api/Controllers/RoleController.cs

+ 4 - 0
src/Hotline.Api/Controllers/RoleController.cs

@@ -95,6 +95,10 @@ public class RoleController : BaseController
         var clientId = jwtOption.Issuer;
         if (string.IsNullOrEmpty(clientId))
             throw new UserFriendlyException("jwt.Issuer未配置");
+
+        if (string.IsNullOrEmpty(dto.Name))
+            throw UserFriendlyException.SameMessage("角色编码不能为空");
+
         var exists = await _roleRepository.Queryable(includeDeleted: true)
             .AnyAsync(d => d.ClientId == clientId && d.Name == dto.Name);
         if (exists)