|
@@ -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;
|