diff --git a/resources/ProjectPathUtil.cs b/resources/ProjectPathUtil.cs index 4eb8317d3..d8d899c18 100644 --- a/resources/ProjectPathUtil.cs +++ b/resources/ProjectPathUtil.cs @@ -1,104 +1,102 @@ -using System.IO; -using System.Linq; +namespace System; -namespace System +public static partial class ProjectPathUtil { - public static partial class ProjectPathUtil +#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter + public static readonly string projPath; +#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter + + public const string ProjectDir_AvaloniaAppBridge = "ST.Client.Desktop.Avalonia.App.Bridge"; + public const string ProjectDir_ConsoleAppBridge = "ST.Client.Desktop.Console.App.Bridge"; + public const string ProjectDir_ConsoleAppBridgePackage = "ST.Client.Desktop.Avalonia.App.Bridge.Package"; + public const string ProjectDir_AvaloniaApp = "ST.Client.Desktop.Avalonia.App"; + public const string ProjectDir_Win7Troubleshoot = "ST.Tools.Win7Troubleshoot"; + public const string ProjectDir_CoreLib = "Common.CoreLib"; + public const string ProjectDir_ClienDroidLib = "Common.ClientLib.Droid"; + public const string ProjectDir_ClientDesktop = "ST.Client.Desktop"; + public const string ProjectDir_ST = "ST"; + public const string ProjectDir_STClient = "ST.Client"; + + public const string release_template_md = + @"\release-template.md"; + + [Obsolete("use MainDllPath_", true)] + public const string MainDllPath = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Steam++.dll"; + + public const string MainDllPath_ = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Steam++.dll"; + + [Obsolete("use DirPublishWinX86_")] + public const string DirPublishWinX86 = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Publish\win-x86"; + + public const string DirPublishWinX86_ = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Publish\win-x86"; + + [Obsolete("use DirPublishWinX64_", true)] + public const string DirPublishWinX64 = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Publish\win-x64"; + + [Obsolete("use DirPublishWinX64_FDE_", true)] + public const string DirPublishWinX64_FDE = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Publish\FrameworkDependent\win-x64"; + + public const string DirPublishWinX64_ = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Publish\win-x64"; + + public const string DirPublishOsx = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Publish\{0}"; + + public const string DirPublishWinX64_FDE_ = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Publish\FrameworkDependent\win-x64"; + + [Obsolete("use DirPublish_", true)] + public const string DirPublish = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Publish"; + + public const string DirPublish_ = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Publish"; + + public const string DirPublish_FDE_ = + @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Publish\FrameworkDependent"; + + //public const string DirPublish_Win7Troubleshoot = + // @"\src\" + ProjectDir_Win7Troubleshoot + @"\bin\Release\Publish\net35"; + + static ProjectPathUtil() { - public static readonly string projPath; - - public const string ProjectDir_AvaloniaAppBridge = "ST.Client.Desktop.Avalonia.App.Bridge"; - public const string ProjectDir_ConsoleAppBridge = "ST.Client.Desktop.Console.App.Bridge"; - public const string ProjectDir_ConsoleAppBridgePackage = "ST.Client.Desktop.Avalonia.App.Bridge.Package"; - public const string ProjectDir_AvaloniaApp = "ST.Client.Desktop.Avalonia.App"; - public const string ProjectDir_Win7Troubleshoot = "ST.Tools.Win7Troubleshoot"; - public const string ProjectDir_CoreLib = "Common.CoreLib"; - public const string ProjectDir_ClienDroidLib = "Common.ClientLib.Droid"; - public const string ProjectDir_ClientDesktop = "ST.Client.Desktop"; - public const string ProjectDir_ST = "ST"; - public const string ProjectDir_STClient = "ST.Client"; - - public const string release_template_md = - @"\release-template.md"; - - [Obsolete("use MainDllPath_", true)] - public const string MainDllPath = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Steam++.dll"; - - public const string MainDllPath_ = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Steam++.dll"; - - [Obsolete("use DirPublishWinX86_")] - public const string DirPublishWinX86 = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Publish\win-x86"; - - public const string DirPublishWinX86_ = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Publish\win-x86"; - - [Obsolete("use DirPublishWinX64_", true)] - public const string DirPublishWinX64 = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Publish\win-x64"; - - [Obsolete("use DirPublishWinX64_FDE_", true)] - public const string DirPublishWinX64_FDE = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Publish\FrameworkDependent\win-x64"; - - public const string DirPublishWinX64_ = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Publish\win-x64"; - - public const string DirPublishOsx = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Publish\{0}"; - - public const string DirPublishWinX64_FDE_ = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Publish\FrameworkDependent\win-x64"; - - [Obsolete("use DirPublish_", true)] - public const string DirPublish = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\Release\Publish"; - - public const string DirPublish_ = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Publish"; - - public const string DirPublish_FDE_ = - @"\src\" + ProjectDir_AvaloniaApp + @"\bin\{0}\Publish\FrameworkDependent"; - - //public const string DirPublish_Win7Troubleshoot = - // @"\src\" + ProjectDir_Win7Troubleshoot + @"\bin\Release\Publish\net35"; - - static ProjectPathUtil() + projPath = GetProjectPath(); + if (!Directory.Exists(Path.Combine(projPath, ProjectDir_AvaloniaApp))) { - projPath = GetProjectPath(); - if (!Directory.Exists(Path.Combine(projPath, ProjectDir_AvaloniaApp))) - { - projPath = GetProjectPathByServerTool(); - } - } - - /// - /// 获取当前项目绝对路径(.sln文件所在目录) - /// - /// - /// - static string GetProjectPath(string? path = null) - { - path ??= AppContext.BaseDirectory; - if (!Directory.GetFiles(path, "*.sln").Any()) - { - var parent = Directory.GetParent(path); - if (parent == null) return string.Empty; - return GetProjectPath(parent.FullName); - } - return path; - } - - /// - /// 获取公开客户端项目绝对路径,仅供服务端工具项目中使用 - /// - /// - static string GetProjectPathByServerTool() - { - var projPath_ = GetProjectPath(); - return Path.GetFullPath(Path.Combine(projPath_, "..", "SteamTools")); + projPath = GetProjectPathByServerTool(); } } + + /// + /// 获取当前项目绝对路径(.sln文件所在目录) + /// + /// + /// + static string GetProjectPath(string? path = null) + { + path ??= AppContext.BaseDirectory; + if (!Directory.GetFiles(path, "*.sln").Any()) + { + var parent = Directory.GetParent(path); + if (parent == null) return string.Empty; + return GetProjectPath(parent.FullName); + } + return path; + } + + /// + /// 获取公开客户端项目绝对路径,仅供服务端工具项目中使用 + /// + /// + static string GetProjectPathByServerTool() + { + var projPath_ = GetProjectPath(); + return Path.GetFullPath(Path.Combine(projPath_, "..", "SteamTools")); + } } \ No newline at end of file diff --git a/src/Common.ClientLib/Application/Essentials/Browser2.isx.cs b/src/Common.ClientLib/Application/Essentials/Browser2.isx.cs index ac5ed18f6..19a134180 100644 --- a/src/Common.ClientLib/Application/Essentials/Browser2.isx.cs +++ b/src/Common.ClientLib/Application/Essentials/Browser2.isx.cs @@ -1,40 +1,39 @@ using System.Diagnostics.CodeAnalysis; // ReSharper disable once CheckNamespace -namespace System.Application +namespace System.Application; + +partial class Browser2 { - partial class Browser2 - { - public const string Prefix_HTTPS = "https://"; + public const string Prefix_HTTPS = "https://"; - public const string Prefix_HTTP = "http://"; + public const string Prefix_HTTP = "http://"; - public const string Prefix_MSStore = "ms-windows-store://"; + public const string Prefix_MSStore = "ms-windows-store://"; - public const string Prefix_Email = "mailto:"; + public const string Prefix_Email = "mailto:"; - /// - /// 判断字符串是否为 Http Url - /// - /// - /// 是否仅Https - /// - public static bool IsHttpUrl([NotNullWhen(true)] string? url, bool httpsOnly = false) => url != null && - (url.StartsWith(Prefix_HTTPS, StringComparison.OrdinalIgnoreCase) || - (!httpsOnly && url.StartsWith(Prefix_HTTP, StringComparison.OrdinalIgnoreCase))); + /// + /// 判断字符串是否为 Http Url + /// + /// + /// 是否仅Https + /// + public static bool IsHttpUrl([NotNullWhen(true)] string? url, bool httpsOnly = false) => url != null && + (url.StartsWith(Prefix_HTTPS, StringComparison.OrdinalIgnoreCase) || + (!httpsOnly && url.StartsWith(Prefix_HTTP, StringComparison.OrdinalIgnoreCase))); - /// - /// 判断字符串是否为 Store Url - /// - /// - /// - public static bool IsStoreUrl([NotNullWhen(true)] string? url) => url != null && url.StartsWith(Prefix_MSStore, StringComparison.OrdinalIgnoreCase); + /// + /// 判断字符串是否为 Store Url + /// + /// + /// + public static bool IsStoreUrl([NotNullWhen(true)] string? url) => url != null && url.StartsWith(Prefix_MSStore, StringComparison.OrdinalIgnoreCase); - /// - /// 判断字符串是否为 Email Url - /// - /// - /// - public static bool IsEmailUrl([NotNullWhen(true)] string? url) => url != null && url.StartsWith(Prefix_Email, StringComparison.OrdinalIgnoreCase); - } + /// + /// 判断字符串是否为 Email Url + /// + /// + /// + public static bool IsEmailUrl([NotNullWhen(true)] string? url) => url != null && url.StartsWith(Prefix_Email, StringComparison.OrdinalIgnoreCase); } \ No newline at end of file diff --git a/src/Common.CoreLib/Application/Repositories/IRepository.cs b/src/Common.CoreLib/Application/Repositories/IRepository.cs index 9321c6306..91d1e997c 100644 --- a/src/Common.CoreLib/Application/Repositories/IRepository.cs +++ b/src/Common.CoreLib/Application/Repositories/IRepository.cs @@ -52,6 +52,8 @@ namespace System.Application.Repositories /// 受影响的行数 Task InsertAsync(TEntity entity); + Task InsertAsync(TEntity entity, CancellationToken cancellationToken) => InsertAsync(entity); + /// /// 将多个实体插入到数据库中 /// @@ -59,6 +61,8 @@ namespace System.Application.Repositories /// 受影响的行数 public Task InsertRangeAsync(IEnumerable entities) => OperateRangeAsync(entities, InsertAsync); + public Task InsertRangeAsync(IEnumerable entities, CancellationToken cancellationToken) => InsertRangeAsync(entities); + /// public Task InsertRangeAsync(params TEntity[] entities) => InsertRangeAsync(entities.AsEnumerable()); @@ -73,6 +77,8 @@ namespace System.Application.Repositories /// 受影响的行数 Task DeleteAsync(TEntity entity); + Task DeleteAsync(TEntity entity, CancellationToken cancellationToken) => DeleteAsync(entity); + /// /// 将多个实体从数据库中删除 /// @@ -80,6 +86,8 @@ namespace System.Application.Repositories /// 受影响的行数 public Task DeleteRangeAsync(IEnumerable entities) => OperateRangeAsync(entities, DeleteAsync); + public Task DeleteRangeAsync(IEnumerable entities, CancellationToken cancellationToken) => DeleteRangeAsync(entities); + /// public Task DeleteRangeAsync(params TEntity[] entities) => DeleteRangeAsync(entities.AsEnumerable()); @@ -94,6 +102,8 @@ namespace System.Application.Repositories /// 受影响的行数 Task UpdateAsync(TEntity entity); + Task UpdateAsync(TEntity entity, CancellationToken cancellationToken) => UpdateAsync(entity); + /// /// 将多个实体更新到数据库中 /// @@ -101,6 +111,8 @@ namespace System.Application.Repositories /// 受影响的行数 public Task UpdateRangeAsync(IEnumerable entities) => OperateRangeAsync(entities, UpdateAsync); + public Task UpdateRangeAsync(IEnumerable entities, CancellationToken cancellationToken) => UpdateRangeAsync(entities); + /// public Task UpdateRangeAsync(params TEntity[] entities) => UpdateRangeAsync(entities.AsEnumerable()); diff --git a/src/Common.CoreLib/Properties/AssemblyInfo.Version.cs b/src/Common.CoreLib/Properties/AssemblyInfo.Version.cs index a07566c74..a748d9a07 100644 --- a/src/Common.CoreLib/Properties/AssemblyInfo.Version.cs +++ b/src/Common.CoreLib/Properties/AssemblyInfo.Version.cs @@ -1,6 +1,6 @@ using System.Reflection; -using static System.Properties.ThisAssembly; +using _ThisAssembly = System.Properties.ThisAssembly; -[assembly: AssemblyFileVersion(Version)] -//[assembly: AssemblyInformationalVersion(InfoVersion)] -[assembly: AssemblyVersion(Version)] \ No newline at end of file +[assembly: AssemblyFileVersion(_ThisAssembly.Version)] +//[assembly: AssemblyInformationalVersion(_ThisAssembly.InfoVersion)] +[assembly: AssemblyVersion(_ThisAssembly.Version)] \ No newline at end of file diff --git a/src/Common.CoreLib/Properties/ThisAssembly.cs b/src/Common.CoreLib/Properties/ThisAssembly.cs index 75eeb7a61..1e8bc9ec8 100644 --- a/src/Common.CoreLib/Properties/ThisAssembly.cs +++ b/src/Common.CoreLib/Properties/ThisAssembly.cs @@ -1,49 +1,48 @@ -namespace System.Properties +namespace System.Properties; + +public static partial class ThisAssembly { - public static partial class ThisAssembly - { - /// - /// 定义程序集清单的产品名自定义属性 - /// - public const string AssemblyProduct = "Watt Toolkit"; + /// + /// 定义程序集清单的产品名自定义属性 + /// + public const string AssemblyProduct = "Watt Toolkit"; - /// - /// 定义程序集清单的商标自定义属性 - /// - public const string AssemblyTrademark = "Watt Toolkit"; + /// + /// 定义程序集清单的商标自定义属性 + /// + public const string AssemblyTrademark = "Watt Toolkit"; - /// - /// 提供程序集的文本说明 - /// - public const string AssemblyDescription = "「Watt Toolkit」是一个开源跨平台的多功能游戏工具箱。"; + /// + /// 提供程序集的文本说明 + /// + public const string AssemblyDescription = "「Watt Toolkit」是一个开源跨平台的多功能游戏工具箱。"; - /// - /// 定义程序集清单的版权自定义属性 - /// - public const string AssemblyCopyright = "© 长沙次元超越科技有限公司. All rights reserved."; + /// + /// 定义程序集清单的版权自定义属性 + /// + public const string AssemblyCopyright = "© 长沙次元超越科技有限公司. All rights reserved."; - /// - /// 定义程序集清单的公司名称自定义属性 - /// - public const string AssemblyCompany = "长沙次元超越科技有限公司"; + /// + /// 定义程序集清单的公司名称自定义属性 + /// + public const string AssemblyCompany = "长沙次元超越科技有限公司"; - public const string PublicKey = + public const string PublicKey = #if SIGN_ASSEMBLY - ", PublicKey=" + - "002400000480000094000000060200000024000052534131000400000100010029b4f7706cbb7e23b3cf33be41127d4b" + - "12c14a77cc1094412e73ccbbea4fbc873883042b5a9e517df99137f31f610624f79b46980bcceb990db3caa619fbbb31989f" + - "5b6db3689d99ff1f70cb9bc20cc4d548beb942e09859cf2c0690683c9ad160a4a7287070e9e49795c75ba3d12723ddb4" + - "ddeb11d32f193e0882db10b41de3"; + ", PublicKey=" + + "002400000480000094000000060200000024000052534131000400000100010029b4f7706cbb7e23b3cf33be41127d4b" + + "12c14a77cc1094412e73ccbbea4fbc873883042b5a9e517df99137f31f610624f79b46980bcceb990db3caa619fbbb31989f" + + "5b6db3689d99ff1f70cb9bc20cc4d548beb942e09859cf2c0690683c9ad160a4a7287070e9e49795c75ba3d12723ddb4" + + "ddeb11d32f193e0882db10b41de3"; #else - ""; + ""; #endif - public const bool Debuggable = + public const bool Debuggable = #if DEBUG true #else false #endif - ; - } + ; } \ No newline at end of file diff --git a/src/Common.ServerLib/Application/Data/IdentityTableNames.cs b/src/Common.ServerLib/Application/Data/IdentityTableNames.cs index 38f9ec9af..2847e4845 100644 --- a/src/Common.ServerLib/Application/Data/IdentityTableNames.cs +++ b/src/Common.ServerLib/Application/Data/IdentityTableNames.cs @@ -1,33 +1,32 @@ -using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; -namespace System.Application.Data -{ - public static class IdentityTableNames - { - const string Users = "Users"; - const string Roles = "Roles"; - const string RoleClaims = "RoleClaims"; - const string UserClaims = "UserClaims"; - const string UserLogins = "UserLogins"; - const string UserRoles = "UserRoles"; - const string UserTokens = "UserTokens"; +namespace System.Application.Data; - public static void ReNameAspNetIdentity(this ModelBuilder builder, - string? tablePrefix = null) - where TUser : IdentityUser - where TRole : IdentityRole - where TKey : IEquatable - { - var hasTablePrefix = !string.IsNullOrEmpty(tablePrefix); - string GetString(string str) => hasTablePrefix ? tablePrefix + str : str; - builder.Entity().ToTable(GetString(Users)); - builder.Entity().ToTable(GetString(Roles)); - builder.Entity>().ToTable(GetString(RoleClaims)); - builder.Entity>().ToTable(GetString(UserClaims)); - builder.Entity>().ToTable(GetString(UserLogins)); - builder.Entity>().ToTable(GetString(UserRoles)); - builder.Entity>().ToTable(GetString(UserTokens)); - } +public static class IdentityTableNames +{ + const string Users = "Users"; + const string Roles = "Roles"; + const string RoleClaims = "RoleClaims"; + const string UserClaims = "UserClaims"; + const string UserLogins = "UserLogins"; + const string UserRoles = "UserRoles"; + const string UserTokens = "UserTokens"; + + public static void ReNameAspNetIdentity(this ModelBuilder builder, + string? tablePrefix = null) + where TUser : IdentityUser + where TRole : IdentityRole + where TKey : IEquatable + { + var hasTablePrefix = !string.IsNullOrEmpty(tablePrefix); + string GetString(string str) => hasTablePrefix ? tablePrefix + str : str; + builder.Entity().ToTable(GetString(Users)); + builder.Entity().ToTable(GetString(Roles)); + builder.Entity>().ToTable(GetString(RoleClaims)); + builder.Entity>().ToTable(GetString(UserClaims)); + builder.Entity>().ToTable(GetString(UserLogins)); + builder.Entity>().ToTable(GetString(UserRoles)); + builder.Entity>().ToTable(GetString(UserTokens)); } } \ No newline at end of file diff --git a/src/Common.ServerLib/Application/Entities/Abstractions/IImage.cs b/src/Common.ServerLib/Application/Entities/Abstractions/IImage.cs index ba908c70e..4421f0203 100644 --- a/src/Common.ServerLib/Application/Entities/Abstractions/IImage.cs +++ b/src/Common.ServerLib/Application/Entities/Abstractions/IImage.cs @@ -1,36 +1,35 @@ using System.IO.FileFormats; using System.Application.Columns; -namespace System.Application.Entities.Abstractions +namespace System.Application.Entities.Abstractions; + +public interface IImage : IEntity, ISoftDeleted { - public interface IImage : IEntity, ISoftDeleted - { - ImageFormat Type { get; set; } + ImageFormat Type { get; set; } - /// - /// 文件大小 - /// - long Size { get; set; } + /// + /// 文件大小 + /// + long Size { get; set; } - /// - /// 图片宽度 - /// - int Width { get; set; } + /// + /// 图片宽度 + /// + int Width { get; set; } - /// - /// 图片高度 - /// - int Height { get; set; } + /// + /// 图片高度 + /// + int Height { get; set; } - /// - /// 哈希值(SHA384) - /// - string SHA384 { get; set; } + /// + /// 哈希值(SHA384) + /// + string SHA384 { get; set; } - /// - /// 获取文件名 - /// - /// - string GetFileName(); - } + /// + /// 获取文件名 + /// + /// + string GetFileName(); } \ No newline at end of file diff --git a/src/Common.ServerLib/Application/Entities/Abstractions/IUser.cs b/src/Common.ServerLib/Application/Entities/Abstractions/IUser.cs index 612ae1875..38e45f05a 100644 --- a/src/Common.ServerLib/Application/Entities/Abstractions/IUser.cs +++ b/src/Common.ServerLib/Application/Entities/Abstractions/IUser.cs @@ -1,20 +1,19 @@ -namespace System.Application.Entities.Abstractions +namespace System.Application.Entities.Abstractions; + +public interface IUser : IEntity { - public interface IUser : IEntity - { - /// - /// 昵称 - /// - string? NickName { get; set; } + /// + /// 昵称 + /// + string? NickName { get; set; } - /// - /// 用户名 - /// - string? UserName { get; set; } + /// + /// 用户名 + /// + string? UserName { get; set; } - /// - /// 封禁到解封日期 - /// - DateTimeOffset? BanEnd { get; set; } - } + /// + /// 封禁到解封日期 + /// + DateTimeOffset? BanEnd { get; set; } } \ No newline at end of file diff --git a/src/Common.ServerLib/Application/Entities/AuthMessageRecord.cs b/src/Common.ServerLib/Application/Entities/AuthMessageRecord.cs index bffcc5538..c018cd77d 100644 --- a/src/Common.ServerLib/Application/Entities/AuthMessageRecord.cs +++ b/src/Common.ServerLib/Application/Entities/AuthMessageRecord.cs @@ -1,108 +1,107 @@ using System.Application.Columns; using System.ComponentModel.DataAnnotations; -namespace System.Application.Entities +namespace System.Application.Entities; + +/// +/// 验证码纪录表(短信或邮箱) +/// +/// +/// +public class AuthMessageRecord : IEntity, ICreationTime + where TSendSmsRequestType : struct, Enum + where TEAuthMessageType : struct, Enum { + [Key] // EF 主键 + public Guid Id { get; set; } + /// - /// 验证码纪录表(短信或邮箱) + /// 创建时间 /// - /// - /// - public class AuthMessageRecord : IEntity, ICreationTime - where TSendSmsRequestType : struct, Enum - where TAuthMessageType : struct, Enum - { - [Key] // EF 主键 - public Guid Id { get; set; } + public DateTimeOffset CreationTime { get; set; } - /// - /// 创建时间 - /// - public DateTimeOffset CreationTime { get; set; } + /// + /// 手机号(如果为短信验证码此字段必填) + /// + public string? PhoneNumber { get; set; } - /// - /// 手机号(如果为短信验证码此字段必填) - /// - public string? PhoneNumber { get; set; } + /// + /// 邮箱地址(如果为邮箱验证码此字段必填) + /// + public string? Email { get; set; } - /// - /// 邮箱地址(如果为邮箱验证码此字段必填) - /// - public string? Email { get; set; } + /// + /// 调用方IP地址 + /// + [Required] // EF not null + public string IPAddress { get; set; } = string.Empty; - /// - /// 调用方IP地址 - /// - [Required] // EF not null - public string IPAddress { get; set; } = string.Empty; + #region 提供商内容 - #region 提供商内容 + /// + /// 第三方下发渠道的显示名称 + /// 比如网易/阿里云 + /// + [Required] // EF not null + public string Channel { get; set; } = string.Empty; - /// - /// 第三方下发渠道的显示名称 - /// 比如网易/阿里云 - /// - [Required] // EF not null - public string Channel { get; set; } = string.Empty; + /// + /// 第三方提供商返回的内容 + /// + public string? SendResultRecord { get; set; } - /// - /// 第三方提供商返回的内容 - /// - public string? SendResultRecord { get; set; } + /// + /// 第三方提供商返回的HTTP状态码 + /// + public int HttpStatusCode { get; set; } - /// - /// 第三方提供商返回的HTTP状态码 - /// - public int HttpStatusCode { get; set; } + /// + /// 第三方提供商发送是否成功 + /// 通常从调用第三方接口返回的JSON中获取状态码判定是否成功 + /// + public bool SendIsSuccess { get; set; } - /// - /// 第三方提供商发送是否成功 - /// 通常从调用第三方接口返回的JSON中获取状态码判定是否成功 - /// - public bool SendIsSuccess { get; set; } + #endregion - #endregion + /// + /// 内容(短信验证码或邮箱验证码的内容) + /// 短信内容通常仅含有验证码数字,不包括其他的提示语文字 + /// + [Required] // EF not null + public string Content { get; set; } = string.Empty; - /// - /// 内容(短信验证码或邮箱验证码的内容) - /// 短信内容通常仅含有验证码数字,不包括其他的提示语文字 - /// - [Required] // EF not null - public string Content { get; set; } = string.Empty; + /// + /// 是否校验过 + /// + public bool EverCheck { get; set; } - /// - /// 是否校验过 - /// - public bool EverCheck { get; set; } + /// + /// 是否校验成功 + /// + public bool CheckSuccess { get; set; } - /// - /// 是否校验成功 - /// - public bool CheckSuccess { get; set; } + /// + /// 是否被废弃 + /// + public bool Abandoned { get; set; } - /// - /// 是否被废弃 - /// - public bool Abandoned { get; set; } + /// + /// 校验失败次数 + /// + public int CheckFailuresCount { get; set; } - /// - /// 校验失败次数 - /// - public int CheckFailuresCount { get; set; } + /// + /// 类型 是属于邮箱验证还是短信验证 + /// + public TEAuthMessageType Type { get; set; } - /// - /// 类型 是属于邮箱验证还是短信验证 - /// - public TAuthMessageType Type { get; set; } + /// + /// 发送验证码用途 + /// + public TSendSmsRequestType RequestType { get; set; } - /// - /// 发送验证码用途 - /// - public TSendSmsRequestType RequestType { get; set; } - - /// - /// 所属用户Id - /// - public Guid? UserId { get; set; } - } + /// + /// 所属用户Id + /// + public Guid? UserId { get; set; } } \ No newline at end of file diff --git a/src/Common.ServerLib/Application/Entities/Image.cs b/src/Common.ServerLib/Application/Entities/Image.cs index 8743fcf0e..e6143adc9 100644 --- a/src/Common.ServerLib/Application/Entities/Image.cs +++ b/src/Common.ServerLib/Application/Entities/Image.cs @@ -7,47 +7,46 @@ using System.Diagnostics; using System.IO.FileFormats; using System.Security.Cryptography; -namespace System.Application.Entities +namespace System.Application.Entities; + +/// +/// 图片表 +/// +[Table("Images")] +[DebuggerDisplay("{DebuggerDisplay(),nq}")] +public class Image : IImage, INEWSEQUENTIALID + where TUser : IUser + where TUploadImageType : struct, Enum { + string DebuggerDisplay() => $"{Id}, {Type}, {SHA384}"; + + [Key] // EF 主键 + public Guid Id { get; set; } + + public ImageFormat Type { get; set; } + + public long Size { get; set; } + + public int Width { get; set; } + + public int Height { get; set; } + + [Required] // EF not null + [MaxLength(Hashs.String.Lengths.SHA384 + 3)] + [MinLength(Hashs.String.Lengths.SHA384)] + public string SHA384 { get; set; } = string.Empty; + + public bool SoftDeleted { get; set; } + /// - /// 图片表 + /// 上传纪录 /// - [Table("Images")] - [DebuggerDisplay("{DebuggerDisplay(),nq}")] - public class Image : IImage, INEWSEQUENTIALID - where TUser : IUser - where TUploadImageType : struct, Enum - { - string DebuggerDisplay() => $"{Id}, {Type}, {SHA384}"; + public virtual List>? Records { get; set; } - [Key] // EF 主键 - public Guid Id { get; set; } + public string GetFileName() => SHA384 + Type.GetExtension(); - public ImageFormat Type { get; set; } - - public long Size { get; set; } - - public int Width { get; set; } - - public int Height { get; set; } - - [Required] // EF not null - [MaxLength(Hashs.String.Lengths.SHA384 + 3)] - [MinLength(Hashs.String.Lengths.SHA384)] - public string SHA384 { get; set; } = string.Empty; - - public bool SoftDeleted { get; set; } - - /// - /// 上传纪录 - /// - public virtual List>? Records { get; set; } - - public string GetFileName() => SHA384 + Type.GetExtension(); - - /// - /// 创建时间 - /// - public DateTimeOffset CreationTime { get; set; } = DateTimeOffset.Now; - } + /// + /// 创建时间 + /// + public DateTimeOffset CreationTime { get; set; } = DateTimeOffset.Now; } \ No newline at end of file diff --git a/src/Common.ServerLib/Application/Entities/ImageUploadRecord.cs b/src/Common.ServerLib/Application/Entities/ImageUploadRecord.cs index 51b8dc2f7..c3d8be3f7 100644 --- a/src/Common.ServerLib/Application/Entities/ImageUploadRecord.cs +++ b/src/Common.ServerLib/Application/Entities/ImageUploadRecord.cs @@ -4,44 +4,43 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics; -namespace System.Application.Entities +namespace System.Application.Entities; + +/// +/// 图片上传纪录表 +/// +[Table("ImageUploadRecords")] +[DebuggerDisplay("{DebuggerDisplay(),nq}")] +public class ImageUploadRecord : INEWSEQUENTIALID, ICreationTime + where TUser : IUser + where TUploadImageType : struct, Enum { + string DebuggerDisplay() => $"{ImagesId}, {Type}, {User?.NickName ?? (UserId.ToString())}"; + + [Key] // EF 主键 + public Guid Id { get; set; } + /// - /// 图片上传纪录表 + /// 上传的用户ID /// - [Table("ImageUploadRecords")] - [DebuggerDisplay("{DebuggerDisplay(),nq}")] - public class ImageUploadRecord : INEWSEQUENTIALID, ICreationTime - where TUser : IUser - where TUploadImageType : struct, Enum - { - string DebuggerDisplay() => $"{ImagesId}, {Type}, {User?.NickName ?? (UserId.ToString())}"; + [Required] // EF not null + public Guid UserId { get; set; } - [Key] // EF 主键 - public Guid Id { get; set; } + /// + /// 上传的用户 + /// + public virtual TUser? User { get; set; } - /// - /// 上传的用户ID - /// - [Required] // EF not null - public Guid UserId { get; set; } + /// + /// 图片ID + /// + public Guid ImagesId { get; set; } - /// - /// 上传的用户 - /// - public virtual TUser? User { get; set; } + public DateTimeOffset CreationTime { get; set; } - /// - /// 图片ID - /// - public Guid ImagesId { get; set; } - - public DateTimeOffset CreationTime { get; set; } - - /// - /// 上传图片类型(用途) - /// - [Required] // EF not null - public TUploadImageType Type { get; set; } - } + /// + /// 上传图片类型(用途) + /// + [Required] // EF not null + public TUploadImageType Type { get; set; } } \ No newline at end of file diff --git a/src/Common.ServerLib/Application/Entities/KeyValuePair.cs b/src/Common.ServerLib/Application/Entities/KeyValuePair.cs index 3b4fc38da..7ccac690e 100644 --- a/src/Common.ServerLib/Application/Entities/KeyValuePair.cs +++ b/src/Common.ServerLib/Application/Entities/KeyValuePair.cs @@ -3,24 +3,23 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics; -namespace System.Application.Entities +namespace System.Application.Entities; + +/// +/// 键值对表 +/// https://stackoverflow.com/questions/514603/key-value-pairs-in-a-database-table +/// +[Table("KeyValuePairs")] +[DebuggerDisplay("{DebuggerDisplay(),nq}")] +public sealed class KeyValuePair : IEntity, ISoftDeleted { - /// - /// 键值对表 - /// https://stackoverflow.com/questions/514603/key-value-pairs-in-a-database-table - /// - [Table("KeyValuePairs")] - [DebuggerDisplay("{DebuggerDisplay(),nq}")] - public sealed class KeyValuePair : IEntity, ISoftDeleted - { - [Key] // EF 主键 - public string Id { get; set; } = string.Empty; + [Key] // EF 主键 + public string Id { get; set; } = string.Empty; - [Required] // EF not null - public string Value { get; set; } = string.Empty; + [Required] // EF not null + public string Value { get; set; } = string.Empty; - public bool SoftDeleted { get; set; } + public bool SoftDeleted { get; set; } - string DebuggerDisplay() => $"{Id}, {Value}"; - } + string DebuggerDisplay() => $"{Id}, {Value}"; } \ No newline at end of file diff --git a/src/Common.ServerLib/Application/Essentials/Browser2.cs b/src/Common.ServerLib/Application/Essentials/Browser2.cs index a842d06de..90ac311bb 100644 --- a/src/Common.ServerLib/Application/Essentials/Browser2.cs +++ b/src/Common.ServerLib/Application/Essentials/Browser2.cs @@ -1,13 +1,7 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - // ReSharper disable once CheckNamespace -namespace System.Application +namespace System.Application; + +public partial class Browser2 { - public partial class Browser2 - { - } } diff --git a/src/Common.ServerLib/Application/Filters/AddResponseHeadersAttribute.cs b/src/Common.ServerLib/Application/Filters/AddResponseHeadersAttribute.cs index 82ed45963..a3e82ce33 100644 --- a/src/Common.ServerLib/Application/Filters/AddResponseHeadersAttribute.cs +++ b/src/Common.ServerLib/Application/Filters/AddResponseHeadersAttribute.cs @@ -1,22 +1,21 @@ -using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.Filters; -namespace System.Application.Filters +namespace System.Application.Filters; + +/// +/// 添加额外响应头 +/// +public sealed class AddResponseHeadersAttribute : ActionFilterAttribute { - /// - /// 添加额外响应头 - /// - public sealed class AddResponseHeadersAttribute : ActionFilterAttribute + public override void OnResultExecuting(ResultExecutingContext context) { - public override void OnResultExecuting(ResultExecutingContext context) - { - /* https://developer.mozilla.org/zh-CN/docs/Web/HTTP/X-Frame-Options - * X-Frame-Options HTTP 响应头是用来给浏览器指示允许一个页面可否在 ,