feat: 完成租户前端对接

This commit is contained in:
橙子
2024-02-08 19:48:35 +08:00
parent 39d472bdc8
commit 36f72c857d
12 changed files with 92 additions and 15 deletions

View File

@@ -104,6 +104,7 @@ namespace Yi.Framework.Rbac.Application.Services
return new { Token = accessToken, RefreshToken = refreshToken };
}
/// <summary>
/// 刷新token
/// </summary>

View File

@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using TencentCloud.Tcr.V20190924.Models;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.EventBus.Local;
@@ -85,6 +86,11 @@ namespace Yi.Framework.Rbac.Application.Services.System
[Permission("system:user:add")]
public async override Task<UserGetOutputDto> CreateAsync(UserCreateInputVo input)
{
if (input.UserName == UserConst.Admin || input.UserName == UserConst.TenantAdmin)
{
throw new UserFriendlyException(UserConst.Name_Not_Allowed);
}
if (string.IsNullOrEmpty(input.Password))
{
throw new UserFriendlyException(UserConst.Login_Passworld_Error);
@@ -134,6 +140,10 @@ namespace Yi.Framework.Rbac.Application.Services.System
[Permission("system:user:update")]
public async override Task<UserGetOutputDto> UpdateAsync(Guid id, UserUpdateInputVo input)
{
if (input.UserName == UserConst.Admin || input.UserName == UserConst.TenantAdmin)
{
throw new UserFriendlyException(UserConst.Name_Not_Allowed);
}
if (await _repository.IsAnyAsync(u => input.UserName!.Equals(u.UserName) && !id.Equals(u.Id)))
{
throw new UserFriendlyException("用户已经存在,更新失败");

View File

@@ -19,6 +19,7 @@ namespace Yi.Framework.Rbac.Domain.Shared.Consts
public const string State_Is_State = "该用户已被禁用,请联系管理员进行恢复";
public const string No_Permission = "登录禁用!该用户分配无任何权限,无意义登录!";
public const string No_Role = "登录禁用!该用户分配无任何角色,无意义登录!";
public const string Name_Not_Allowed = "用户名被禁止";
//子租户管理员
public const string Admin = "cc";

View File

@@ -13,6 +13,11 @@ namespace Yi.Framework.Rbac.Domain.Shared.Options
/// </summary>
public string AdminPassword { get; set; } = "123456";
/// <summary>
/// 租户超级管理员默认密码
/// </summary>
public string TenantAdminPassword { get; set; } = "123456";
/// <summary>
/// 是否开启登录验证码
/// </summary>

View File

@@ -11,6 +11,7 @@ using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Services;
using Volo.Abp.EventBus.Local;
using Volo.Abp.Security.Claims;
using Volo.Abp.Users;
using Yi.Framework.Core.Helper;
using Yi.Framework.Rbac.Domain.Entities;
using Yi.Framework.Rbac.Domain.Repositories;
@@ -32,6 +33,7 @@ namespace Yi.Framework.Rbac.Domain.Managers
private readonly IUserRepository _repository;
private readonly ILocalEventBus _localEventBus;
private readonly JwtOptions _jwtOptions;
private readonly RbacOptions _options;
private IHttpContextAccessor _httpContextAccessor;
private UserManager _userManager;
private ISqlSugarRepository<RoleEntity> _roleRepository;
@@ -42,7 +44,8 @@ namespace Yi.Framework.Rbac.Domain.Managers
, ILocalEventBus localEventBus
, UserManager userManager
, IOptions<RefreshJwtOptions> refreshJwtOptions
, ISqlSugarRepository<RoleEntity> roleRepository)
, ISqlSugarRepository<RoleEntity> roleRepository
, IOptions<RbacOptions> options)
{
_repository = repository;
_httpContextAccessor = httpContextAccessor;
@@ -51,6 +54,7 @@ namespace Yi.Framework.Rbac.Domain.Managers
_userManager = userManager;
_roleRepository = roleRepository;
_refreshJwtOptions = refreshJwtOptions.Value;
_options = options.Value;
}
/// <summary>
@@ -215,7 +219,7 @@ namespace Yi.Framework.Rbac.Domain.Managers
dto.PermissionCodes?.ForEach(per => AddToClaim(claims, TokenTypeConst.Permission, per));
dto.RoleCodes?.ForEach(role => AddToClaim(claims, AbpClaimTypes.Role, role));
}
return claims;
}

View File

@@ -25,6 +25,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.Repositories
/// <exception cref="ArgumentNullException"></exception>
public async Task<UserRoleMenuDto> GetUserAllInfoAsync(Guid userId)
{
var userRoleMenu = new UserRoleMenuDto();
//首先获取到该用户全部信息,导航到角色、菜单,(菜单需要去重,完全交给Set来处理即可)