mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-12-29 00:55:48 +08:00
wip: 🧠 初步的框架
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
using NetAdmin.Domain.Dto.Dependency;
|
||||
using NetAdmin.Domain.Dto.Sys.Api;
|
||||
using NetAdmin.Host.Attributes;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 接口服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class ApiController : ControllerBase<IApiCache, IApiService>, IApiModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiController" /> class.
|
||||
/// </summary>
|
||||
public ApiController(IApiCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除接口
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
[Transaction]
|
||||
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
return Cache.BulkDeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建接口
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
[Transaction]
|
||||
public Task<QueryApiRsp> CreateAsync(CreateApiReq req)
|
||||
{
|
||||
return Cache.CreateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除接口
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
[Transaction]
|
||||
public Task<int> DeleteAsync(DelReq req)
|
||||
{
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 接口是否存在
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<bool> ExistAsync(QueryReq<QueryApiReq> req)
|
||||
{
|
||||
return Cache.ExistAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个接口
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<QueryApiRsp> GetAsync(QueryApiReq req)
|
||||
{
|
||||
return Cache.GetAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询接口
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<PagedQueryRsp<QueryApiRsp>> PagedQueryAsync(PagedQueryReq<QueryApiReq> req)
|
||||
{
|
||||
return Cache.PagedQueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询接口
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryApiRsp>> QueryAsync(QueryReq<QueryApiReq> req)
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步接口
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task SyncAsync()
|
||||
{
|
||||
return Cache.SyncAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新接口
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<NopReq> UpdateAsync(NopReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using NetAdmin.Domain.Dto.Dependency;
|
||||
using NetAdmin.Domain.Dto.Sys.Cache;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 缓存服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class CacheController : ControllerBase<ICacheCache, ICacheService>, ICacheModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CacheController" /> class.
|
||||
/// </summary>
|
||||
public CacheController(ICacheCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 缓存统计
|
||||
/// </summary>
|
||||
public Task<CacheStatisticsRsp> CacheStatisticsAsync()
|
||||
{
|
||||
return Cache.CacheStatisticsAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有缓存项
|
||||
/// </summary>
|
||||
public PagedQueryRsp<GetAllEntriesRsp> GetAllEntries(PagedQueryReq<GetAllEntriesReq> req)
|
||||
{
|
||||
return Cache.GetAllEntries(req);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using NetAdmin.Domain.Dto.Sys.Captcha;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 人机验证服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class CaptchaController : ControllerBase<ICaptchaCache, ICaptchaService>, ICaptchaModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CaptchaController" /> class.
|
||||
/// </summary>
|
||||
public CaptchaController(ICaptchaCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 获取人机校验图
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
public Task<GetCaptchaRsp> GetCaptchaImageAsync()
|
||||
{
|
||||
return Cache.GetCaptchaImageAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 完成人机校验
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
public Task<bool> VerifyCaptchaAsync(VerifyCaptchaReq req)
|
||||
{
|
||||
return Cache.VerifyCaptchaAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using NetAdmin.Domain.Dto.Dependency;
|
||||
using NetAdmin.Domain.Dto.Sys.Config;
|
||||
using NetAdmin.Host.Attributes;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 配置服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class ConfigController : ControllerBase<IConfigCache, IConfigService>, IConfigModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConfigController" /> class.
|
||||
/// </summary>
|
||||
public ConfigController(IConfigCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除配置
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
return Cache.BulkDeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建配置
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryConfigRsp> CreateAsync(CreateConfigReq req)
|
||||
{
|
||||
return Cache.CreateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除配置
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> DeleteAsync(DelReq req)
|
||||
{
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置是否存在
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<bool> ExistAsync(QueryReq<QueryConfigReq> req)
|
||||
{
|
||||
return Cache.ExistAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个配置
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<QueryConfigRsp> GetAsync(QueryConfigReq req)
|
||||
{
|
||||
return Cache.GetAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取最新有效配置
|
||||
/// </summary>
|
||||
public Task<QueryConfigRsp> GetLatestConfigAsync()
|
||||
{
|
||||
return Cache.GetLatestConfigAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询配置
|
||||
/// </summary>
|
||||
public Task<PagedQueryRsp<QueryConfigRsp>> PagedQueryAsync(PagedQueryReq<QueryConfigReq> req)
|
||||
{
|
||||
return Cache.PagedQueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询配置
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryConfigRsp>> QueryAsync(QueryReq<QueryConfigReq> req)
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新配置
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryConfigRsp> UpdateAsync(UpdateConfigReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using NetAdmin.Domain.Dto;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 常量服务
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class ConstantController : ControllerBase<IConstantCache, IConstantService>, IConstantModule
|
||||
{
|
||||
private readonly JsonOptions _jsonOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConstantController" /> class.
|
||||
/// </summary>
|
||||
public ConstantController(IConstantCache cache, IOptions<JsonOptions> jsonOptions) //
|
||||
: base(cache)
|
||||
{
|
||||
_jsonOptions = jsonOptions.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得常量字符串
|
||||
/// </summary>
|
||||
[NonUnify]
|
||||
public IActionResult GetChars()
|
||||
{
|
||||
var ret = GetCharsDic();
|
||||
return OriginNamingResult(ret);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得常量字符串
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public IDictionary<string, string> GetCharsDic()
|
||||
{
|
||||
return Cache.GetCharsDic();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得公共枚举值
|
||||
/// </summary>
|
||||
public IDictionary<string, Dictionary<string, string[]>> GetEnums()
|
||||
{
|
||||
return Cache.GetEnums();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得本地化字符串
|
||||
/// </summary>
|
||||
public IDictionary<string, string> GetLocalizedStrings()
|
||||
{
|
||||
return Cache.GetLocalizedStrings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得数字常量表
|
||||
/// </summary>
|
||||
[NonUnify]
|
||||
public IActionResult GetNumbers()
|
||||
{
|
||||
var ret = GetNumbersDic();
|
||||
return OriginNamingResult(ret);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得数字常量表
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public IDictionary<string, long> GetNumbersDic()
|
||||
{
|
||||
return Cache.GetNumbersDic();
|
||||
}
|
||||
|
||||
private IActionResult OriginNamingResult<T>(T data)
|
||||
{
|
||||
return new JsonResult( //
|
||||
new RestfulInfo<T> { Code = 0, Data = data }
|
||||
, new JsonSerializerOptions(_jsonOptions.JsonSerializerOptions) { DictionaryKeyPolicy = null });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using NetAdmin.Domain.Dto.Dependency;
|
||||
using NetAdmin.Domain.Dto.Sys.Dept;
|
||||
using NetAdmin.Host.Attributes;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 部门服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class DeptController : ControllerBase<IDeptCache, IDeptService>, IDeptModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeptController" /> class.
|
||||
/// </summary>
|
||||
public DeptController(IDeptCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除部门
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
return Cache.BulkDeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建部门
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryDeptRsp> CreateAsync(CreateDeptReq req)
|
||||
{
|
||||
return Cache.CreateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除部门
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> DeleteAsync(DelReq req)
|
||||
{
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 部门是否存在
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<bool> ExistAsync(QueryReq<QueryDeptReq> req)
|
||||
{
|
||||
return Cache.ExistAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个部门
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<QueryDeptRsp> GetAsync(QueryDeptReq req)
|
||||
{
|
||||
return Cache.GetAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询部门
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<PagedQueryRsp<QueryDeptRsp>> PagedQueryAsync(PagedQueryReq<QueryDeptReq> req)
|
||||
{
|
||||
return Cache.PagedQueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询部门
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryDeptRsp>> QueryAsync(QueryReq<QueryDeptReq> req)
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新部门
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryDeptRsp> UpdateAsync(UpdateDeptReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using NetAdmin.Domain.Dto.Sys.Dev;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 开发服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class DevController : ControllerBase<IDevCache, IDevService>, IDevModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DevController" /> class.
|
||||
/// </summary>
|
||||
public DevController(IDevCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 生成后端代码
|
||||
/// </summary>
|
||||
public Task GenerateCsCodeAsync(GenerateCsCodeReq req)
|
||||
{
|
||||
return Cache.GenerateCsCodeAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成图标代码
|
||||
/// </summary>
|
||||
public Task GenerateIconCodeAsync(GenerateIconCodeReq req)
|
||||
{
|
||||
return Cache.GenerateIconCodeAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成接口代码
|
||||
/// </summary>
|
||||
public Task GenerateJsCodeAsync()
|
||||
{
|
||||
return Cache.GenerateJsCodeAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
using NetAdmin.Domain.Dto.Dependency;
|
||||
using NetAdmin.Domain.Dto.Sys.Dic.Catalog;
|
||||
using NetAdmin.Domain.Dto.Sys.Dic.Content;
|
||||
using NetAdmin.Host.Attributes;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 字典服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class DicController : ControllerBase<IDicCache, IDicService>, IDicModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DicController" /> class.
|
||||
/// </summary>
|
||||
public DicController(IDicCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除字典目录
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> BulkDeleteCatalogAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
return Cache.BulkDeleteCatalogAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除字典内容
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> BulkDeleteContentAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
return Cache.BulkDeleteContentAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建字典目录
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryDicCatalogRsp> CreateCatalogAsync(CreateDicCatalogReq req)
|
||||
{
|
||||
return Cache.CreateCatalogAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建字典内容
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryDicContentRsp> CreateContentAsync(CreateDicContentReq req)
|
||||
{
|
||||
return Cache.CreateContentAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除字典目录
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> DeleteCatalogAsync(DelReq req)
|
||||
{
|
||||
return Cache.DeleteCatalogAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除字典内容
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> DeleteContentAsync(DelReq req)
|
||||
{
|
||||
return Cache.DeleteContentAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询字典目录
|
||||
/// </summary>
|
||||
public Task<PagedQueryRsp<QueryDicCatalogRsp>> PagedQueryCatalogAsync(PagedQueryReq<QueryDicCatalogReq> req)
|
||||
{
|
||||
return Cache.PagedQueryCatalogAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询字典内容
|
||||
/// </summary>
|
||||
public Task<PagedQueryRsp<QueryDicContentRsp>> PagedQueryContentAsync(PagedQueryReq<QueryDicContentReq> req)
|
||||
{
|
||||
return Cache.PagedQueryContentAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询字典目录
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryDicCatalogRsp>> QueryCatalogAsync(QueryReq<QueryDicCatalogReq> req)
|
||||
{
|
||||
return Cache.QueryCatalogAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询字典内容
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryDicContentRsp>> QueryContentAsync(QueryReq<QueryDicContentReq> req)
|
||||
{
|
||||
return Cache.QueryContentAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新字典目录
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryDicCatalogRsp> UpdateCatalogAsync(UpdateDicCatalogReq req)
|
||||
{
|
||||
return Cache.UpdateCatalogAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新字典内容
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryDicContentRsp> UpdateContentAsync(UpdateDicContentReq req)
|
||||
{
|
||||
return Cache.UpdateContentAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 文件服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class FileController : ControllerBase<IFileCache, IFileService>, IFileModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileController" /> class.
|
||||
/// </summary>
|
||||
public FileController(IFileCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 文件上传
|
||||
/// </summary>
|
||||
public Task<string> UploadAsync(IFormFile file)
|
||||
{
|
||||
return Cache.UploadAsync(file);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using NetAdmin.Domain.Dto.Dependency;
|
||||
using NetAdmin.Domain.Dto.Sys.RequestLog;
|
||||
using NetAdmin.Host.Attributes;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 请求日志服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class LogController : ControllerBase<IRequestLogCache, IRequestLogService>, IRequestLogModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LogController" /> class.
|
||||
/// </summary>
|
||||
public LogController(IRequestLogCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除请求日志
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
[Transaction]
|
||||
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
return Cache.BulkDeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建请求日志
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
[Transaction]
|
||||
public Task<QueryRequestLogRsp> CreateAsync(CreateRequestLogReq req)
|
||||
{
|
||||
return Cache.CreateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除请求日志
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
[Transaction]
|
||||
public Task<int> DeleteAsync(DelReq req)
|
||||
{
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求日志是否存在
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<bool> ExistAsync(QueryReq<QueryRequestLogReq> req)
|
||||
{
|
||||
return Cache.ExistAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个请求日志
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<QueryRequestLogRsp> GetAsync(QueryRequestLogReq req)
|
||||
{
|
||||
return Cache.GetAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询请求日志
|
||||
/// </summary>
|
||||
public Task<PagedQueryRsp<QueryRequestLogRsp>> PagedQueryAsync(PagedQueryReq<QueryRequestLogReq> req)
|
||||
{
|
||||
return Cache.PagedQueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询请求日志
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryRequestLogRsp>> QueryAsync(QueryReq<QueryRequestLogReq> req)
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新请求日志
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
[Transaction]
|
||||
public Task<NopReq> UpdateAsync(NopReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using NetAdmin.Domain.Dto.Dependency;
|
||||
using NetAdmin.Domain.Dto.Sys.Menu;
|
||||
using NetAdmin.Host.Attributes;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 菜单服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class MenuController : ControllerBase<IMenuCache, IMenuService>, IMenuModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MenuController" /> class.
|
||||
/// </summary>
|
||||
public MenuController(IMenuCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除菜单
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
return Cache.BulkDeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建菜单
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryMenuRsp> CreateAsync(CreateMenuReq req)
|
||||
{
|
||||
return Cache.CreateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除菜单
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> DeleteAsync(DelReq req)
|
||||
{
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单是否存在
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<bool> ExistAsync(QueryReq<QueryMenuReq> req)
|
||||
{
|
||||
return Cache.ExistAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个菜单
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<QueryMenuRsp> GetAsync(QueryMenuReq req)
|
||||
{
|
||||
return Cache.GetAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询菜单
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<PagedQueryRsp<QueryMenuRsp>> PagedQueryAsync(PagedQueryReq<QueryMenuReq> req)
|
||||
{
|
||||
return Cache.PagedQueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询菜单
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryMenuRsp>> QueryAsync(QueryReq<QueryMenuReq> req)
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新菜单
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryMenuRsp> UpdateAsync(UpdateMenuReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户菜单
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryMenuRsp>> UserMenusAsync()
|
||||
{
|
||||
return Cache.UserMenusAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using NetAdmin.Domain.Dto.Dependency;
|
||||
using NetAdmin.Domain.Dto.Sys.Role;
|
||||
using NetAdmin.Host.Attributes;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 角色服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class RoleController : ControllerBase<IRoleCache, IRoleService>, IRoleModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RoleController" /> class.
|
||||
/// </summary>
|
||||
public RoleController(IRoleCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除角色
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
return Cache.BulkDeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建角色
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryRoleRsp> CreateAsync(CreateRoleReq req)
|
||||
{
|
||||
return Cache.CreateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除角色
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> DeleteAsync(DelReq req)
|
||||
{
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色是否存在
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<bool> ExistAsync(QueryReq<QueryRoleReq> req)
|
||||
{
|
||||
return Cache.ExistAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个角色
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<QueryRoleRsp> GetAsync(QueryRoleReq req)
|
||||
{
|
||||
return Cache.GetAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询角色
|
||||
/// </summary>
|
||||
public Task<PagedQueryRsp<QueryRoleRsp>> PagedQueryAsync(PagedQueryReq<QueryRoleReq> req)
|
||||
{
|
||||
return Cache.PagedQueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询角色
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryRoleRsp>> QueryAsync(QueryReq<QueryRoleReq> req)
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新角色
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryRoleRsp> UpdateAsync(UpdateRoleReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 工具服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class ToolsController : ControllerBase<IToolsCache, IToolsService>, IToolsModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ToolsController" /> class.
|
||||
/// </summary>
|
||||
public ToolsController(IToolsCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 服务器时间
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
public DateTime GetServerUtcTime()
|
||||
{
|
||||
return Cache.GetServerUtcTime();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 版本信息
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
public string Version()
|
||||
{
|
||||
return Cache.Version();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
using NetAdmin.Domain.Dto.Dependency;
|
||||
using NetAdmin.Domain.Dto.Sys.User;
|
||||
using NetAdmin.Domain.Dto.Sys.UserProfile;
|
||||
using NetAdmin.Host.Attributes;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 用户服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class UserController : ControllerBase<IUserCache, IUserService>, IUserModule
|
||||
{
|
||||
private readonly IConfigCache _configCache;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UserController" /> class.
|
||||
/// </summary>
|
||||
public UserController(IUserCache cache, IConfigCache configCache) //
|
||||
: base(cache)
|
||||
{
|
||||
_configCache = configCache;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除用户
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
[Transaction]
|
||||
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
return Cache.BulkDeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查手机号是否可用
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
public Task<bool> CheckMobileAvailableAsync(CheckMobileAvailableReq req)
|
||||
{
|
||||
return Cache.CheckMobileAvailableAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查用户名是否可用
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
public Task<bool> CheckUserNameAvailableAsync(CheckUserNameAvailableReq req)
|
||||
{
|
||||
return Cache.CheckUserNameAvailableAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryUserRsp> CreateAsync(CreateUserReq req)
|
||||
{
|
||||
return Cache.CreateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> DeleteAsync(DelReq req)
|
||||
{
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户是否存在
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<bool> ExistAsync(QueryReq<QueryUserReq> req)
|
||||
{
|
||||
return Cache.ExistAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个用户
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<QueryUserRsp> GetAsync(QueryUserReq req)
|
||||
{
|
||||
return Cache.GetAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 密码登录
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
[Transaction]
|
||||
public async Task<LoginRsp> LoginByPwdAsync(LoginByPwdReq req)
|
||||
{
|
||||
var ret = await Cache.LoginByPwdAsync(req);
|
||||
ret.SetToRspHeader();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 短信登录
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
[Transaction]
|
||||
public async Task<LoginRsp> LoginBySmsAsync(LoginBySmsReq req)
|
||||
{
|
||||
var ret = await Cache.LoginBySmsAsync(req);
|
||||
ret.SetToRspHeader();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询用户
|
||||
/// </summary>
|
||||
public Task<PagedQueryRsp<QueryUserRsp>> PagedQueryAsync(PagedQueryReq<QueryUserReq> req)
|
||||
{
|
||||
return Cache.PagedQueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询用户
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryUserRsp>> QueryAsync(QueryReq<QueryUserReq> req)
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询用户档案
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryUserProfileRsp>> QueryProfileAsync(QueryReq<QueryUserProfileReq> req)
|
||||
{
|
||||
return Cache.QueryProfileAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册用户
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
[AllowAnonymous]
|
||||
public async Task<UserInfoRsp> RegisterAsync(RegisterUserReq req)
|
||||
{
|
||||
var config = await _configCache.GetLatestConfigAsync();
|
||||
|
||||
return await Cache.RegisterAsync(req with {
|
||||
DeptId = config.UserRegisterDeptId
|
||||
, RoleIds = new[] { config.UserRegisterRoleId }
|
||||
, Profile = new CreateUserProfileReq()
|
||||
, Enabled = !config.UserRegisterConfirm
|
||||
, Mobile = req.VerifySmsCodeReq.DestDevice
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重设密码
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
[Transaction]
|
||||
public Task<uint> ResetPasswordAsync(ResetPasswordReq req)
|
||||
{
|
||||
return Cache.ResetPasswordAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新用户头像
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<UserInfoRsp> SetAvatarAsync(SetAvatarReq req)
|
||||
{
|
||||
return Cache.SetAvatarAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置邮箱
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<UserInfoRsp> SetEmailAsync(SetEmailReq req)
|
||||
{
|
||||
return Cache.SetEmailAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置手机号
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<UserInfoRsp> SetMobileAsync(SetMobileReq req)
|
||||
{
|
||||
return Cache.SetMobileAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置密码
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<uint> SetPasswordAsync(SetPasswordReq req)
|
||||
{
|
||||
return Cache.SetPasswordAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新用户
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryUserRsp> UpdateAsync(UpdateUserReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户信息
|
||||
/// </summary>
|
||||
public Task<UserInfoRsp> UserInfoAsync()
|
||||
{
|
||||
return Cache.UserInfoAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using NetAdmin.Domain.Dto.Dependency;
|
||||
using NetAdmin.Domain.Dto.Sys.VerifyCode;
|
||||
using NetAdmin.Host.Attributes;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
|
||||
|
||||
/// <summary>
|
||||
/// 验证码服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
|
||||
public sealed class VerifyCodeController : ControllerBase<IVerifyCodeCache, IVerifyCodeService>, IVerifyCodeModule
|
||||
{
|
||||
private readonly ICaptchaCache _captchaCache;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VerifyCodeController" /> class.
|
||||
/// </summary>
|
||||
public VerifyCodeController(IVerifyCodeCache cache, ICaptchaCache captchaCache) //
|
||||
: base(cache)
|
||||
{
|
||||
_captchaCache = captchaCache;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[NonAction]
|
||||
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[NonAction]
|
||||
public Task<QueryVerifyCodeRsp> CreateAsync(CreateVerifyCodeReq req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[NonAction]
|
||||
public Task<int> DeleteAsync(DelReq req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[NonAction]
|
||||
public Task<bool> ExistAsync(QueryReq<QueryVerifyCodeReq> req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[NonAction]
|
||||
public Task<QueryVerifyCodeRsp> GetAsync(QueryVerifyCodeReq req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[NonAction]
|
||||
public Task<PagedQueryRsp<QueryVerifyCodeRsp>> PagedQueryAsync(PagedQueryReq<QueryVerifyCodeReq> req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[NonAction]
|
||||
public Task<IEnumerable<QueryVerifyCodeRsp>> QueryAsync(QueryReq<QueryVerifyCodeReq> req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送验证码
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
[AllowAnonymous]
|
||||
public async Task<SendVerifyCodeRsp> SendVerifyCodeAsync(SendVerifyCodeReq req)
|
||||
{
|
||||
await _captchaCache.VerifyCaptchaAndRemoveAsync(req.VerifyCaptchaReq);
|
||||
return await Cache.SendVerifyCodeAsync(req);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[NonAction]
|
||||
public Task<QueryVerifyCodeRsp> UpdateAsync(UpdateVerifyCodeReq req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 完成验证
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
[AllowAnonymous]
|
||||
public Task<bool> VerifyAsync(VerifyCodeReq req)
|
||||
{
|
||||
return Cache.VerifyAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using NetAdmin.Domain.Dto.Dependency;
|
||||
using NetAdmin.Domain.Dto.Tpl.Example;
|
||||
using NetAdmin.Host.Attributes;
|
||||
using NetAdmin.Host.Controllers;
|
||||
using NetAdmin.SysComponent.Application.Modules.Tpl;
|
||||
using NetAdmin.SysComponent.Application.Services.Tpl.Dependency;
|
||||
using NetAdmin.SysComponent.Cache.Tpl.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Controllers.Tpl;
|
||||
|
||||
/// <summary>
|
||||
/// 示例服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(nameof(Tpl), Module = nameof(Tpl))]
|
||||
public sealed class ExampleController : ControllerBase<IExampleCache, IExampleService>, IExampleModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExampleController" /> class.
|
||||
/// </summary>
|
||||
public ExampleController(IExampleCache cache) //
|
||||
: base(cache) { }
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除示例
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
|
||||
{
|
||||
return Cache.BulkDeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建示例
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryExampleRsp> CreateAsync(CreateExampleReq req)
|
||||
{
|
||||
return Cache.CreateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除示例
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> DeleteAsync(DelReq req)
|
||||
{
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 示例是否存在
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<bool> ExistAsync(QueryReq<QueryExampleReq> req)
|
||||
{
|
||||
return Cache.ExistAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个示例
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<QueryExampleRsp> GetAsync(QueryExampleReq req)
|
||||
{
|
||||
return Cache.GetAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询示例
|
||||
/// </summary>
|
||||
public Task<PagedQueryRsp<QueryExampleRsp>> PagedQueryAsync(PagedQueryReq<QueryExampleReq> req)
|
||||
{
|
||||
return Cache.PagedQueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询示例
|
||||
/// </summary>
|
||||
public Task<IEnumerable<QueryExampleRsp>> QueryAsync(QueryReq<QueryExampleReq> req)
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新示例
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryExampleRsp> UpdateAsync(UpdateExampleReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$(SolutionDir)/CodeQuality.props"/>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../NetAdmin.Host/NetAdmin.Host.csproj"/>
|
||||
<ProjectReference Include="../NetAdmin.SysComponent.Cache/NetAdmin.SysComponent.Cache.csproj"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,31 @@
|
||||
using NetAdmin.Domain.Events;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Subscribers;
|
||||
|
||||
/// <summary>
|
||||
/// Api接口同步器
|
||||
/// </summary>
|
||||
public sealed class ApiSynchronizer : IEventSubscriber
|
||||
{
|
||||
private readonly ILogger<ApiSynchronizer> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiSynchronizer" /> class.
|
||||
/// </summary>
|
||||
public ApiSynchronizer(ILogger<ApiSynchronizer> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步Api接口
|
||||
/// </summary>
|
||||
[EventSubscribe(nameof(SyncStructureAfterEvent))]
|
||||
public async Task SyncApiAsync(EventHandlerExecutingContext _)
|
||||
{
|
||||
var logService = App.GetService<IApiService>();
|
||||
await logService.SyncAsync();
|
||||
_logger.Info($"{nameof(IApiService)}.{nameof(IApiService.SyncAsync)} {Ln.已完成}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using NetAdmin.Domain.Contexts;
|
||||
using NetAdmin.Domain.Events.Sys;
|
||||
using NetAdmin.SysComponent.Cache.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Subscribers;
|
||||
|
||||
/// <summary>
|
||||
/// 缓存清理器
|
||||
/// </summary>
|
||||
public sealed class CacheCleaner : IEventSubscriber
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CacheCleaner" /> class.
|
||||
/// </summary>
|
||||
public CacheCleaner() { }
|
||||
|
||||
/// <summary>
|
||||
/// 用户缓存清理
|
||||
/// </summary>
|
||||
[EventSubscribe(nameof(UserUpdatedEvent))]
|
||||
public async Task RemoveUserInfoAsync(EventHandlerExecutingContext context)
|
||||
{
|
||||
if (context.Source is not UserUpdatedEvent userUpdatedEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
var cache = App.GetService<IUserCache>();
|
||||
cache.Service.UserToken = ContextUserToken.Create(userUpdatedEvent.Data);
|
||||
await cache.RemoveUserInfoAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using NetAdmin.Domain.Dto.Sys.VerifyCode;
|
||||
using NetAdmin.Domain.Enums.Sys;
|
||||
using NetAdmin.Domain.Events.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Subscribers;
|
||||
|
||||
/// <summary>
|
||||
/// 邮件验证码发送器
|
||||
/// </summary>
|
||||
public sealed class EmailCodeSender : IEventSubscriber
|
||||
{
|
||||
private readonly ILogger<EmailCodeSender> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EmailCodeSender" /> class.
|
||||
/// </summary>
|
||||
public EmailCodeSender(ILogger<EmailCodeSender> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送邮件
|
||||
/// </summary>
|
||||
[EventSubscribe(nameof(VerifyCodeCreatedEvent))]
|
||||
public async Task SendEmailAsync(EventHandlerExecutingContext context)
|
||||
{
|
||||
if (context.Source is not VerifyCodeCreatedEvent verifyCodeCreatedEvent ||
|
||||
verifyCodeCreatedEvent.Data.DeviceType != VerifyCodeDeviceTypes.Email) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 发送...
|
||||
var verifyCodeService = App.GetService<IVerifyCodeService>();
|
||||
_ = await verifyCodeService.UpdateAsync(
|
||||
verifyCodeCreatedEvent.Data.Adapt<UpdateVerifyCodeReq>() with { Status = VerifyCodeStatues.Sent });
|
||||
_logger.Info($"{nameof(IVerifyCodeService)}.{nameof(IVerifyCodeService.UpdateAsync)} {Ln.已完成}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using NetAdmin.Domain.Dto.Sys.RequestLog;
|
||||
using NetAdmin.Domain.Dto.Sys.User;
|
||||
using NetAdmin.Domain.Events.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Subscribers;
|
||||
|
||||
/// <summary>
|
||||
/// 操作日志记录
|
||||
/// </summary>
|
||||
public sealed class OperationLogger : IEventSubscriber
|
||||
{
|
||||
/// <summary>
|
||||
/// 保存请求日志到数据库
|
||||
/// </summary>
|
||||
[EventSubscribe(nameof(RequestLogEvent))]
|
||||
public async Task OperationEventDbRecordAsync(EventHandlerExecutingContext context)
|
||||
{
|
||||
if (context.Source is not RequestLogEvent operationEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 跳过心跳请求
|
||||
if (operationEvent.Data.ApiId.Equals("api/health/check", StringComparison.OrdinalIgnoreCase)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CreateRequestLogReq logReq = null;
|
||||
|
||||
// 登录日志特殊处理
|
||||
if (operationEvent.Data.ApiId.Equals("api/user/login", StringComparison.OrdinalIgnoreCase)) {
|
||||
try {
|
||||
var loginReq = operationEvent.Data.RequestBody.ToObject<LoginByPwdReq>();
|
||||
logReq = operationEvent.Data with { ExtraData = loginReq.Account };
|
||||
}
|
||||
catch {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
logReq ??= operationEvent.Data;
|
||||
var logService = App.GetService<IRequestLogService>();
|
||||
logReq.TruncateStrings();
|
||||
_ = await logService.CreateAsync(logReq);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using NetAdmin.Domain.Dto.Sys.VerifyCode;
|
||||
using NetAdmin.Domain.Enums.Sys;
|
||||
using NetAdmin.Domain.Events.Sys;
|
||||
using NetAdmin.SysComponent.Application.Services.Sys.Dependency;
|
||||
|
||||
namespace NetAdmin.SysComponent.Host.Subscribers;
|
||||
|
||||
/// <summary>
|
||||
/// 短信验证码发送器
|
||||
/// </summary>
|
||||
public sealed class SmsCodeSender : IEventSubscriber
|
||||
{
|
||||
private readonly ILogger<SmsCodeSender> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SmsCodeSender" /> class.
|
||||
/// </summary>
|
||||
public SmsCodeSender(ILogger<SmsCodeSender> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送短信
|
||||
/// </summary>
|
||||
[EventSubscribe(nameof(VerifyCodeCreatedEvent))]
|
||||
public async Task SendSmsAsync(EventHandlerExecutingContext context)
|
||||
{
|
||||
if (context.Source is not VerifyCodeCreatedEvent verifyCodeCreatedEvent ||
|
||||
verifyCodeCreatedEvent.Data.DeviceType != VerifyCodeDeviceTypes.Mobile) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 发送...
|
||||
var verifyCodeService = App.GetService<IVerifyCodeService>();
|
||||
_ = await verifyCodeService.UpdateAsync(
|
||||
verifyCodeCreatedEvent.Data.Adapt<UpdateVerifyCodeReq>() with { Status = VerifyCodeStatues.Sent });
|
||||
_logger.Info($"{nameof(IVerifyCodeService)}.{nameof(IVerifyCodeService.UpdateAsync)} {Ln.已完成}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user