feat: 完成租户前端对接
This commit is contained in:
@@ -104,6 +104,7 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
return new { Token = accessToken, RefreshToken = refreshToken };
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 刷新token
|
||||
/// </summary>
|
||||
|
||||
@@ -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("用户已经存在,更新失败");
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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来处理即可)
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.TenantManagement.Application.Contracts.Dtos
|
||||
{
|
||||
public class TenantSelectOutputDto : EntityDto<Guid>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SqlSugar;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.Uow;
|
||||
using Yi.Framework.Ddd.Application;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
using Yi.Framework.TenantManagement.Application.Contracts;
|
||||
@@ -60,6 +52,17 @@ namespace Yi.Framework.TenantManagement.Application
|
||||
return new PagedResultDto<TenantGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 租户选项
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<TenantSelectOutputDto>> GetSelectAsync()
|
||||
{
|
||||
var entites = await _repository._DbQueryable.ToListAsync();
|
||||
return entites.Select(x => new TenantSelectOutputDto { Id = x.Id, Name = x.Name }).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建租户
|
||||
/// </summary>
|
||||
@@ -108,11 +111,11 @@ namespace Yi.Framework.TenantManagement.Application
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("tenant/init/{id}")]
|
||||
public async Task InitAsync([FromRoute]Guid id)
|
||||
public async Task InitAsync([FromRoute] Guid id)
|
||||
{
|
||||
using (CurrentTenant.Change(id))
|
||||
{
|
||||
await CodeFirst(this.LazyServiceProvider);
|
||||
await CodeFirst(this.LazyServiceProvider);
|
||||
await _dataSeeder.SeedAsync(id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user