chore:目录重构
This commit is contained in:
15
Yi.Furion.Net6/Yi.Furion.Application/GlobalUsings.cs
Normal file
15
Yi.Furion.Net6/Yi.Furion.Application/GlobalUsings.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
global using Furion;
|
||||
global using Furion.DatabaseAccessor;
|
||||
global using Furion.DataEncryption;
|
||||
global using Furion.DataValidation;
|
||||
global using Furion.DependencyInjection;
|
||||
global using Furion.DynamicApiController;
|
||||
global using Furion.Extensions;
|
||||
global using Furion.FriendlyException;
|
||||
global using Furion.Logging;
|
||||
global using Mapster;
|
||||
global using Microsoft.AspNetCore.Authorization;
|
||||
global using Microsoft.AspNetCore.Http;
|
||||
global using Microsoft.AspNetCore.Mvc;
|
||||
global using Microsoft.CodeAnalysis;
|
||||
global using System.ComponentModel.DataAnnotations;
|
||||
@@ -0,0 +1,140 @@
|
||||
using Yi.Framework.Infrastructure.Const;
|
||||
using Yi.Framework.Infrastructure.Ddd.Repositories;
|
||||
using Yi.Framework.Infrastructure.Exceptions;
|
||||
using Yi.Framework.Infrastructure.Helper;
|
||||
using Yi.Furion.Core.Rbac.ConstClasses;
|
||||
using Yi.Furion.Core.Rbac.Dtos;
|
||||
using Yi.Furion.Core.Rbac.Entities;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Domain
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 用户领域服务
|
||||
/// </summary>
|
||||
public class AccountManager : ITransient
|
||||
{
|
||||
private readonly IRepository<UserEntity> _repository;
|
||||
public AccountManager(IRepository<UserEntity> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录效验
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="userAction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task LoginValidationAsync(string userName, string password, Action<UserEntity> userAction = null)
|
||||
{
|
||||
var user = new UserEntity();
|
||||
if (await ExistAsync(userName, o => user = o))
|
||||
{
|
||||
if (userAction is not null)
|
||||
{
|
||||
userAction.Invoke(user);
|
||||
}
|
||||
if (user.Password == MD5Helper.SHA2Encode(password, user.Salt))
|
||||
{
|
||||
return;
|
||||
}
|
||||
throw new UserFriendlyException(UserConst.登录失败_错误);
|
||||
}
|
||||
throw new UserFriendlyException(UserConst.登录失败_不存在);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断账户合法存在
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="userAction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ExistAsync(string userName, Action<UserEntity> userAction = null)
|
||||
{
|
||||
var user = await _repository.GetFirstAsync(u => u.UserName == userName && u.State == true);
|
||||
if (userAction is not null)
|
||||
{
|
||||
userAction.Invoke(user);
|
||||
}
|
||||
if (user == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 令牌转换
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public Dictionary<string, object> UserInfoToClaim(UserRoleMenuDto dto)
|
||||
{
|
||||
var claims = new Dictionary<string, object>();
|
||||
claims.Add(TokenTypeConst.Id, dto.User.Id);
|
||||
claims.Add(TokenTypeConst.UserName, dto.User.UserName);
|
||||
if (dto.User.Email is not null)
|
||||
{
|
||||
claims.Add(TokenTypeConst.Email, dto.User.Email);
|
||||
}
|
||||
if (dto.User.Phone is not null)
|
||||
{
|
||||
claims.Add(TokenTypeConst.PhoneNumber, dto.User.Phone);
|
||||
}
|
||||
if (UserConst.Admin.Equals(dto.User.UserName))
|
||||
{
|
||||
claims.Add(TokenTypeConst.Permission, UserConst.AdminPermissionCode);
|
||||
claims.Add(TokenTypeConst.Roles, UserConst.AdminRolesCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
claims.Add(TokenTypeConst.Permission, dto.PermissionCodes.Where(x => !string.IsNullOrEmpty(x)));
|
||||
claims.Add(TokenTypeConst.Roles, dto.RoleCodes.Where(x => !string.IsNullOrEmpty(x)));
|
||||
}
|
||||
|
||||
return claims;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新密码
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="newPassword"></param>
|
||||
/// <param name="oldPassword"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
public async Task UpdatePasswordAsync(long userId, string newPassword, string oldPassword)
|
||||
{
|
||||
var user = await _repository.GetByIdAsync(userId);
|
||||
|
||||
if (!user.JudgePassword(oldPassword))
|
||||
{
|
||||
throw new UserFriendlyException("无效更新!原密码错误!");
|
||||
}
|
||||
user.Password = newPassword;
|
||||
user.BuildPassword();
|
||||
await _repository.UpdateAsync(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置密码
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RestPasswordAsync(long userId, string password)
|
||||
{
|
||||
var user = await _repository.GetByIdAsync(userId);
|
||||
user.Id = userId;
|
||||
user.Password = password;
|
||||
user.BuildPassword();
|
||||
return await _repository.UpdateAsync(user);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Repositories;
|
||||
using Yi.Framework.Infrastructure.Helper;
|
||||
using Yi.Furion.Core.Rbac.Entities;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Domain
|
||||
{
|
||||
public class RoleManager : ITransient
|
||||
{
|
||||
private IRepository<RoleEntity> _repository;
|
||||
private IRepository<RoleMenuEntity> _roleMenuRepository;
|
||||
public RoleManager(IRepository<RoleEntity> repository, IRepository<RoleMenuEntity> roleMenuRepository)
|
||||
{
|
||||
_repository = repository;
|
||||
_roleMenuRepository = roleMenuRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给角色设置菜单
|
||||
/// </summary>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <param name="menuIds"></param>
|
||||
/// <returns></returns>
|
||||
public async Task GiveRoleSetMenuAsync(List<long> roleIds, List<long> menuIds)
|
||||
{
|
||||
//这个是需要事务的,在service中进行工作单元
|
||||
await _roleMenuRepository.DeleteAsync(u => roleIds.Contains(u.RoleId));
|
||||
//遍历用户
|
||||
foreach (var roleId in roleIds)
|
||||
{
|
||||
//添加新的关系
|
||||
List<RoleMenuEntity> roleMenuEntity = new();
|
||||
foreach (var menu in menuIds)
|
||||
{
|
||||
roleMenuEntity.Add(new RoleMenuEntity() { Id = SnowflakeHelper.NextId, RoleId = roleId, MenuId = menu });
|
||||
}
|
||||
//一次性批量添加
|
||||
await _roleMenuRepository.InsertRangeAsync(roleMenuEntity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Repositories;
|
||||
using Yi.Framework.Infrastructure.Helper;
|
||||
using Yi.Furion.Core.Rbac.Entities;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Domain
|
||||
{
|
||||
public class UserManager : ITransient
|
||||
{
|
||||
private readonly IRepository<UserEntity> _repository;
|
||||
private readonly IRepository<UserRoleEntity> _repositoryUserRole;
|
||||
private readonly IRepository<UserPostEntity> _repositoryUserPost;
|
||||
public UserManager(IRepository<UserEntity> repository, IRepository<UserRoleEntity> repositoryUserRole, IRepository<UserPostEntity> repositoryUserPost) =>
|
||||
(_repository, _repositoryUserRole, _repositoryUserPost) =
|
||||
(repository, repositoryUserRole, repositoryUserPost);
|
||||
|
||||
/// <summary>
|
||||
/// 给用户设置角色
|
||||
/// </summary>
|
||||
/// <param name="userIds"></param>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <returns></returns>
|
||||
public async Task GiveUserSetRoleAsync(List<long> userIds, List<long> roleIds)
|
||||
{
|
||||
//删除用户之前所有的用户角色关系(物理删除,没有恢复的必要)
|
||||
await _repositoryUserRole.DeleteAsync(u => userIds.Contains(u.UserId));
|
||||
|
||||
if (roleIds is not null)
|
||||
{
|
||||
//遍历用户
|
||||
foreach (var userId in userIds)
|
||||
{
|
||||
//添加新的关系
|
||||
List<UserRoleEntity> userRoleEntities = new();
|
||||
|
||||
foreach (var roleId in roleIds)
|
||||
{
|
||||
userRoleEntities.Add(new UserRoleEntity() { Id = SnowflakeHelper.NextId, UserId = userId, RoleId = roleId });
|
||||
}
|
||||
//一次性批量添加
|
||||
await _repositoryUserRole.InsertRangeAsync(userRoleEntities);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 给用户设置岗位
|
||||
/// </summary>
|
||||
/// <param name="userIds"></param>
|
||||
/// <param name="postIds"></param>
|
||||
/// <returns></returns>
|
||||
public async Task GiveUserSetPostAsync(List<long> userIds, List<long> postIds)
|
||||
{
|
||||
//删除用户之前所有的用户角色关系(物理删除,没有恢复的必要)
|
||||
await _repositoryUserPost.DeleteAsync(u => userIds.Contains(u.UserId));
|
||||
if (postIds is not null)
|
||||
{
|
||||
//遍历用户
|
||||
foreach (var userId in userIds)
|
||||
{
|
||||
//添加新的关系
|
||||
List<UserPostEntity> userPostEntities = new();
|
||||
foreach (var post in postIds)
|
||||
{
|
||||
userPostEntities.Add(new UserPostEntity() { Id = SnowflakeHelper.NextId, UserId = userId, PostId = post });
|
||||
}
|
||||
|
||||
//一次性批量添加
|
||||
await _repositoryUserPost.InsertRangeAsync(userPostEntities);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Account
|
||||
{
|
||||
public class CaptchaImageDto
|
||||
{
|
||||
public string Code { get; set; } = string.Empty;
|
||||
public Guid Uuid { get; set; } = Guid.Empty;
|
||||
public byte[] Img { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Account
|
||||
{
|
||||
public class LoginInputVo
|
||||
{
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
public string Uuid { get; set; }
|
||||
|
||||
public string Code { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Account
|
||||
{
|
||||
public class PhoneCaptchaImageDto
|
||||
{
|
||||
public string Phone { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Account
|
||||
{
|
||||
public class RegisterDto
|
||||
{
|
||||
|
||||
//电话号码,根据code的表示来获取
|
||||
|
||||
/// <summary>
|
||||
/// 账号
|
||||
/// </summary>
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 唯一标识码
|
||||
/// </summary>
|
||||
public string Uuid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电话
|
||||
/// </summary>
|
||||
public long Phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证码
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Account
|
||||
{
|
||||
public class RestPasswordDto
|
||||
{
|
||||
public string Password = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Account
|
||||
{
|
||||
public class UpdateIconDto
|
||||
{
|
||||
public string Icon { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Account
|
||||
{
|
||||
public class UpdatePasswordDto
|
||||
{
|
||||
public string NewPassword { get; set; } = string.Empty;
|
||||
public string OldPassword { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Dept
|
||||
{
|
||||
/// <summary>
|
||||
/// Dept输入创建对象
|
||||
/// </summary>
|
||||
public class DeptCreateInputVo
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public bool State { get; set; }
|
||||
public string DeptName { get; set; } = string.Empty;
|
||||
public string DeptCode { get; set; } = string.Empty;
|
||||
public string Leader { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Dept
|
||||
{
|
||||
public class DeptGetListInputVo : PagedAllResultRequestDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public bool? State { get; set; }
|
||||
public string DeptName { get; set; }
|
||||
public string DeptCode { get; set; }
|
||||
public string Leader { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos.Abstract;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Dept
|
||||
{
|
||||
public class DeptGetListOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public bool State { get; set; }
|
||||
public string DeptName { get; set; } = string.Empty;
|
||||
public string DeptCode { get; set; } = string.Empty;
|
||||
public string Leader { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
public string Remark { get; set; }
|
||||
|
||||
public int OrderNum { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos.Abstract;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Dept
|
||||
{
|
||||
public class DeptGetOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public bool State { get; set; }
|
||||
public string DeptName { get; set; } = string.Empty;
|
||||
public string DeptCode { get; set; } = string.Empty;
|
||||
public string Leader { get; set; }
|
||||
public string Remark { get; set; }
|
||||
|
||||
public long? deptId { get; set; }
|
||||
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
public long ParentId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Dept
|
||||
{
|
||||
public class DeptUpdateInputVo
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public bool State { get; set; }
|
||||
public string DeptName { get; set; } = string.Empty;
|
||||
public string DeptCode { get; set; } = string.Empty;
|
||||
public string Leader { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Menu
|
||||
{
|
||||
/// <summary>
|
||||
/// Menu输入创建对象
|
||||
/// </summary>
|
||||
public class MenuCreateInputVo
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public bool State { get; set; }
|
||||
public string MenuName { get; set; } = string.Empty;
|
||||
public MenuTypeEnum MenuType { get; set; } = MenuTypeEnum.Menu;
|
||||
public string PermissionCode { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
public string MenuIcon { get; set; }
|
||||
public string Router { get; set; }
|
||||
public bool IsLink { get; set; }
|
||||
public bool IsCache { get; set; }
|
||||
public bool IsShow { get; set; } = true;
|
||||
public string Remark { get; set; }
|
||||
public string Component { get; set; }
|
||||
public string Query { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Menu
|
||||
{
|
||||
public class MenuGetListInputVo : PagedAndSortedResultRequestDto
|
||||
{
|
||||
|
||||
public bool? State { get; set; }
|
||||
public string MenuName { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos.Abstract;
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Menu
|
||||
{
|
||||
public class MenuGetListOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public bool State { get; set; }
|
||||
public string MenuName { get; set; } = string.Empty;
|
||||
public MenuTypeEnum MenuType { get; set; } = MenuTypeEnum.Menu;
|
||||
public string PermissionCode { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
public string MenuIcon { get; set; }
|
||||
public string Router { get; set; }
|
||||
public bool IsLink { get; set; }
|
||||
public bool IsCache { get; set; }
|
||||
public bool IsShow { get; set; } = true;
|
||||
public string Remark { get; set; }
|
||||
public string Component { get; set; }
|
||||
public string Query { get; set; }
|
||||
|
||||
public int OrderNum { get; set; }
|
||||
//public List<MenuEntity>? Children { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos.Abstract;
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Menu
|
||||
{
|
||||
public class MenuGetOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public bool State { get; set; }
|
||||
public string MenuName { get; set; } = string.Empty;
|
||||
public MenuTypeEnum MenuType { get; set; } = MenuTypeEnum.Menu;
|
||||
public string PermissionCode { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
public string MenuIcon { get; set; }
|
||||
public string Router { get; set; }
|
||||
public bool IsLink { get; set; }
|
||||
public bool IsCache { get; set; }
|
||||
public bool IsShow { get; set; } = true;
|
||||
public string Remark { get; set; }
|
||||
public string Component { get; set; }
|
||||
public string Query { get; set; }
|
||||
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
//public List<MenuEntity>? Children { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Menu
|
||||
{
|
||||
public class MenuUpdateInputVo
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public bool State { get; set; }
|
||||
public string MenuName { get; set; } = string.Empty;
|
||||
public MenuTypeEnum MenuType { get; set; } = MenuTypeEnum.Menu;
|
||||
public string PermissionCode { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
public string MenuIcon { get; set; }
|
||||
public string Router { get; set; }
|
||||
public bool IsLink { get; set; }
|
||||
public bool IsCache { get; set; }
|
||||
public bool IsShow { get; set; } = true;
|
||||
public string Remark { get; set; }
|
||||
public string Component { get; set; }
|
||||
public string Query { get; set; }
|
||||
//public List<MenuEntity>? Children { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Post
|
||||
{
|
||||
/// <summary>
|
||||
/// Post输入创建对象
|
||||
/// </summary>
|
||||
public class PostCreateInputVo
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public bool State { get; set; }
|
||||
public string PostCode { get; set; } = string.Empty;
|
||||
public string PostName { get; set; } = string.Empty;
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Post
|
||||
{
|
||||
public class PostGetListInputVo : PagedAndSortedResultRequestDto
|
||||
{
|
||||
public bool? State { get; set; }
|
||||
//public string? PostCode { get; set; }=string.Empty;
|
||||
public string PostName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos.Abstract;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Post
|
||||
{
|
||||
public class PostGetListOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public bool State { get; set; }
|
||||
public string PostCode { get; set; } = string.Empty;
|
||||
public string PostName { get; set; } = string.Empty;
|
||||
public string Remark { get; set; }
|
||||
|
||||
public int OrderNum { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos.Abstract;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Post
|
||||
{
|
||||
public class PostGetOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public bool State { get; set; }
|
||||
public string PostCode { get; set; } = string.Empty;
|
||||
public string PostName { get; set; } = string.Empty;
|
||||
public string Remark { get; set; }
|
||||
|
||||
public int OrderNum { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Post
|
||||
{
|
||||
public class PostUpdateInputVo
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public bool State { get; set; }
|
||||
public string PostCode { get; set; } = string.Empty;
|
||||
public string PostName { get; set; } = string.Empty;
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Role
|
||||
{
|
||||
/// <summary>
|
||||
/// Role输入创建对象
|
||||
/// </summary>
|
||||
public class RoleCreateInputVo
|
||||
{
|
||||
public string RoleName { get; set; }
|
||||
public string RoleCode { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
||||
public bool State { get; set; } = true;
|
||||
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
public List<long> DeptIds { get; set; }
|
||||
|
||||
public List<long> MenuIds { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Role
|
||||
{
|
||||
public class RoleGetListInputVo : PagedAllResultRequestDto
|
||||
{
|
||||
public string RoleName { get; set; }
|
||||
public string RoleCode { get; set; }
|
||||
public bool? State { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos.Abstract;
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Role
|
||||
{
|
||||
public class RoleGetListOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public string RoleName { get; set; }
|
||||
public string RoleCode { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
||||
public bool State { get; set; }
|
||||
|
||||
public int OrderNum { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos.Abstract;
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Role
|
||||
{
|
||||
public class RoleGetOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
public string RoleName { get; set; }
|
||||
public string RoleCode { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
||||
public bool State { get; set; }
|
||||
|
||||
public int OrderNum { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.Role
|
||||
{
|
||||
public class RoleUpdateInputVo
|
||||
{
|
||||
public string RoleName { get; set; }
|
||||
public string RoleCode { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
||||
public bool State { get; set; }
|
||||
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
public List<long> DeptIds { get; set; }
|
||||
|
||||
public List<long> MenuIds { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.User
|
||||
{
|
||||
public class ProfileUpdateInputVo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int? Age { get; set; }
|
||||
public string Nick { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Address { get; set; }
|
||||
public long? Phone { get; set; }
|
||||
public string Introduction { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public SexEnum? Sex { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.User
|
||||
{
|
||||
/// <summary>
|
||||
/// User输入创建对象
|
||||
/// </summary>
|
||||
public class UserCreateInputVo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int? Age { get; set; }
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string Icon { get; set; }
|
||||
public string Nick { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Address { get; set; }
|
||||
public long? Phone { get; set; }
|
||||
public string Introduction { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public SexEnum Sex { get; set; } = SexEnum.Unknown;
|
||||
public List<long> RoleIds { get; set; }
|
||||
public List<long> PostIds { get; set; }
|
||||
public long? DeptId { get; set; }
|
||||
public bool State { get; set; } = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.User
|
||||
{
|
||||
public class UserGetListInputVo : PagedAllResultRequestDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public long? Phone { get; set; }
|
||||
|
||||
public bool? State { get; set; }
|
||||
|
||||
public long? DeptId { get; set; }
|
||||
|
||||
public string Ids { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos.Abstract;
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.User
|
||||
{
|
||||
public class UserGetListOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int? Age { get; set; }
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public string Icon { get; set; }
|
||||
public string Nick { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Ip { get; set; }
|
||||
public string Address { get; set; }
|
||||
public long? Phone { get; set; }
|
||||
public string Introduction { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public SexEnum Sex { get; set; } = SexEnum.Unknown;
|
||||
public long? DeptId { get; set; }
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
public long? CreatorId { get; set; }
|
||||
|
||||
public bool State { get; set; }
|
||||
|
||||
|
||||
public string DeptName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos.Abstract;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Dept;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Post;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Role;
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.User
|
||||
{
|
||||
public class UserGetOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int? Age { get; set; }
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public string Icon { get; set; }
|
||||
public string Nick { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Ip { get; set; }
|
||||
public string Address { get; set; }
|
||||
public long? Phone { get; set; }
|
||||
public string Introduction { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public SexEnum Sex { get; set; } = SexEnum.Unknown;
|
||||
public bool State { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public long DeptId { get; set; }
|
||||
|
||||
public DeptGetOutputDto Dept { get; set; }
|
||||
|
||||
public List<PostGetListOutputDto> Posts { get; set; }
|
||||
|
||||
public List<RoleGetListOutputDto> Roles { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Yi.Furion.Core.Rbac.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Dtos.User
|
||||
{
|
||||
public class UserUpdateInputVo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int? Age { get; set; }
|
||||
public string UserName { get; set; }
|
||||
|
||||
[AdaptIgnore]
|
||||
public string Password { get; set; }
|
||||
public string Icon { get; set; }
|
||||
public string Nick { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Ip { get; set; }
|
||||
public string Address { get; set; }
|
||||
public long? Phone { get; set; }
|
||||
public string Introduction { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public SexEnum? Sex { get; set; }
|
||||
public long? DeptId { get; set; }
|
||||
public List<long> PostIds { get; set; }
|
||||
|
||||
public List<long> RoleIds { get; set; }
|
||||
public bool? State { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using Furion.EventBus;
|
||||
using IPTools.Core;
|
||||
using UAParser;
|
||||
using Yi.Framework.Infrastructure.AspNetCore;
|
||||
using Yi.Framework.Infrastructure.Ddd.Repositories;
|
||||
using Yi.Framework.Infrastructure.Helper;
|
||||
using Yi.Furion.Core.Rbac.Entities;
|
||||
using Yi.Furion.Core.Rbac.Etos;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Event
|
||||
{
|
||||
public class LoginEventHandler : IEventSubscriber, ISingleton
|
||||
{
|
||||
private readonly IRepository<LoginLogEntity> _loginLogRepository;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private HttpContext _httpContext => _httpContextAccessor.HttpContext;
|
||||
public LoginEventHandler(IRepository<LoginLogEntity> loginLogRepository, IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_loginLogRepository = loginLogRepository;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
//[EventSubscribe(nameof(LoginEventSource))]
|
||||
public Task HandlerAsync(EventHandlerExecutingContext context)
|
||||
{
|
||||
var eventData = (LoginEventArgs)context.Source.Payload;
|
||||
var loginLogEntity = GetLoginLogInfo(_httpContext);
|
||||
loginLogEntity.Id = SnowflakeHelper.NextId;
|
||||
loginLogEntity.LogMsg = eventData.UserName + "登录系统";
|
||||
loginLogEntity.LoginUser = eventData.UserName;
|
||||
loginLogEntity.LoginIp = _httpContext.GetClientIp();
|
||||
|
||||
_loginLogRepository.InsertAsync(loginLogEntity);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取客户端信息
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
private static ClientInfo GetClientInfo(HttpContext context)
|
||||
{
|
||||
var str = context.GetUserAgent();
|
||||
var uaParser = Parser.GetDefault();
|
||||
ClientInfo c = uaParser.Parse(str);
|
||||
return c;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录用户登陆信息
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
private static LoginLogEntity GetLoginLogInfo(HttpContext context)
|
||||
{
|
||||
var ipAddr = context.GetClientIp();
|
||||
IpInfo location;
|
||||
if (ipAddr == "127.0.0.1")
|
||||
{
|
||||
location = new IpInfo() { Province = "本地", City = "本机" };
|
||||
}
|
||||
else
|
||||
{
|
||||
location = IpTool.Search(ipAddr);
|
||||
}
|
||||
ClientInfo clientInfo = GetClientInfo(context);
|
||||
LoginLogEntity entity = new()
|
||||
{
|
||||
Browser = clientInfo.Device.Family,
|
||||
Os = clientInfo.OS.ToString(),
|
||||
LoginIp = ipAddr,
|
||||
LoginLocation = location.Province + "-" + location.City
|
||||
};
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Services.Abstract;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Dept;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Dept服务抽象
|
||||
/// </summary>
|
||||
public interface IDeptService : ICrudAppService<DeptGetOutputDto, DeptGetListOutputDto, long, DeptGetListInputVo, DeptCreateInputVo, DeptUpdateInputVo>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Services.Abstract;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Menu;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Menu服务抽象
|
||||
/// </summary>
|
||||
public interface IMenuService : ICrudAppService<MenuGetOutputDto, MenuGetListOutputDto, long, MenuGetListInputVo, MenuCreateInputVo, MenuUpdateInputVo>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Services.Abstract;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Post;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Post服务抽象
|
||||
/// </summary>
|
||||
public interface IPostService : ICrudAppService<PostGetOutputDto, PostGetListOutputDto, long, PostGetListInputVo, PostCreateInputVo, PostUpdateInputVo>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Services.Abstract;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Role;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Role服务抽象
|
||||
/// </summary>
|
||||
public interface IRoleService : ICrudAppService<RoleGetOutputDto, RoleGetListOutputDto, long, RoleGetListInputVo, RoleCreateInputVo, RoleUpdateInputVo>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Yi.Framework.Infrastructure.Ddd.Services.Abstract;
|
||||
using Yi.Furion.Application.Rbac.Dtos.User;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// User服务抽象
|
||||
/// </summary>
|
||||
public interface IUserService : ICrudAppService<UserGetOutputDto, UserGetListOutputDto, long, UserGetListInputVo, UserCreateInputVo, UserUpdateInputVo>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Furion.EventBus;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.CurrentUsers;
|
||||
using Yi.Framework.Infrastructure.Ddd.Repositories;
|
||||
using Yi.Framework.Infrastructure.Ddd.Services;
|
||||
using Yi.Framework.Infrastructure.Exceptions;
|
||||
using Yi.Framework.Module.ImageSharp.HeiCaptcha;
|
||||
using Yi.Framework.Module.Sms.Aliyun;
|
||||
using Yi.Furion.Application.Rbac.Domain;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Account;
|
||||
using Yi.Furion.Core.Rbac.ConstClasses;
|
||||
using Yi.Furion.Core.Rbac.Dtos;
|
||||
using Yi.Furion.Core.Rbac.Entities;
|
||||
using Yi.Furion.Core.Rbac.Etos;
|
||||
using Yi.Furion.Sqlsugar.Core.Repositories;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
{
|
||||
public class AccountService : ApplicationService, ITransient, IDynamicApiController
|
||||
{
|
||||
|
||||
public AccountService(IUserRepository userRepository, ICurrentUser currentUser, AccountManager accountManager, IRepository<MenuEntity> menuRepository, SmsAliyunManager smsAliyunManager, IOptions<SmsAliyunOptions> smsAliyunManagerOptions, SecurityCodeHelper securityCode, IMemoryCache memoryCache, IEventPublisher eventPublisher) =>
|
||||
(_userRepository, _currentUser, _accountManager, _menuRepository, _smsAliyunManager, _smsAliyunManagerOptions, _securityCode, _memoryCache, _eventPublisher) =
|
||||
(userRepository, currentUser, accountManager, menuRepository, smsAliyunManager, smsAliyunManagerOptions, securityCode, memoryCache, eventPublisher);
|
||||
|
||||
|
||||
private IUserRepository _userRepository { get; set; }
|
||||
|
||||
private ICurrentUser _currentUser { get; set; }
|
||||
|
||||
private AccountManager _accountManager { get; set; }
|
||||
|
||||
|
||||
private IRepository<MenuEntity> _menuRepository { get; set; }
|
||||
|
||||
|
||||
private SecurityCodeHelper _securityCode { get; set; }
|
||||
|
||||
|
||||
private IEventPublisher _eventPublisher { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
private IUserService _userService { get; set; }
|
||||
|
||||
|
||||
|
||||
private UserManager _userManager { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
private IRepository<RoleEntity> _roleRepository { get; set; }
|
||||
|
||||
|
||||
private IMemoryCache _memoryCache { get; set; }
|
||||
|
||||
|
||||
private SmsAliyunManager _smsAliyunManager { get; set; }
|
||||
|
||||
|
||||
private IOptions<SmsAliyunOptions> _smsAliyunManagerOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 效验图片登录验证码,无需和账号绑定
|
||||
/// </summary>
|
||||
private void ValidationImageCaptcha(LoginInputVo input)
|
||||
{
|
||||
//登录不想要验证码 ,不效验
|
||||
return;
|
||||
var value = _memoryCache.Get<string>($"Yi:Captcha:{input.Code}");
|
||||
if (value is not null && value.Equals(input.Uuid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
throw new UserFriendlyException("验证码错误");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 效验电话验证码,需要与电话号码绑定
|
||||
/// </summary>
|
||||
private void ValidationPhoneCaptcha(RegisterDto input)
|
||||
{
|
||||
var value = _memoryCache.Get<string>($"Yi:Phone:{input.Phone}");
|
||||
if (value is not null && value.Equals($"{input.Code}"))
|
||||
{
|
||||
//成功,需要清空
|
||||
_memoryCache.Remove($"Yi:Phone:{input.Phone}");
|
||||
return;
|
||||
}
|
||||
throw new UserFriendlyException("验证码错误");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<object> PostLoginAsync(LoginInputVo input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.Password) || string.IsNullOrEmpty(input.UserName))
|
||||
{
|
||||
throw new UserFriendlyException("请输入合理数据!");
|
||||
}
|
||||
|
||||
//效验验证码
|
||||
ValidationImageCaptcha(input);
|
||||
|
||||
UserEntity user = new();
|
||||
//登录成功
|
||||
await _accountManager.LoginValidationAsync(input.UserName, input.Password, x => user = x);
|
||||
|
||||
//获取用户信息
|
||||
var userInfo = await _userRepository.GetUserAllInfoAsync(user.Id);
|
||||
|
||||
if (userInfo.RoleCodes.Count == 0)
|
||||
{
|
||||
throw new UserFriendlyException(UserConst.用户无角色分配);
|
||||
}
|
||||
//这里抛出一个登录的事件
|
||||
|
||||
//不阻碍执行,无需等待
|
||||
#pragma warning disable CS4014 // 由于此调用不会等待,因此在调用完成前将继续执行当前方法
|
||||
|
||||
_eventPublisher.PublishAsync(new LoginEventSource(new LoginEventArgs
|
||||
{
|
||||
|
||||
UserId = userInfo.User.Id,
|
||||
UserName = user.UserName
|
||||
|
||||
})
|
||||
);
|
||||
#pragma warning restore CS4014 // 由于此调用不会等待,因此在调用完成前将继续执行当前方法
|
||||
|
||||
//创建token
|
||||
var accessToken = JWTEncryption.Encrypt(_accountManager.UserInfoToClaim(userInfo));
|
||||
return new { Token = accessToken };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成验证码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
[AllowAnonymous]
|
||||
public CaptchaImageDto GetCaptchaImage()
|
||||
{
|
||||
var uuid = Guid.NewGuid();
|
||||
var code = _securityCode.GetRandomEnDigitalText(4);
|
||||
//将uuid与code,Redis缓存中心化保存起来,登录根据uuid比对即可
|
||||
//10分钟过期
|
||||
_memoryCache.Set($"Yi:Captcha:{code}", uuid, new TimeSpan(0, 10, 0));
|
||||
var imgbyte = _securityCode.GetEnDigitalCodeByte(code);
|
||||
return new CaptchaImageDto { Img = imgbyte, Code = code, Uuid = uuid };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证电话号码
|
||||
/// </summary>
|
||||
/// <param name="str_handset"></param>
|
||||
private async Task ValidationPhone(string str_handset)
|
||||
{
|
||||
var res = Regex.IsMatch(str_handset, "^(0\\d{2,3}-?\\d{7,8}(-\\d{3,5}){0,1})|(((13[0-9])|(15([0-3]|[5-9]))|(18[0-9])|(17[0-9])|(14[0-9]))\\d{8})$");
|
||||
if (res == false)
|
||||
{
|
||||
throw new UserFriendlyException("手机号码格式错误!请检查");
|
||||
}
|
||||
if (await _userRepository.IsAnyAsync(x => x.Phone.ToString() == str_handset))
|
||||
{
|
||||
throw new UserFriendlyException("该手机号已被注册!");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 注册 手机验证码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
public async Task<object> PostCaptchaPhone(PhoneCaptchaImageDto input)
|
||||
{
|
||||
await ValidationPhone(input.Phone);
|
||||
var value = _memoryCache.Get<string>($"Yi:Phone:{input.Phone}");
|
||||
|
||||
//防止暴刷
|
||||
if (value is not null)
|
||||
{
|
||||
throw new UserFriendlyException($"{input.Phone}已发送过验证码,10分钟后可重试");
|
||||
}
|
||||
//生成一个4位数的验证码
|
||||
//发送短信,同时生成uuid
|
||||
//key: 电话号码 value:验证码+uuid
|
||||
var code = _securityCode.GetRandomEnDigitalText(4);
|
||||
var uuid = Guid.NewGuid();
|
||||
|
||||
//未开启短信验证,默认8888
|
||||
if (_smsAliyunManagerOptions.Value.EnableFeature)
|
||||
{
|
||||
await _smsAliyunManager.Send(input.Phone, code);
|
||||
}
|
||||
else
|
||||
{
|
||||
code = "8888";
|
||||
}
|
||||
_memoryCache.Set($"Yi:Phone:{input.Phone}", $"{code}", new TimeSpan(0, 10, 0));
|
||||
|
||||
|
||||
return new { Uuid = uuid };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册,需要验证码通过
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[UnitOfWork]
|
||||
public async Task<object> PostRegisterAsync(RegisterDto input)
|
||||
{
|
||||
if (input.UserName == UserConst.Admin)
|
||||
{
|
||||
throw new UserFriendlyException("用户名无效注册!");
|
||||
}
|
||||
|
||||
if (input.UserName.Length < 2)
|
||||
{
|
||||
throw new UserFriendlyException("账号名需大于等于2位!");
|
||||
}
|
||||
if (input.Password.Length < 6)
|
||||
{
|
||||
throw new UserFriendlyException("密码需大于等于6位!");
|
||||
}
|
||||
//效验验证码,根据电话号码获取 value,比对验证码已经uuid
|
||||
ValidationPhoneCaptcha(input);
|
||||
|
||||
|
||||
|
||||
//输入的用户名与电话号码都不能在数据库中存在
|
||||
UserEntity user = new();
|
||||
var isExist = await _userRepository.IsAnyAsync(x =>
|
||||
x.UserName == input.UserName
|
||||
|| x.Phone == input.Phone);
|
||||
if (isExist)
|
||||
{
|
||||
throw new UserFriendlyException("用户已存在,注册失败");
|
||||
}
|
||||
|
||||
var newUser = new UserEntity(input.UserName, input.Password, input.Phone);
|
||||
|
||||
var entity = await _userRepository.InsertReturnEntityAsync(newUser);
|
||||
//赋上一个初始角色
|
||||
var roleRepository = _roleRepository;
|
||||
var role = await roleRepository.GetFirstAsync(x => x.RoleCode == UserConst.GuestRoleCode);
|
||||
if (role is not null)
|
||||
{
|
||||
await _userManager.GiveUserSetRoleAsync(new List<long> { entity.Id }, new List<long> { role.Id });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询已登录的账户信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AuthException"></exception>
|
||||
[Route("/api/account")]
|
||||
[Authorize]
|
||||
public async Task<UserRoleMenuDto> Get()
|
||||
{
|
||||
//通过鉴权jwt获取到用户的id
|
||||
var userId = _currentUser.Id;
|
||||
//此处从缓存中获取即可
|
||||
//var data = _cacheManager.Get<UserRoleMenuDto>($"Yi:UserInfo:{userId}");
|
||||
var data = await _userRepository.GetUserAllInfoAsync(userId);
|
||||
//系统用户数据被重置,老前端访问重新授权
|
||||
if (data is null)
|
||||
{
|
||||
throw new AuthException();
|
||||
}
|
||||
|
||||
data.Menus.Clear();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前登录用户的前端路由
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
public async Task<List<Vue3RouterDto>> GetVue3Router()
|
||||
{
|
||||
var userId = _currentUser.Id;
|
||||
var data = await _userRepository.GetUserAllInfoAsync(userId);
|
||||
var menus = data.Menus.ToList();
|
||||
|
||||
//为超级管理员直接给全部路由
|
||||
if (UserConst.Admin.Equals(data.User.UserName))
|
||||
{
|
||||
menus = await _menuRepository.GetListAsync();
|
||||
}
|
||||
//将后端菜单转换成前端路由,组件级别需要过滤
|
||||
List<Vue3RouterDto> routers = menus.Vue3RouterBuild();
|
||||
return routers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 退出登录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> PostLogout()
|
||||
{
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新密码
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> UpdatePasswordAsync(UpdatePasswordDto input)
|
||||
{
|
||||
if (input.OldPassword.Equals(input.NewPassword))
|
||||
{
|
||||
throw new UserFriendlyException("无效更新!输入的数据,新密码不能与老密码相同");
|
||||
}
|
||||
await _accountManager.UpdatePasswordAsync(_currentUser.Id, input.NewPassword, input.OldPassword);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置密码
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<bool> RestPasswordAsync(long userId, RestPasswordDto input)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(input.Password))
|
||||
{
|
||||
throw new UserFriendlyException("重置密码不能为空!");
|
||||
}
|
||||
await _accountManager.RestPasswordAsync(userId, input.Password);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新头像
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> UpdateIconAsync(UpdateIconDto input)
|
||||
{
|
||||
var entity = await _userRepository.GetByIdAsync(_currentUser.Id);
|
||||
entity.Icon = input.Icon;
|
||||
await _userRepository.UpdateAsync(entity);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos;
|
||||
using Yi.Framework.Infrastructure.Ddd.Services;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Dept;
|
||||
using Yi.Furion.Core.Rbac.Entities;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
{
|
||||
/// <summary>
|
||||
/// Dept服务实现
|
||||
/// </summary>
|
||||
public class DeptService : CrudAppService<DeptEntity, DeptGetOutputDto, DeptGetListOutputDto, long, DeptGetListInputVo, DeptCreateInputVo, DeptUpdateInputVo>,
|
||||
IDeptService, ITransient, IDynamicApiController
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 通过角色id查询该角色全部部门
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//[Route("{roleId}")]
|
||||
public async Task<List<DeptGetListOutputDto>> GetListRoleIdAsync([FromRoute] long roleId)
|
||||
{
|
||||
var entities = await _DbQueryable.Where(d => SqlFunc.Subqueryable<RoleDeptEntity>().Where(rd => rd.RoleId == roleId && d.Id == rd.DeptId).Any()).ToListAsync();
|
||||
return await MapToGetListOutputDtosAsync(entities);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 多查
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<PagedResultDto<DeptGetListOutputDto>> GetListAsync(DeptGetListInputVo input)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
var entities = await _DbQueryable
|
||||
.WhereIF(!string.IsNullOrEmpty(input.DeptName), u => u.DeptName.Contains(input.DeptName!))
|
||||
.WhereIF(input.State is not null, u => u.State == input.State)
|
||||
.OrderBy(u => u.OrderNum, OrderByType.Asc)
|
||||
.ToPageListAsync(input.PageNum, input.PageSize, total);
|
||||
return new PagedResultDto<DeptGetListOutputDto>
|
||||
{
|
||||
Items = await MapToGetListOutputDtosAsync(entities),
|
||||
Total = total
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos;
|
||||
using Yi.Framework.Infrastructure.Ddd.Services;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Menu;
|
||||
using Yi.Furion.Application.Rbac.Services;
|
||||
using Yi.Furion.Core.Rbac.Entities;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
{
|
||||
/// <summary>
|
||||
/// Menu服务实现
|
||||
/// </summary>
|
||||
public class MenuService : CrudAppService<MenuEntity, MenuGetOutputDto, MenuGetListOutputDto, long, MenuGetListInputVo, MenuCreateInputVo, MenuUpdateInputVo>,
|
||||
IMenuService, ITransient, IDynamicApiController
|
||||
{
|
||||
|
||||
public override async Task<PagedResultDto<MenuGetListOutputDto>> GetListAsync(MenuGetListInputVo input)
|
||||
{
|
||||
var entity = await MapToEntityAsync(input);
|
||||
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
var entities = await _DbQueryable.WhereIF(!string.IsNullOrEmpty(input.MenuName), x => x.MenuName.Contains(input.MenuName!))
|
||||
.WhereIF(input.State is not null, x => x.State == input.State)
|
||||
.OrderByDescending(x => x.OrderNum)
|
||||
.ToPageListAsync(input.PageNum, input.PageSize, total);
|
||||
return new PagedResultDto<MenuGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询当前角色的菜单
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<MenuGetListOutputDto>> GetListRoleIdAsync(long roleId)
|
||||
{
|
||||
var entities = await _DbQueryable.Where(m => SqlFunc.Subqueryable<RoleMenuEntity>().Where(rm => rm.RoleId == roleId && rm.MenuId == m.Id).Any()).ToListAsync();
|
||||
|
||||
return await MapToGetListOutputDtosAsync(entities);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos;
|
||||
using Yi.Framework.Infrastructure.Ddd.Services;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Post;
|
||||
using Yi.Furion.Core.Rbac.Entities;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
{
|
||||
/// <summary>
|
||||
/// Post服务实现
|
||||
/// </summary>
|
||||
public class PostService : CrudAppService<PostEntity, PostGetOutputDto, PostGetListOutputDto, long, PostGetListInputVo, PostCreateInputVo, PostUpdateInputVo>,
|
||||
IPostService, ITransient, IDynamicApiController
|
||||
{
|
||||
public override async Task<PagedResultDto<PostGetListOutputDto>> GetListAsync(PostGetListInputVo input)
|
||||
{
|
||||
var entity = await MapToEntityAsync(input);
|
||||
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
var entities = await _DbQueryable.WhereIF(!string.IsNullOrEmpty(input.PostName), x => x.PostName.Contains(input.PostName!))
|
||||
.WhereIF(input.State is not null, x => x.State == input.State)
|
||||
.ToPageListAsync(input.PageNum, input.PageSize, total);
|
||||
return new PagedResultDto<PostGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos;
|
||||
using Yi.Framework.Infrastructure.Ddd.Services;
|
||||
using Yi.Furion.Application.Rbac.Domain;
|
||||
using Yi.Furion.Application.Rbac.Dtos.Role;
|
||||
using Yi.Furion.Core.Rbac.Entities;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
{
|
||||
/// <summary>
|
||||
/// Role服务实现
|
||||
/// </summary>
|
||||
public class RoleService : CrudAppService<RoleEntity, RoleGetOutputDto, RoleGetListOutputDto, long, RoleGetListInputVo, RoleCreateInputVo, RoleUpdateInputVo>,
|
||||
IRoleService, ITransient, IDynamicApiController
|
||||
{
|
||||
public RoleService(RoleManager roleManager) =>
|
||||
_roleManager =
|
||||
roleManager;
|
||||
private RoleManager _roleManager { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public override async Task<PagedResultDto<RoleGetListOutputDto>> GetListAsync(RoleGetListInputVo input)
|
||||
{
|
||||
var entity = await MapToEntityAsync(input);
|
||||
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
var entities = await _DbQueryable.WhereIF(!string.IsNullOrEmpty(input.RoleCode), x => x.RoleCode.Contains(input.RoleCode!))
|
||||
.WhereIF(!string.IsNullOrEmpty(input.RoleName), x => x.RoleName.Contains(input.RoleName!))
|
||||
.WhereIF(input.State is not null, x => x.State == input.State)
|
||||
.ToPageListAsync(input.PageNum, input.PageSize, total);
|
||||
return new PagedResultDto<RoleGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加角色
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[UnitOfWork]
|
||||
public override async Task<RoleGetOutputDto> CreateAsync(RoleCreateInputVo input)
|
||||
{
|
||||
RoleGetOutputDto outputDto;
|
||||
//using (var uow = _unitOfWorkManager.CreateContext())
|
||||
//{
|
||||
var entity = await MapToEntityAsync(input);
|
||||
await _repository.InsertAsync(entity);
|
||||
outputDto = await MapToGetOutputDtoAsync(entity);
|
||||
await _roleManager.GiveRoleSetMenuAsync(new List<long> { entity.Id }, input.MenuIds);
|
||||
// uow.Commit();
|
||||
//}
|
||||
|
||||
return outputDto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改角色
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[UnitOfWork]
|
||||
public override async Task<RoleGetOutputDto> UpdateAsync(long id, RoleUpdateInputVo input)
|
||||
{
|
||||
var dto = new RoleGetOutputDto();
|
||||
//using (var uow = _unitOfWorkManager.CreateContext())
|
||||
//{
|
||||
var entity = await _repository.GetByIdAsync(id);
|
||||
await MapToEntityAsync(input, entity);
|
||||
await _repository.UpdateAsync(entity);
|
||||
|
||||
await _roleManager.GiveRoleSetMenuAsync(new List<long> { id }, input.MenuIds);
|
||||
|
||||
dto = await MapToGetOutputDtoAsync(entity);
|
||||
// uow.Commit();
|
||||
//}
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新状态
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
[Route("/api/role/{id}/{state}")]
|
||||
public async Task<RoleGetOutputDto> UpdateStateAsync([FromRoute] long id, [FromRoute] bool state)
|
||||
{
|
||||
var entity = await _repository.GetByIdAsync(id);
|
||||
if (entity is null)
|
||||
{
|
||||
throw new ApplicationException("角色未存在");
|
||||
}
|
||||
|
||||
entity.State = state;
|
||||
await _repository.UpdateAsync(entity);
|
||||
return await MapToGetOutputDtoAsync(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.CurrentUsers;
|
||||
using Yi.Framework.Infrastructure.Ddd.Dtos;
|
||||
using Yi.Framework.Infrastructure.Ddd.Services;
|
||||
using Yi.Framework.Infrastructure.Exceptions;
|
||||
using Yi.Framework.Module.OperLogManager;
|
||||
using Yi.Furion.Application.Rbac.Domain;
|
||||
using Yi.Furion.Application.Rbac.Dtos.User;
|
||||
using Yi.Furion.Core.Rbac.ConstClasses;
|
||||
using Yi.Furion.Core.Rbac.Entities;
|
||||
using Yi.Furion.Sqlsugar.Core.Repositories;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
{
|
||||
/// <summary>
|
||||
/// User服务实现
|
||||
/// </summary>
|
||||
public class UserService : CrudAppService<UserEntity, UserGetOutputDto, UserGetListOutputDto, long, UserGetListInputVo, UserCreateInputVo, UserUpdateInputVo>,
|
||||
IUserService, ITransient, IDynamicApiController
|
||||
{
|
||||
|
||||
|
||||
public UserService(UserManager userManager, IUserRepository userRepository, ICurrentUser currentUser) =>
|
||||
(_userManager, _userRepository, _currentUser) =
|
||||
(userManager, userRepository, currentUser);
|
||||
private UserManager _userManager { get; set; }
|
||||
|
||||
private IUserRepository _userRepository { get; set; }
|
||||
|
||||
|
||||
private ICurrentUser _currentUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 查询用户
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<PagedResultDto<UserGetListOutputDto>> GetListAsync(UserGetListInputVo input)
|
||||
{
|
||||
var entity = await MapToEntityAsync(input);
|
||||
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
|
||||
List<long> ids = input.Ids?.Split(",").Select(x => long.Parse(x)).ToList();
|
||||
var outPut = await _DbQueryable.WhereIF(!string.IsNullOrEmpty(input.UserName), x => x.UserName.Contains(input.UserName!))
|
||||
.WhereIF(input.Phone is not null, x => x.Phone.ToString()!.Contains(input.Phone.ToString()!))
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name!.Contains(input.Name!))
|
||||
.WhereIF(input.State is not null, x => x.State == input.State)
|
||||
.WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
|
||||
|
||||
//这个为过滤当前部门,加入数据权限后,将由数据权限控制
|
||||
.WhereIF(input.DeptId is not null, x => x.DeptId == input.DeptId)
|
||||
|
||||
.WhereIF(ids is not null, x => ids.Contains(x.Id))
|
||||
|
||||
|
||||
.LeftJoin<DeptEntity>((user, dept) => user.DeptId == dept.Id)
|
||||
.Select((user, dept) => new UserGetListOutputDto(), true)
|
||||
.ToPageListAsync(input.PageNum, input.PageSize, total);
|
||||
|
||||
var result = new PagedResultDto<UserGetListOutputDto>();
|
||||
result.Items = outPut;
|
||||
result.Total = total;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加用户
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
[OperLog("添加用户", OperEnum.Insert)]
|
||||
[UnitOfWork]
|
||||
public async override Task<UserGetOutputDto> CreateAsync(UserCreateInputVo input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.Password))
|
||||
{
|
||||
throw new UserFriendlyException(UserConst.添加失败_密码为空);
|
||||
}
|
||||
if (await _repository.IsAnyAsync(u => input.UserName.Equals(u.UserName)))
|
||||
{
|
||||
throw new UserFriendlyException(UserConst.添加失败_用户存在);
|
||||
}
|
||||
var entities = await MapToEntityAsync(input);
|
||||
|
||||
entities.BuildPassword();
|
||||
|
||||
//using (var uow = _unitOfWorkManager.CreateContext())
|
||||
//{
|
||||
var returnEntity = await _repository.InsertReturnEntityAsync(entities);
|
||||
await _userManager.GiveUserSetRoleAsync(new List<long> { returnEntity.Id }, input.RoleIds);
|
||||
await _userManager.GiveUserSetPostAsync(new List<long> { returnEntity.Id }, input.PostIds);
|
||||
//uow.Commit();
|
||||
|
||||
var result = await MapToGetOutputDtoAsync(returnEntity);
|
||||
return result;
|
||||
//}
|
||||
}
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<UserGetOutputDto> GetAsync(long id)
|
||||
{
|
||||
//使用导航树形查询
|
||||
var entity = await _DbQueryable.Includes(u => u.Roles).Includes(u => u.Posts).Includes(u => u.Dept).InSingleAsync(id);
|
||||
|
||||
return await MapToGetOutputDtoAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新用户
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[OperLog("更新用户", OperEnum.Update)]
|
||||
[UnitOfWork]
|
||||
public async override Task<UserGetOutputDto> UpdateAsync(long id, UserUpdateInputVo input)
|
||||
{
|
||||
if (await _repository.IsAnyAsync(u => input.UserName!.Equals(u.UserName) && !id.Equals(u.Id)))
|
||||
{
|
||||
throw new UserFriendlyException("用户已经在,更新失败");
|
||||
}
|
||||
var entity = await _repository.GetByIdAsync(id);
|
||||
//更新密码,特殊处理
|
||||
if (input.Password is not null)
|
||||
{
|
||||
entity.Password = input.Password;
|
||||
entity.BuildPassword();
|
||||
}
|
||||
await MapToEntityAsync(input, entity);
|
||||
//using (var uow = _unitOfWorkManager.CreateContext())
|
||||
//{
|
||||
var res1 = await _repository.UpdateAsync(entity);
|
||||
await _userManager.GiveUserSetRoleAsync(new List<long> { id }, input.RoleIds);
|
||||
await _userManager.GiveUserSetPostAsync(new List<long> { id }, input.PostIds);
|
||||
// uow.Commit();
|
||||
//}
|
||||
return await MapToGetOutputDtoAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新个人中心
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[OperLog("更新个人信息", OperEnum.Update)]
|
||||
public async Task<UserGetOutputDto> UpdateProfileAsync(ProfileUpdateInputVo input)
|
||||
{
|
||||
var entity = await _repository.GetByIdAsync(_currentUser.Id);
|
||||
_mapper.Map(input, entity);
|
||||
await _repository.UpdateAsync(entity);
|
||||
var dto = _mapper.Map<UserGetOutputDto>(entity);
|
||||
return dto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新状态
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
[Route("/api/user/{id}/{state}")]
|
||||
[OperLog("更新用户状态", OperEnum.Update)]
|
||||
public async Task<UserGetOutputDto> UpdateStateAsync([FromRoute] long id, [FromRoute] bool state)
|
||||
{
|
||||
var entity = await _repository.GetByIdAsync(id);
|
||||
if (entity is null)
|
||||
{
|
||||
throw new ApplicationException("用户未存在");
|
||||
}
|
||||
|
||||
entity.State = state;
|
||||
await _repository.UpdateAsync(entity);
|
||||
return await MapToGetOutputDtoAsync(entity);
|
||||
}
|
||||
[OperLog("删除用户", OperEnum.Delete)]
|
||||
public override Task<bool> DeleteAsync(string id)
|
||||
{
|
||||
return base.DeleteAsync(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<NoWarn>1701;1702;1591</NoWarn>
|
||||
<DocumentationFile>Yi.Furion.Application.xml</DocumentationFile>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="applicationsettings.json" />
|
||||
<None Remove="Yi.Furion.Application.xml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="applicationsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Infrastructure\Yi.Framework.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Module\Yi.Framework.Module.csproj" />
|
||||
<ProjectReference Include="..\Yi.Furion.Sqlsugar.Core\Yi.Furion.Sqlsugar.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Bbs\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
364
Yi.Furion.Net6/Yi.Furion.Application/Yi.Furion.Application.xml
Normal file
364
Yi.Furion.Net6/Yi.Furion.Application/Yi.Furion.Application.xml
Normal file
@@ -0,0 +1,364 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Furion.Application</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Domain.AccountManager">
|
||||
<summary>
|
||||
用户领域服务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Domain.AccountManager.LoginValidationAsync(System.String,System.String,System.Action{Yi.Furion.Core.Rbac.Entities.UserEntity})">
|
||||
<summary>
|
||||
登录效验
|
||||
</summary>
|
||||
<param name="userName"></param>
|
||||
<param name="password"></param>
|
||||
<param name="userAction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Domain.AccountManager.ExistAsync(System.String,System.Action{Yi.Furion.Core.Rbac.Entities.UserEntity})">
|
||||
<summary>
|
||||
判断账户合法存在
|
||||
</summary>
|
||||
<param name="userName"></param>
|
||||
<param name="userAction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Domain.AccountManager.UserInfoToClaim(Yi.Furion.Core.Rbac.Dtos.UserRoleMenuDto)">
|
||||
<summary>
|
||||
令牌转换
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Domain.AccountManager.UpdatePasswordAsync(System.Int64,System.String,System.String)">
|
||||
<summary>
|
||||
更新密码
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<param name="newPassword"></param>
|
||||
<param name="oldPassword"></param>
|
||||
<returns></returns>
|
||||
<exception cref="T:Yi.Framework.Infrastructure.Exceptions.UserFriendlyException"></exception>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Domain.AccountManager.RestPasswordAsync(System.Int64,System.String)">
|
||||
<summary>
|
||||
重置密码
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<param name="password"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Domain.RoleManager.GiveRoleSetMenuAsync(System.Collections.Generic.List{System.Int64},System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
给角色设置菜单
|
||||
</summary>
|
||||
<param name="roleIds"></param>
|
||||
<param name="menuIds"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Domain.UserManager.GiveUserSetRoleAsync(System.Collections.Generic.List{System.Int64},System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
给用户设置角色
|
||||
</summary>
|
||||
<param name="userIds"></param>
|
||||
<param name="roleIds"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Domain.UserManager.GiveUserSetPostAsync(System.Collections.Generic.List{System.Int64},System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
给用户设置岗位
|
||||
</summary>
|
||||
<param name="userIds"></param>
|
||||
<param name="postIds"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:Yi.Furion.Application.Rbac.Dtos.Account.RegisterDto.UserName">
|
||||
<summary>
|
||||
账号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Furion.Application.Rbac.Dtos.Account.RegisterDto.Password">
|
||||
<summary>
|
||||
密码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Furion.Application.Rbac.Dtos.Account.RegisterDto.Uuid">
|
||||
<summary>
|
||||
唯一标识码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Furion.Application.Rbac.Dtos.Account.RegisterDto.Phone">
|
||||
<summary>
|
||||
电话
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Furion.Application.Rbac.Dtos.Account.RegisterDto.Code">
|
||||
<summary>
|
||||
验证码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Dtos.Dept.DeptCreateInputVo">
|
||||
<summary>
|
||||
Dept输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Dtos.Menu.MenuCreateInputVo">
|
||||
<summary>
|
||||
Menu输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Dtos.Post.PostCreateInputVo">
|
||||
<summary>
|
||||
Post输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Dtos.Role.RoleCreateInputVo">
|
||||
<summary>
|
||||
Role输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Dtos.User.UserCreateInputVo">
|
||||
<summary>
|
||||
User输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Event.LoginEventHandler.GetClientInfo(Microsoft.AspNetCore.Http.HttpContext)">
|
||||
<summary>
|
||||
获取客户端信息
|
||||
</summary>
|
||||
<param name="context"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Event.LoginEventHandler.GetLoginLogInfo(Microsoft.AspNetCore.Http.HttpContext)">
|
||||
<summary>
|
||||
记录用户登陆信息
|
||||
</summary>
|
||||
<param name="context"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Services.IDeptService">
|
||||
<summary>
|
||||
Dept服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Services.IMenuService">
|
||||
<summary>
|
||||
Menu服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.ValidationImageCaptcha(Yi.Furion.Application.Rbac.Dtos.Account.LoginInputVo)">
|
||||
<summary>
|
||||
效验图片登录验证码,无需和账号绑定
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.ValidationPhoneCaptcha(Yi.Furion.Application.Rbac.Dtos.Account.RegisterDto)">
|
||||
<summary>
|
||||
效验电话验证码,需要与电话号码绑定
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.PostLoginAsync(Yi.Furion.Application.Rbac.Dtos.Account.LoginInputVo)">
|
||||
<summary>
|
||||
登录
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.GetCaptchaImage">
|
||||
<summary>
|
||||
生成验证码
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.ValidationPhone(System.String)">
|
||||
<summary>
|
||||
验证电话号码
|
||||
</summary>
|
||||
<param name="str_handset"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.PostCaptchaPhone(Yi.Furion.Application.Rbac.Dtos.Account.PhoneCaptchaImageDto)">
|
||||
<summary>
|
||||
注册 手机验证码
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.PostRegisterAsync(Yi.Furion.Application.Rbac.Dtos.Account.RegisterDto)">
|
||||
<summary>
|
||||
注册,需要验证码通过
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.Get">
|
||||
<summary>
|
||||
查询已登录的账户信息
|
||||
</summary>
|
||||
<returns></returns>
|
||||
<exception cref="T:Yi.Framework.Infrastructure.Exceptions.AuthException"></exception>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.GetVue3Router">
|
||||
<summary>
|
||||
获取当前登录用户的前端路由
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.PostLogout">
|
||||
<summary>
|
||||
退出登录
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.UpdatePasswordAsync(Yi.Furion.Application.Rbac.Dtos.Account.UpdatePasswordDto)">
|
||||
<summary>
|
||||
更新密码
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.RestPasswordAsync(System.Int64,Yi.Furion.Application.Rbac.Dtos.Account.RestPasswordDto)">
|
||||
<summary>
|
||||
重置密码
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.AccountService.UpdateIconAsync(Yi.Furion.Application.Rbac.Dtos.Account.UpdateIconDto)">
|
||||
<summary>
|
||||
更新头像
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Services.Impl.DeptService">
|
||||
<summary>
|
||||
Dept服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.DeptService.GetListRoleIdAsync(System.Int64)">
|
||||
<summary>
|
||||
通过角色id查询该角色全部部门
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.DeptService.GetListAsync(Yi.Furion.Application.Rbac.Dtos.Dept.DeptGetListInputVo)">
|
||||
<summary>
|
||||
多查
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Services.Impl.MenuService">
|
||||
<summary>
|
||||
Menu服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.MenuService.GetListRoleIdAsync(System.Int64)">
|
||||
<summary>
|
||||
查询当前角色的菜单
|
||||
</summary>
|
||||
<param name="roleId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Services.Impl.PostService">
|
||||
<summary>
|
||||
Post服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Services.Impl.RoleService">
|
||||
<summary>
|
||||
Role服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.RoleService.CreateAsync(Yi.Furion.Application.Rbac.Dtos.Role.RoleCreateInputVo)">
|
||||
<summary>
|
||||
添加角色
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.RoleService.UpdateAsync(System.Int64,Yi.Furion.Application.Rbac.Dtos.Role.RoleUpdateInputVo)">
|
||||
<summary>
|
||||
修改角色
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.RoleService.UpdateStateAsync(System.Int64,System.Boolean)">
|
||||
<summary>
|
||||
更新状态
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="state"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Services.Impl.UserService">
|
||||
<summary>
|
||||
User服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.UserService.GetListAsync(Yi.Furion.Application.Rbac.Dtos.User.UserGetListInputVo)">
|
||||
<summary>
|
||||
查询用户
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.UserService.CreateAsync(Yi.Furion.Application.Rbac.Dtos.User.UserCreateInputVo)">
|
||||
<summary>
|
||||
添加用户
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
<exception cref="T:Yi.Framework.Infrastructure.Exceptions.UserFriendlyException"></exception>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.UserService.GetAsync(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.UserService.UpdateAsync(System.Int64,Yi.Furion.Application.Rbac.Dtos.User.UserUpdateInputVo)">
|
||||
<summary>
|
||||
更新用户
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.UserService.UpdateProfileAsync(Yi.Furion.Application.Rbac.Dtos.User.ProfileUpdateInputVo)">
|
||||
<summary>
|
||||
更新个人中心
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Application.Rbac.Services.Impl.UserService.UpdateStateAsync(System.Int64,System.Boolean)">
|
||||
<summary>
|
||||
更新状态
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="state"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Services.IPostService">
|
||||
<summary>
|
||||
Post服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Services.IRoleService">
|
||||
<summary>
|
||||
Role服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Application.Rbac.Services.IUserService">
|
||||
<summary>
|
||||
User服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,364 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Furion.Rbac.Application</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Domain.AccountManager">
|
||||
<summary>
|
||||
用户领域服务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Domain.AccountManager.LoginValidationAsync(System.String,System.String,System.Action{Yi.Furion.Rbac.Core.Entities.UserEntity})">
|
||||
<summary>
|
||||
登录效验
|
||||
</summary>
|
||||
<param name="userName"></param>
|
||||
<param name="password"></param>
|
||||
<param name="userAction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Domain.AccountManager.ExistAsync(System.String,System.Action{Yi.Furion.Rbac.Core.Entities.UserEntity})">
|
||||
<summary>
|
||||
判断账户合法存在
|
||||
</summary>
|
||||
<param name="userName"></param>
|
||||
<param name="userAction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Domain.AccountManager.UserInfoToClaim(Yi.Furion.Rbac.Core.Dtos.UserRoleMenuDto)">
|
||||
<summary>
|
||||
令牌转换
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Domain.AccountManager.UpdatePasswordAsync(System.Int64,System.String,System.String)">
|
||||
<summary>
|
||||
更新密码
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<param name="newPassword"></param>
|
||||
<param name="oldPassword"></param>
|
||||
<returns></returns>
|
||||
<exception cref="T:Yi.Framework.Infrastructure.Exceptions.UserFriendlyException"></exception>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Domain.AccountManager.RestPasswordAsync(System.Int64,System.String)">
|
||||
<summary>
|
||||
重置密码
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<param name="password"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Domain.RoleManager.GiveRoleSetMenuAsync(System.Collections.Generic.List{System.Int64},System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
给角色设置菜单
|
||||
</summary>
|
||||
<param name="roleIds"></param>
|
||||
<param name="menuIds"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Domain.UserManager.GiveUserSetRoleAsync(System.Collections.Generic.List{System.Int64},System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
给用户设置角色
|
||||
</summary>
|
||||
<param name="userIds"></param>
|
||||
<param name="roleIds"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Domain.UserManager.GiveUserSetPostAsync(System.Collections.Generic.List{System.Int64},System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
给用户设置岗位
|
||||
</summary>
|
||||
<param name="userIds"></param>
|
||||
<param name="postIds"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:Yi.Furion.Rbac.Application.System.Dtos.Account.RegisterDto.UserName">
|
||||
<summary>
|
||||
账号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Furion.Rbac.Application.System.Dtos.Account.RegisterDto.Password">
|
||||
<summary>
|
||||
密码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Furion.Rbac.Application.System.Dtos.Account.RegisterDto.Uuid">
|
||||
<summary>
|
||||
唯一标识码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Furion.Rbac.Application.System.Dtos.Account.RegisterDto.Phone">
|
||||
<summary>
|
||||
电话
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.Furion.Rbac.Application.System.Dtos.Account.RegisterDto.Code">
|
||||
<summary>
|
||||
验证码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Dtos.Dept.DeptCreateInputVo">
|
||||
<summary>
|
||||
Dept输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Dtos.Menu.MenuCreateInputVo">
|
||||
<summary>
|
||||
Menu输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Dtos.Post.PostCreateInputVo">
|
||||
<summary>
|
||||
Post输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Dtos.Role.RoleCreateInputVo">
|
||||
<summary>
|
||||
Role输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Dtos.User.UserCreateInputVo">
|
||||
<summary>
|
||||
User输入创建对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Event.LoginEventHandler.GetClientInfo(Microsoft.AspNetCore.Http.HttpContext)">
|
||||
<summary>
|
||||
获取客户端信息
|
||||
</summary>
|
||||
<param name="context"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Event.LoginEventHandler.GetLoginLogInfo(Microsoft.AspNetCore.Http.HttpContext)">
|
||||
<summary>
|
||||
记录用户登陆信息
|
||||
</summary>
|
||||
<param name="context"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Services.IDeptService">
|
||||
<summary>
|
||||
Dept服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Services.IMenuService">
|
||||
<summary>
|
||||
Menu服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.ValidationImageCaptcha(Yi.Furion.Rbac.Application.System.Dtos.Account.LoginInputVo)">
|
||||
<summary>
|
||||
效验图片登录验证码,无需和账号绑定
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.ValidationPhoneCaptcha(Yi.Furion.Rbac.Application.System.Dtos.Account.RegisterDto)">
|
||||
<summary>
|
||||
效验电话验证码,需要与电话号码绑定
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.PostLoginAsync(Yi.Furion.Rbac.Application.System.Dtos.Account.LoginInputVo)">
|
||||
<summary>
|
||||
登录
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.GetCaptchaImage">
|
||||
<summary>
|
||||
生成验证码
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.ValidationPhone(System.String)">
|
||||
<summary>
|
||||
验证电话号码
|
||||
</summary>
|
||||
<param name="str_handset"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.PostCaptchaPhone(Yi.Furion.Rbac.Application.System.Dtos.Account.PhoneCaptchaImageDto)">
|
||||
<summary>
|
||||
注册 手机验证码
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.PostRegisterAsync(Yi.Furion.Rbac.Application.System.Dtos.Account.RegisterDto)">
|
||||
<summary>
|
||||
注册,需要验证码通过
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.Get">
|
||||
<summary>
|
||||
查询已登录的账户信息
|
||||
</summary>
|
||||
<returns></returns>
|
||||
<exception cref="T:Yi.Framework.Infrastructure.Exceptions.AuthException"></exception>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.GetVue3Router">
|
||||
<summary>
|
||||
获取当前登录用户的前端路由
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.PostLogout">
|
||||
<summary>
|
||||
退出登录
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.UpdatePasswordAsync(Yi.Furion.Rbac.Application.System.Dtos.Account.UpdatePasswordDto)">
|
||||
<summary>
|
||||
更新密码
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.RestPasswordAsync(System.Int64,Yi.Furion.Rbac.Application.System.Dtos.Account.RestPasswordDto)">
|
||||
<summary>
|
||||
重置密码
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.AccountService.UpdateIconAsync(Yi.Furion.Rbac.Application.System.Dtos.Account.UpdateIconDto)">
|
||||
<summary>
|
||||
更新头像
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Services.Impl.DeptService">
|
||||
<summary>
|
||||
Dept服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.DeptService.GetListRoleIdAsync(System.Int64)">
|
||||
<summary>
|
||||
通过角色id查询该角色全部部门
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.DeptService.GetListAsync(Yi.Furion.Rbac.Application.System.Dtos.Dept.DeptGetListInputVo)">
|
||||
<summary>
|
||||
多查
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Services.Impl.MenuService">
|
||||
<summary>
|
||||
Menu服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.MenuService.GetListRoleIdAsync(System.Int64)">
|
||||
<summary>
|
||||
查询当前角色的菜单
|
||||
</summary>
|
||||
<param name="roleId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Services.Impl.PostService">
|
||||
<summary>
|
||||
Post服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Services.Impl.RoleService">
|
||||
<summary>
|
||||
Role服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.RoleService.CreateAsync(Yi.Furion.Rbac.Application.System.Dtos.Role.RoleCreateInputVo)">
|
||||
<summary>
|
||||
添加角色
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.RoleService.UpdateAsync(System.Int64,Yi.Furion.Rbac.Application.System.Dtos.Role.RoleUpdateInputVo)">
|
||||
<summary>
|
||||
修改角色
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.RoleService.UpdateStateAsync(System.Int64,System.Boolean)">
|
||||
<summary>
|
||||
更新状态
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="state"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Services.Impl.UserService">
|
||||
<summary>
|
||||
User服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.UserService.GetListAsync(Yi.Furion.Rbac.Application.System.Dtos.User.UserGetListInputVo)">
|
||||
<summary>
|
||||
查询用户
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.UserService.CreateAsync(Yi.Furion.Rbac.Application.System.Dtos.User.UserCreateInputVo)">
|
||||
<summary>
|
||||
添加用户
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
<exception cref="T:Yi.Framework.Infrastructure.Exceptions.UserFriendlyException"></exception>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.UserService.GetAsync(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.UserService.UpdateAsync(System.Int64,Yi.Furion.Rbac.Application.System.Dtos.User.UserUpdateInputVo)">
|
||||
<summary>
|
||||
更新用户
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.UserService.UpdateProfileAsync(Yi.Furion.Rbac.Application.System.Dtos.User.ProfileUpdateInputVo)">
|
||||
<summary>
|
||||
更新个人中心
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Furion.Rbac.Application.System.Services.Impl.UserService.UpdateStateAsync(System.Int64,System.Boolean)">
|
||||
<summary>
|
||||
更新状态
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="state"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Services.IPostService">
|
||||
<summary>
|
||||
Post服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Services.IRoleService">
|
||||
<summary>
|
||||
Role服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.Furion.Rbac.Application.System.Services.IUserService">
|
||||
<summary>
|
||||
User服务抽象
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json",
|
||||
"SpecificationDocumentSettings": {
|
||||
"DocumentTitle": "Furion | 规范化接口",
|
||||
"GroupOpenApiInfos": [
|
||||
{
|
||||
"Group": "Default",
|
||||
"Title": "规范化接口演示",
|
||||
"Description": "让 .NET 开发更简单,更通用,更流行。",
|
||||
"Version": "1.0.0",
|
||||
"TermsOfService": "https://furion.baiqian.ltd",
|
||||
"Contact": {
|
||||
"Name": "百小僧",
|
||||
"Url": "https://gitee.com/monksoul",
|
||||
"Email": "monksoul@outlook.com"
|
||||
},
|
||||
"License": {
|
||||
"Name": "Apache-2.0",
|
||||
"Url": "https://gitee.com/dotnetchina/Furion/blob/rc1/LICENSE"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"CorsAccessorSettings": {
|
||||
"WithExposedHeaders": [
|
||||
"access-token",
|
||||
"x-access-token",
|
||||
"environment"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user