提交代码

This commit is contained in:
zpc 2024-08-08 04:43:24 +08:00
parent fd67ec702c
commit b18eabb9fc
13 changed files with 183 additions and 20 deletions

View File

@ -44,9 +44,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HuanMeng.MiaoYu.Code", "src
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HuanMeng.MiaoYu.WebApi", "src\2-api\HuanMeng.MiaoYu.WebApi\HuanMeng.MiaoYu.WebApi.csproj", "{729950F2-71EE-42C0-8B46-295740DE20BA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HuanMeng.Utility", "src\0-core\HuanMeng.Utility\HuanMeng.Utility.csproj", "{48E1532F-8B50-477C-BB78-8AEA89A167CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextCensorFilterTest", "src\9-test\TextCensorFilterTest\TextCensorFilterTest.csproj", "{CF7FEDBA-FC1A-4D6D-92F1-6882B5143E0A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TextCensorFilterTest", "src\9-test\TextCensorFilterTest\TextCensorFilterTest.csproj", "{CF7FEDBA-FC1A-4D6D-92F1-6882B5143E0A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -94,10 +92,6 @@ Global
{729950F2-71EE-42C0-8B46-295740DE20BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{729950F2-71EE-42C0-8B46-295740DE20BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{729950F2-71EE-42C0-8B46-295740DE20BA}.Release|Any CPU.Build.0 = Release|Any CPU
{48E1532F-8B50-477C-BB78-8AEA89A167CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48E1532F-8B50-477C-BB78-8AEA89A167CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48E1532F-8B50-477C-BB78-8AEA89A167CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48E1532F-8B50-477C-BB78-8AEA89A167CE}.Release|Any CPU.Build.0 = Release|Any CPU
{CF7FEDBA-FC1A-4D6D-92F1-6882B5143E0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF7FEDBA-FC1A-4D6D-92F1-6882B5143E0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF7FEDBA-FC1A-4D6D-92F1-6882B5143E0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -124,7 +118,6 @@ Global
{B845C884-AD1A-4483-A2F6-B218DB14EA2D} = {DD14191F-22CE-48D8-A944-B8A41C97ACD4}
{6E79742F-1E56-4B7D-94E8-B509D43561FA} = {DD14191F-22CE-48D8-A944-B8A41C97ACD4}
{729950F2-71EE-42C0-8B46-295740DE20BA} = {0C0B6EB5-E41D-46D9-9F60-90D320A2EEF3}
{48E1532F-8B50-477C-BB78-8AEA89A167CE} = {DD14191F-22CE-48D8-A944-B8A41C97ACD4}
{CF7FEDBA-FC1A-4D6D-92F1-6882B5143E0A} = {8D39E84B-2810-41D7-AFE6-0A58E09E34C3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution

View File

@ -14,7 +14,11 @@ namespace HuanMeng.DotNetCore.MiddlewareExtend
/// <returns></returns>
public static IApplicationBuilder UseMiddlewareAll(this IApplicationBuilder builder)
{
return builder.UseExceptionMiddleware().UseExecutionTimeMiddleware().UseSignMiddleware();
return builder
.UseExceptionMiddleware()
.UseExecutionTimeMiddleware()
.UseSignMiddleware()
;
}

View File

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;
namespace HuanMeng.DotNetCore.Utility.AssemblyHelper
{
/// <summary>
/// 保存各种程序集信息属性的类。
/// </summary>
[Serializable]
public class AssemblyInfo
{
/// <summary>
/// 获取或设置程序集的版本。
/// </summary>
public string Version { get; set; }
/// <summary>
/// 获取或设置程序集的文件版本。
/// </summary>
public string FileVersion { get; set; }
/// <summary>
/// 获取或设置程序集版本。
/// </summary>
public string AssemblyVersion { get; set; }
/// <summary>
/// 获取或设置程序集的信息性版本。
/// </summary>
public string InformationalVersion { get; set; }
///// <summary>
///// 获取或设置与程序集关联的公司名称。
///// </summary>
//public string Company { get; set; }
///// <summary>
///// 获取或设置与程序集关联的产品名称。
///// </summary>
//public string Product { get; set; }
/// <summary>
/// 获取或设置与程序集关联的版权信息。
/// </summary>
public string Copyright { get; set; }
/// <summary>
/// 获取或设置程序集的描述信息。
/// </summary>
public string Description { get; set; }
}
}

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace HuanMeng.DotNetCore.Utility.AssemblyHelper
{
/// <summary>
/// 用于检索程序集信息的辅助类。
/// </summary>
public static class AssemblyInfoHelper
{
/// <summary>
/// 从正在执行的程序集检索各种属性,并返回一个 AssemblyInfo 对象。
/// </summary>
/// <returns>包含程序集属性的 AssemblyInfo 对象。</returns>
public static AssemblyInfo GetAssemblyInfo()
{
// 获取正在执行的程序集
Assembly assembly = Assembly.GetExecutingAssembly();
// 创建并填充 AssemblyInfo 对象的相关属性
var assemblyInfo = new AssemblyInfo
{
Version = assembly.GetName().Version.ToString(),
FileVersion = assembly.GetCustomAttributes<AssemblyFileVersionAttribute>().FirstOrDefault()?.Version ?? "",
AssemblyVersion = assembly.GetCustomAttributes<AssemblyVersionAttribute>().FirstOrDefault()?.Version ?? "",
InformationalVersion = assembly.GetCustomAttributes<AssemblyInformationalVersionAttribute>().FirstOrDefault()?.InformationalVersion ?? "",
//Company = assembly.GetCustomAttributes<AssemblyCompanyAttribute>().FirstOrDefault()?.Company ?? "",
//Product = assembly.GetCustomAttributes<AssemblyProductAttribute>().FirstOrDefault()?.Product ?? "",
Copyright = assembly.GetCustomAttributes<AssemblyCopyrightAttribute>().FirstOrDefault()?.Copyright ?? "",
Description = assembly.GetCustomAttributes<AssemblyDescriptionAttribute>().FirstOrDefault()?.Description ?? ""
};
return assemblyInfo;
}
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace HuanMeng.DotNetCore.Utility
{
/// <summary>
/// 时间扩展
/// </summary>
public static class DateTimeExtensions
{
/// <summary>
/// 获取时间戳,秒
/// </summary>
/// <param name="dateTime"></param>
/// <returns></returns>
public static long ToUnixTimestamp(this DateTime dateTime)
{
return (long)(dateTime.ToUniversalTime() - new DateTime(1970, 1, 1)).TotalSeconds;
}
/// <summary>
/// 获取是时间戳,毫秒
/// </summary>
/// <param name="dateTime"></param>
/// <returns></returns>
public static long ToUnixTimestampMilliseconds(this DateTime dateTime)
{
return (long)(dateTime.ToUniversalTime() - new DateTime(1970, 1, 1)).TotalMilliseconds;
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace HuanMeng.DotNetCore.Utility;
/// <summary>
/// 手机号
/// </summary>
public class PhoneNumberValidator
{
// 正则表达式用于匹配手机号码。可以根据需要调整以适应不同的国家或地区。
private static readonly Regex phoneNumberRegex = new Regex(@"^(1[3-9]\d{9})$");
public static bool IsPhoneNumber(string input)
{
if (string.IsNullOrWhiteSpace(input))
{
return false;
}
return phoneNumberRegex.IsMatch(input);
}
}

View File

@ -8,7 +8,7 @@ using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
using HuanMeng.MiaoYu.Model.Dto.Chat;
using HuanMeng.MiaoYu.Model.EnumModel.Chat;
using HuanMeng.MiaoYu.Model.EnumModel.User;
using HuanMeng.Utility;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;

View File

@ -10,4 +10,5 @@ global using System.Collections.Concurrent;
global using HuanMeng.MiaoYu.Code.SysDictionary.Contract;
global using HuanMeng.MiaoYu.Code.SysDictionary;
global using HuanMeng.MiaoYu.Code.SysDictionary.DictionaryNetwork;
global using HuanMeng.DotNetCore.TextCensor;
global using HuanMeng.DotNetCore.TextCensor;
global using HuanMeng.DotNetCore.Utility;

View File

@ -32,7 +32,6 @@
<ItemGroup>
<ProjectReference Include="..\HuanMeng.DotNetCore\HuanMeng.DotNetCore.csproj" />
<ProjectReference Include="..\HuanMeng.MiaoYu.Model\HuanMeng.MiaoYu.Model.csproj" />
<ProjectReference Include="..\HuanMeng.Utility\HuanMeng.Utility.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "8.0.7",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}

View File

@ -1,13 +1,14 @@
using Azure;
using HuanMeng.DotNetCore.Base;
using HuanMeng.DotNetCore.Utility;
using HuanMeng.MiaoYu.Code.Other;
using HuanMeng.MiaoYu.Code.Users;
using HuanMeng.MiaoYu.Model.Dto;
using HuanMeng.MiaoYu.Model.Dto.Account;
using HuanMeng.MiaoYu.Model.Dto.Shop;
using HuanMeng.MiaoYu.WebApi.Base;
using HuanMeng.Utility;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;

View File

@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<PublishAot>false</PublishAot>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
@ -23,7 +24,6 @@
<ProjectReference Include="..\..\0-core\HuanMeng.DotNetCore\HuanMeng.DotNetCore.csproj" />
<ProjectReference Include="..\..\0-core\HuanMeng.MiaoYu.Code\HuanMeng.MiaoYu.Code.csproj" />
<ProjectReference Include="..\..\0-core\HuanMeng.MiaoYu.Model\HuanMeng.MiaoYu.Model.csproj" />
<ProjectReference Include="..\..\0-core\HuanMeng.Utility\HuanMeng.Utility.csproj" />
</ItemGroup>
<ItemGroup>

View File

@ -8,7 +8,6 @@ using HuanMeng.MiaoYu.Code.TencentUtile;
using HuanMeng.MiaoYu.Code.Users.UserAccount.VerificationCodeManager;
using HuanMeng.MiaoYu.Code.JwtUtil;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using HuanMeng.Utility.AssemblyHelper;
using HuanMeng.DotNetCore.CustomExtension;
using HuanMeng.MiaoYu.Code.Cache;
using HuanMeng.MiaoYu.Code.Chat;
@ -20,6 +19,7 @@ using Newtonsoft.Json.Serialization;
using HuanMeng.MiaoYu.Code.SysDictionary;
using HuanMeng.MiaoYu.Code.Base;
using HuanMeng.MiaoYu.Code.Other;
using HuanMeng.DotNetCore.Utility.AssemblyHelper;
var builder = WebApplication.CreateBuilder(args);
//Log.Logger = new LoggerConfiguration()
// .WriteTo.Console()
@ -57,7 +57,8 @@ if (type != null)
builder.Services.AddAutoMapper(mapperDomain);
#endregion
builder.Services.AddControllers().AddNewtonsoftJson(options =>
builder.Services.AddControllers()
.AddNewtonsoftJson(options =>
{
// 配置 Newtonsoft.Json 选项
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; // 忽略循环引用
@ -65,7 +66,8 @@ builder.Services.AddControllers().AddNewtonsoftJson(options =>
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";// 时间格式化
//options.SerializerSettings.Converters.Add()
// 其他配置...
});
})
;
// .AddJsonOptions(options =>
//{
// //options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve;
@ -164,8 +166,8 @@ app.UseMiddlewareAll();
app.MapGet("/", () => "请求成功").WithName("默认请求");
var startDateTime = DateTime.Now;
//var InformationalVersion = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
//Console.WriteLine($"version:{InformationalVersion}");
var InformationalVersion = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
Console.WriteLine($"version:{InformationalVersion}");
app.MapGet("/system", () =>
{
@ -185,4 +187,4 @@ app.MapGet("/system", () =>
};
}).WithName("获取系统数据");
#endregion
app.Run();
app.Run();