Explorar o código

Merge branch 'master' of http://git.fwt.com/Hotline/hotline

Dun.Jason %!s(int64=2) %!d(string=hai) anos
pai
achega
79eb4224de

+ 4 - 2
src/Hotline.Api/Controllers/OrgController.cs

@@ -1,7 +1,8 @@
-using AutoMapper;
-using Hotline.Permissions;
+using Hotline.Permissions;
 using Hotline.Settings;
 using Hotline.Share.Dtos.Org;
+using MapsterMapper;
+using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using XF.Domain.Exceptions;
 
@@ -27,6 +28,7 @@ namespace Hotline.Api.Controllers
         /// <returns></returns>
         [Permission(EPermission.GetOrgJson)]
         [HttpGet("getorgjson")]
+        [AllowAnonymous]
         public async Task<IReadOnlyList<SystemOrganize>> GetOrgJson()
         {
             return await _systemOrganizeRepository.GetOrgJson();

+ 6 - 1
src/Hotline.Api/Controllers/RoleController.cs

@@ -6,6 +6,7 @@ using Identity.Admin.HttpClient;
 using Identity.Shared.Dtos.Identity;
 using Identity.Shared.Dtos.Role;
 using MapsterMapper;
+using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using XF.Domain.Exceptions;
 using XF.Utility.UnifyResponse;
@@ -42,7 +43,6 @@ public class RoleController : BaseController
     [Permission(EPermission.QueryPagedRole)]
     public async Task<PagedDto<IdentityRoleDto>> QueryPaged([FromQuery] QueryRolesPagedDto dto)
     {
-
         var getRolesRsp = await _identityClient.GetRolesPagedAsync(dto, HttpContext.RequestAborted);
         CheckHttpRequestSuccess(getRolesRsp, "GetRolesPagedAsync");
         var result = getRolesRsp.Result;
@@ -58,6 +58,11 @@ public class RoleController : BaseController
     [HttpPost]
     public async Task<string> Add([FromBody] IdentityRoleDto dto)
     {
+        var existsRsp = await _identityClient.IsRoleExistsAsync(dto.Name, HttpContext.RequestAborted);
+        CheckHttpRequestSuccess(existsRsp, "IsRoleExistsAsync");
+        if (existsRsp.Result)
+            throw UserFriendlyException.SameMessage("角色名重复");
+
         var addRoleRsp = await _identityClient.AddRoleAsync(dto, HttpContext.RequestAborted);
         CheckHttpRequestSuccess(addRoleRsp, "AddRoleAsync");
         return addRoleRsp.Result;

+ 1 - 1
src/Hotline.Application/Hotline.Application.csproj

@@ -7,7 +7,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Identity.Admin.HttpClient" Version="1.0.15" />
+    <PackageReference Include="Identity.Admin.HttpClient" Version="1.0.18" />
   </ItemGroup>
 
   <ItemGroup>