feat: 框架代码同步 (#178)

Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
2024-10-14 13:55:53 +08:00
committed by GitHub
parent dfe6b03b21
commit 58e4572723
185 changed files with 4732 additions and 1086 deletions

View File

@@ -6,13 +6,13 @@ namespace NetAdmin.Domain.Dto.Sys.Cache;
public sealed record CacheStatisticsRsp : DataAbstraction
{
private static readonly Regex[] _regexes = [
new Regex(@"keyspace_hits:(\d+)", RegexOptions.Compiled) //
, new Regex(@"keyspace_misses:(\d+)", RegexOptions.Compiled) //
, new Regex(@"uptime_in_seconds:(\d+)", RegexOptions.Compiled) //
, new Regex(@"used_cpu_sys:([\d\\.]+)", RegexOptions.Compiled) //
, new Regex(@"used_cpu_user:([\d\\.]+)", RegexOptions.Compiled) //
, new Regex(@"used_memory:(\d+)", RegexOptions.Compiled) //
, new Regex("redis_version:(.+)", RegexOptions.Compiled) //
new(@"keyspace_hits:(\d+)", RegexOptions.Compiled) //
, new(@"keyspace_misses:(\d+)", RegexOptions.Compiled) //
, new(@"uptime_in_seconds:(\d+)", RegexOptions.Compiled) //
, new(@"used_cpu_sys:([\d\\.]+)", RegexOptions.Compiled) //
, new(@"used_cpu_user:([\d\\.]+)", RegexOptions.Compiled) //
, new(@"used_memory:(\d+)", RegexOptions.Compiled) //
, new("redis_version:(.+)", RegexOptions.Compiled) //
];
/// <summary>
@@ -25,13 +25,12 @@ public sealed record CacheStatisticsRsp : DataAbstraction
/// </summary>
public CacheStatisticsRsp(string redisResult)
{
KeyspaceHits = _regexes[0].Match(redisResult).Groups[1].Value.Trim().Int64Try(0);
KeyspaceHits = _regexes[0].Match(redisResult).Groups[1].Value.Trim().Int64Try(0);
KeyspaceMisses = _regexes[1].Match(redisResult).Groups[1].Value.Trim().Int64Try(0);
UpTime = _regexes[2].Match(redisResult).Groups[1].Value.Trim().Int64Try(0);
UsedCpu = _regexes[3].Match(redisResult).Groups[1].Value.Trim().DecTry(0) +
_regexes[4].Match(redisResult).Groups[1].Value.Trim().DecTry(0);
UpTime = _regexes[2].Match(redisResult).Groups[1].Value.Trim().Int64Try(0);
UsedCpu = _regexes[3].Match(redisResult).Groups[1].Value.Trim().DecTry(0) + _regexes[4].Match(redisResult).Groups[1].Value.Trim().DecTry(0);
UsedMemory = _regexes[5].Match(redisResult).Groups[1].Value.Trim().Int64Try(0);
Version = _regexes[6].Match(redisResult).Groups[1].Value.Trim();
Version = _regexes[6].Match(redisResult).Groups[1].Value.Trim();
}
/// <summary>

View File

@@ -10,13 +10,21 @@ public record CreateDicContentReq : Sys_DicContent
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.字典目录编号不能为空))]
public override long CatalogId { get; init; }
/// <inheritdoc cref="Sys_DicContent.Key" />
/// <inheritdoc cref="IFieldEnabled.Enabled" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override bool Enabled { get; init; } = true;
/// <inheritdoc cref="Sys_DicContent.Key" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.键名称不能为空))]
public override string Key { get; init; }
/// <inheritdoc cref="Sys_DicContent.Summary" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string Summary { get; init; }
/// <inheritdoc cref="Sys_DicContent.Value" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.键值不能为空))]
public override string Value { get; init; }
}

View File

@@ -11,12 +11,24 @@ public sealed record ExportDicContentRsp : QueryDicContentRsp
[CsvName(nameof(Ln.创建时间))]
public override DateTime CreatedTime { get; init; }
/// <inheritdoc />
[CsvIndex(3)]
[CsvIgnore(false)]
[CsvName(nameof(Ln.是否启用))]
public override bool Enabled { get; init; }
/// <inheritdoc />
[CsvIndex(0)]
[CsvIgnore(false)]
[CsvName(nameof(Ln.项名))]
public override string Key { get; init; }
/// <inheritdoc />
[CsvIndex(4)]
[CsvIgnore(false)]
[CsvName(nameof(Ln.备注))]
public override string Summary { get; init; }
/// <inheritdoc />
[CsvIndex(1)]
[CsvIgnore(false)]

View File

@@ -13,10 +13,18 @@ public record QueryDicContentRsp : Sys_DicContent
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override DateTime CreatedTime { get; init; }
/// <inheritdoc cref="IFieldEnabled.Enabled" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override bool Enabled { get; init; }
/// <inheritdoc cref="Sys_DicContent.Key" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string Key { get; init; }
/// <inheritdoc cref="Sys_DicContent.Summary" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string Summary { get; init; }
/// <inheritdoc cref="Sys_DicContent.Value" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string Value { get; init; }

View File

@@ -0,0 +1,15 @@
namespace NetAdmin.Domain.Dto.Sys.Dic.Content;
/// <summary>
/// 请求:设置字典内容启用状态
/// </summary>
public sealed record SetDicContentEnabledReq : Sys_DicContent
{
/// <inheritdoc cref="IFieldEnabled.Enabled" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override bool Enabled { get; init; }
/// <inheritdoc cref="IFieldVersion.Version" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override long Version { get; init; }
}

View File

@@ -19,8 +19,7 @@ public record CreateJobReq : Sys_Job
public override string ExecutionCron { get; init; }
/// <inheritdoc cref="Sys_Job.HttpMethod" />
[EnumDataType(typeof(HttpMethods), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.请求方法不正确))]
[EnumDataType(typeof(HttpMethods), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.请求方法不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override HttpMethods HttpMethod { get; init; }

View File

@@ -15,8 +15,7 @@ public record QueryJobRsp : Sys_Job
/// Cron 表达式描述
/// </summary>
[JsonInclude]
public string CronDescription =>
ExpressionDescriptor.GetDescription(ExecutionCron, new Options { Locale = "zh-CN" });
public string CronDescription => ExpressionDescriptor.GetDescription(ExecutionCron, new Options { Locale = "zh-CN" });
/// <inheritdoc cref="Sys_Job.LastStatusCode" />
[JsonInclude]

View File

@@ -15,8 +15,7 @@ public sealed record MetaInfo : DataAbstraction
/// <summary>
/// Initializes a new instance of the <see cref="MetaInfo" /> class.
/// </summary>
public MetaInfo(string color, bool fullPage, bool hidden, bool hiddenBreadCrumb, string icon, string tag
, string title, MenuTypes type)
public MetaInfo(string color, bool fullPage, bool hidden, bool hiddenBreadCrumb, string icon, string tag, string title, MenuTypes type)
{
Color = color;
FullPage = fullPage;
@@ -73,8 +72,7 @@ public sealed record MetaInfo : DataAbstraction
/// <summary>
/// 类型
/// </summary>
[EnumDataType(typeof(MenuTypes), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.菜单类型不正确))]
[EnumDataType(typeof(MenuTypes), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.菜单类型不正确))]
[JsonInclude]
public MenuTypes Type { get; init; }
}

View File

@@ -18,8 +18,7 @@ public record CreateRoleReq : Sys_Role, IValidatableObject
public override string DashboardLayout { get; set; }
/// <inheritdoc cref="Sys_Role.DataScope" />
[EnumDataType(typeof(DataScopes), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.角色数据范围不正确))]
[EnumDataType(typeof(DataScopes), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.角色数据范围不正确))]
public override DataScopes DataScope { get; init; } = DataScopes.All;
/// <summary>

View File

@@ -20,8 +20,7 @@ public record CreateSiteMsgReq : Sys_SiteMsg
public IReadOnlyCollection<long> DeptIds { get; init; }
/// <inheritdoc cref="Sys_SiteMsg.MsgType" />
[EnumDataType(typeof(SiteMsgTypes), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.站内信类型不正确))]
[EnumDataType(typeof(SiteMsgTypes), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.站内信类型不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override SiteMsgTypes MsgType { get; init; }

View File

@@ -12,8 +12,7 @@ public record CreateSiteMsgFlagReq : Sys_SiteMsgFlag
public override long SiteMsgId { get; init; }
/// <inheritdoc cref="Sys_SiteMsgFlag.UserSiteMsgStatus" />
[EnumDataType(typeof(UserSiteMsgStatues), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.站内信状态不正确))]
[EnumDataType(typeof(UserSiteMsgStatues), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.站内信状态不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override UserSiteMsgStatues UserSiteMsgStatus { get; init; }
}

View File

@@ -0,0 +1,12 @@
namespace NetAdmin.Domain.Dto.Sys.Tool;
/// <summary>
/// 请求Aes解密
/// </summary>
public record AesDecodeReq : DataAbstraction
{
/// <summary>
/// 密文
/// </summary>
public string CipherText { get; init; }
}

View File

@@ -16,6 +16,14 @@ public record QueryUserRsp : Sys_User
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override DateTime CreatedTime { get; init; }
/// <inheritdoc cref="IFieldCreatedUser.CreatedUserId" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override long? CreatedUserId { get; init; }
/// <inheritdoc cref="IFieldCreatedUser.CreatedUserName" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string CreatedUserName { get; init; }
/// <inheritdoc cref="Sys_User.Dept" />
public new virtual QueryDeptRsp Dept { get; init; }

View File

@@ -17,8 +17,7 @@ public record CreateUserProfileReq : Sys_UserProfile
public override string CertificateNumber { get; init; }
/// <inheritdoc cref="Sys_UserProfile.CertificateType" />
[EnumDataType(typeof(CertificateTypes), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.证件类型不正确))]
[EnumDataType(typeof(CertificateTypes), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.证件类型不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override CertificateTypes? CertificateType { get; init; }
@@ -39,8 +38,7 @@ public record CreateUserProfileReq : Sys_UserProfile
public override string CompanyTelephone { get; init; }
/// <inheritdoc cref="Sys_UserProfile.Education" />
[EnumDataType(typeof(Educations), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.学历不正确))]
[EnumDataType(typeof(Educations), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.学历不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override Educations? Education { get; init; }
@@ -82,8 +80,7 @@ public record CreateUserProfileReq : Sys_UserProfile
public override string HomeTelephone { get; init; }
/// <inheritdoc cref="Sys_UserProfile.MarriageStatus" />
[EnumDataType(typeof(MarriageStatues), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.婚姻状况不正确))]
[EnumDataType(typeof(MarriageStatues), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.婚姻状况不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override MarriageStatues? MarriageStatus { get; init; }
@@ -96,8 +93,7 @@ public record CreateUserProfileReq : Sys_UserProfile
public new CreateDicContentReq NationArea { get; init; }
/// <inheritdoc cref="Sys_UserProfile.PoliticalStatus" />
[EnumDataType(typeof(PoliticalStatues), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.政治面貌不正确))]
[EnumDataType(typeof(PoliticalStatues), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.政治面貌不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override PoliticalStatues? PoliticalStatus { get; init; }

View File

@@ -14,8 +14,7 @@ public sealed record SendVerifyCodeReq : Sys_VerifyCode, IValidatableObject
public override string DestDevice { get; init; }
/// <inheritdoc cref="Sys_VerifyCode.DeviceType" />
[EnumDataType(typeof(VerifyCodeDeviceTypes), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.验证码目标设备类型不正确))]
[EnumDataType(typeof(VerifyCodeDeviceTypes), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.验证码目标设备类型不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.设备类型不能为空))]
public override VerifyCodeDeviceTypes DeviceType { get; init; }
@@ -24,8 +23,7 @@ public sealed record SendVerifyCodeReq : Sys_VerifyCode, IValidatableObject
public override VerifyCodeStatues Status => VerifyCodeStatues.Waiting;
/// <inheritdoc cref="Sys_VerifyCode.Type" />
[EnumDataType(typeof(VerifyCodeTypes), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.验证码类型不正确))]
[EnumDataType(typeof(VerifyCodeTypes), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.验证码类型不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.验证码类型不能为空))]
public override VerifyCodeTypes Type { get; init; }
@@ -43,22 +41,20 @@ public sealed record SendVerifyCodeReq : Sys_VerifyCode, IValidatableObject
switch (DeviceType) {
case VerifyCodeDeviceTypes.Email:
validationResult = new EmailAttribute().GetValidationResult(DestDevice, validationContext);
if (validationResult == null) {
yield break;
}
yield return new ValidationResult(validationResult.ErrorMessage, new[] { nameof(DestDevice) });
break;
case VerifyCodeDeviceTypes.Mobile:
validationResult = new MobileAttribute().GetValidationResult(DestDevice, validationContext);
if (validationResult == null) {
yield break;
}
yield return new ValidationResult(validationResult.ErrorMessage, new[] { nameof(DestDevice) });
break;
default:
yield break;
}
if (validationResult == null) {
yield break;
}
yield return new ValidationResult(validationResult.ErrorMessage, [nameof(DestDevice)]);
}
}