wip: 🧠 初步的框架

This commit is contained in:
tk
2023-08-25 15:33:42 +08:00
parent 57c1ba2002
commit 18b4d7547a
1014 changed files with 122380 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
namespace NetAdmin.Infrastructure.Configuration.Options;
/// <summary>
/// 人机验证配置
/// </summary>
public sealed record CaptchaOptions : OptionAbstraction
{
private static readonly double _seed
= BitConverter.ToInt32(Chars.TPL_DATE_YYYYMMDD[..4].Select(x => (byte)x).ToArray());
#pragma warning disable S3963
static CaptchaOptions()
#pragma warning restore S3963
{
var rtn = new char[32];
for (var i = 0; i != 32; i++) {
rtn[i] = Chars.FLG_VISIBLE_ASCIIS[
(int)(Math.Abs(Math.Sin(_seed * (i + 1))) * Chars.FLG_VISIBLE_ASCIIS.Length)];
}
SecretKey = new string(rtn);
}
/// <summary>
/// 密钥
/// </summary>
public static string SecretKey { get; }
}

View File

@@ -0,0 +1,24 @@
using DataType = FreeSql.DataType;
namespace NetAdmin.Infrastructure.Configuration.Options;
/// <summary>
/// 数据库连接字符串配置
/// </summary>
public sealed record DatabaseOptions : OptionAbstraction
{
/// <summary>
/// 链接字符串
/// </summary>
public string ConnStr { get; init; }
/// <summary>
/// 数据库类型
/// </summary>
public DataType DbType { get; init; }
/// <summary>
/// 种子数据路径(相对)
/// </summary>
public string SeedDataRelativePath { get; init; }
}

View File

@@ -0,0 +1,6 @@
namespace NetAdmin.Infrastructure.Configuration.Options;
/// <summary>
/// 选项抽象基类
/// </summary>
public abstract record OptionAbstraction : IConfigurableOptions;

View File

@@ -0,0 +1,12 @@
namespace NetAdmin.Infrastructure.Configuration.Options;
/// <summary>
/// Redis配置
/// </summary>
public sealed record RedisOptions : OptionAbstraction
{
/// <summary>
/// 实例列表
/// </summary>
public InstanceNode[] Instances { get; init; }
}

View File

@@ -0,0 +1,22 @@
namespace NetAdmin.Infrastructure.Configuration.Options.SubNodes.Redis;
/// <summary>
/// Redis实例
/// </summary>
public sealed record InstanceNode
{
/// <summary>
/// 链接字符串
/// </summary>
public string ConnStr { get; init; }
/// <summary>
/// 数据库
/// </summary>
public int Database { get; set; }
/// <summary>
/// 实例名称
/// </summary>
public string Name { get; set; }
}

View File

@@ -0,0 +1,37 @@
namespace NetAdmin.Infrastructure.Configuration.Options.SubNodes.Upload;
/// <summary>
/// Minio 节点
/// </summary>
public sealed record MinioNode
{
/// <summary>
/// 访问令牌
/// </summary>
public string AccessKey { get; init; }
/// <summary>
/// 文件访问Url地址
/// </summary>
public string AccessUrl { get; init; }
/// <summary>
/// 使用的存储桶名称
/// </summary>
public string BucketName { get; init; }
/// <summary>
/// 安全码
/// </summary>
public string SecretKey { get; init; }
/// <summary>
/// 是否启用ssl
/// </summary>
public bool Secure { get; init; }
/// <summary>
/// 服务器地址
/// </summary>
public string ServerAddress { get; init; }
}

View File

@@ -0,0 +1,22 @@
namespace NetAdmin.Infrastructure.Configuration.Options;
/// <summary>
/// 上传配置
/// </summary>
public sealed record UploadOptions : OptionAbstraction
{
/// <summary>
/// 允许的文件类型
/// </summary>
public IReadOnlyCollection<string> ContentTypes { get; init; }
/// <summary>
/// 允许的文件大小(字节)
/// </summary>
public long MaxSize { get; init; }
/// <summary>
/// Minio 配置
/// </summary>
public MinioNode Minio { get; init; }
}