feat: 初始化后台管理模块与基础业务框架
1. 新增依赖注入生命周期标记接口、基础仓储与管理员仓储实现 2. 新增管理员认证与用户服务接口,补充认证相关DTO 3. 重构实体审计字段命名,统一Created/UpdatedAt规范 4. 新增大量业务实体类与API版本枚举配置 5. 集成Autofac依赖注入、JWT自动刷新与跨域配置 6. 替换原有微信小程序与旧认证服务为后台管理系统架构 7. 完善Swagger文档配置与项目基础部署配置
This commit is contained in:
96
QYZH.InteractiveMagazine.IService/Dto/AdminUserDto.cs
Normal file
96
QYZH.InteractiveMagazine.IService/Dto/AdminUserDto.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.IService.Dto;
|
||||
|
||||
/// <summary>
|
||||
/// 管理员创建/更新输入
|
||||
/// </summary>
|
||||
public class AdminUserInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户名
|
||||
/// </summary>
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 密码(创建时必填,更新时为空表示不修改密码)
|
||||
/// </summary>
|
||||
public string? Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 管理员类型: SuperAdmin, Editor
|
||||
/// </summary>
|
||||
public string Type { get; set; } = "Editor";
|
||||
|
||||
/// <summary>
|
||||
/// 状态: Active, Inactive
|
||||
/// </summary>
|
||||
public string Status { get; set; } = "Active";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 管理员输出
|
||||
/// </summary>
|
||||
public class AdminUserOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键ID
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户名
|
||||
/// </summary>
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 管理员类型
|
||||
/// </summary>
|
||||
public string Type { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public string Status { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
public string? CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新人
|
||||
/// </summary>
|
||||
public string? UpdatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime? UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 管理员分页查询输入
|
||||
/// </summary>
|
||||
public class AdminUserQueryInput : PageQueryModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户名(模糊查询)
|
||||
/// </summary>
|
||||
public string? UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 管理员类型
|
||||
/// </summary>
|
||||
public string? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public string? Status { get; set; }
|
||||
}
|
||||
@ -62,3 +62,32 @@ public class LoginOutput
|
||||
/// </summary>
|
||||
public string RefreshToken { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class AdminLoginInput
|
||||
{
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class AdminLoginOutput
|
||||
{
|
||||
public string Token { get; set; } = string.Empty;
|
||||
|
||||
public long UserId { get; set; }
|
||||
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
public string Type { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class AdminUserInfoOutput
|
||||
{
|
||||
public long UserId { get; set; }
|
||||
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
public string Type { get; set; } = string.Empty;
|
||||
|
||||
public string Status { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
14
QYZH.InteractiveMagazine.IService/IAdminAuthService.cs
Normal file
14
QYZH.InteractiveMagazine.IService/IAdminAuthService.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using QYZH.InteractiveMagazine.IService.Dto;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.IService;
|
||||
|
||||
public interface IAdminAuthService
|
||||
{
|
||||
Task<AdminLoginOutput> LoginAsync(AdminLoginInput input);
|
||||
|
||||
Task LogoutAsync(long userId);
|
||||
|
||||
Task<AdminUserInfoOutput> GetAdminInfoAsync(long userId);
|
||||
|
||||
Task ChangePasswordAsync(long userId, string oldPassword, string newPassword);
|
||||
}
|
||||
45
QYZH.InteractiveMagazine.IService/IAdminUserService.cs
Normal file
45
QYZH.InteractiveMagazine.IService/IAdminUserService.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using QYZH.InteractiveMagazine.IService.Dto;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.IService;
|
||||
|
||||
/// <summary>
|
||||
/// 管理员用户服务接口
|
||||
/// </summary>
|
||||
public interface IAdminUserService
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建管理员
|
||||
/// </summary>
|
||||
/// <param name="input">管理员输入</param>
|
||||
/// <returns>创建的管理员信息</returns>
|
||||
Task<AdminUserOutput> CreateAsync(AdminUserInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 更新管理员
|
||||
/// </summary>
|
||||
/// <param name="id">管理员ID</param>
|
||||
/// <param name="input">管理员输入</param>
|
||||
/// <returns>更新后的管理员信息</returns>
|
||||
Task<AdminUserOutput> UpdateAsync(long id, AdminUserInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 删除管理员(软删除)
|
||||
/// </summary>
|
||||
/// <param name="id">管理员ID</param>
|
||||
Task DeleteAsync(long id);
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取管理员
|
||||
/// </summary>
|
||||
/// <param name="id">管理员ID</param>
|
||||
/// <returns>管理员信息</returns>
|
||||
Task<AdminUserOutput> GetByIdAsync(long id);
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询管理员列表
|
||||
/// </summary>
|
||||
/// <param name="input">查询条件</param>
|
||||
/// <returns>分页结果</returns>
|
||||
Task<PageListModel<AdminUserOutput>> GetListAsync(AdminUserQueryInput input);
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
using QYZH.InteractiveMagazine.IService.Dto;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.IService;
|
||||
|
||||
/// <summary>
|
||||
/// 认证服务接口
|
||||
/// </summary>
|
||||
public interface IAuthService
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户登录
|
||||
/// </summary>
|
||||
/// <param name="account">账号</param>
|
||||
/// <param name="password">密码</param>
|
||||
/// <returns>登录结果</returns>
|
||||
Task<LoginOutput> LoginAsync(string account, string password);
|
||||
|
||||
/// <summary>
|
||||
/// 用户注册
|
||||
/// </summary>
|
||||
/// <param name="input">注册输入参数</param>
|
||||
/// <returns>是否成功</returns>
|
||||
Task<bool> RegisterAsync(RegisterInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 刷新令牌
|
||||
/// </summary>
|
||||
/// <param name="refreshToken">刷新令牌</param>
|
||||
/// <returns>新的登录结果</returns>
|
||||
Task<LoginOutput> RefreshTokenAsync(string refreshToken);
|
||||
}
|
||||
15
QYZH.InteractiveMagazine.IService/IDependency.cs
Normal file
15
QYZH.InteractiveMagazine.IService/IDependency.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace QYZH.InteractiveMagazine.IService;
|
||||
|
||||
/// <summary>
|
||||
/// 单例生命周期标记接口
|
||||
/// </summary>
|
||||
public interface ISingletonDependency
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 瞬时生命周期标记接口
|
||||
/// </summary>
|
||||
public interface ITransientDependency
|
||||
{
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
using QYZH.InteractiveMagazine.IService.Dto;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.IService;
|
||||
|
||||
/// <summary>
|
||||
/// 微信小程序服务接口
|
||||
/// </summary>
|
||||
public interface IWeChatMiniProgramService
|
||||
{
|
||||
/// <summary>
|
||||
/// 微信登录
|
||||
/// </summary>
|
||||
/// <param name="code">微信登录凭证</param>
|
||||
/// <returns>微信登录结果</returns>
|
||||
Task<WeChatLoginOutput> WeChatLoginAsync(string code);
|
||||
|
||||
/// <summary>
|
||||
/// 获取手机号
|
||||
/// </summary>
|
||||
/// <param name="code">获取手机号凭证</param>
|
||||
/// <returns>手机号信息</returns>
|
||||
Task<WeChatPhoneNumberOutput> GetPhoneNumberAsync(string code);
|
||||
}
|
||||
Reference in New Issue
Block a user