feat(优化): 优化项目结构
This commit is contained in:
parent
04f0c79c2e
commit
4a897b5ccd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,92 @@
|
|||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "D:\\MyFolder\\Bunny\\Bunny-cli\\CSharp\\CSharp-Single-EFCore\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{28753039-0C3B-4FE5-95F8-7EDC92DCBA26}|Bunny.WebApi\\Bunny.WebApi.csproj|d:\\myfolder\\bunny\\bunny-cli\\csharp\\csharp-single-efcore\\bunny.webapi\\config\\baseconfig.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{28753039-0C3B-4FE5-95F8-7EDC92DCBA26}|Bunny.WebApi\\Bunny.WebApi.csproj|solutionrelative:bunny.webapi\\config\\baseconfig.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{28753039-0C3B-4FE5-95F8-7EDC92DCBA26}|Bunny.WebApi\\Bunny.WebApi.csproj|d:\\myfolder\\bunny\\bunny-cli\\csharp\\csharp-single-efcore\\bunny.webapi\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{28753039-0C3B-4FE5-95F8-7EDC92DCBA26}|Bunny.WebApi\\Bunny.WebApi.csproj|solutionrelative:bunny.webapi\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{28753039-0C3B-4FE5-95F8-7EDC92DCBA26}|Bunny.WebApi\\Bunny.WebApi.csproj|d:\\myfolder\\bunny\\bunny-cli\\csharp\\csharp-single-efcore\\bunny.webapi\\config\\serviceregistration.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{28753039-0C3B-4FE5-95F8-7EDC92DCBA26}|Bunny.WebApi\\Bunny.WebApi.csproj|solutionrelative:bunny.webapi\\config\\serviceregistration.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{28753039-0C3B-4FE5-95F8-7EDC92DCBA26}|Bunny.WebApi\\Bunny.WebApi.csproj|d:\\myfolder\\bunny\\bunny-cli\\csharp\\csharp-single-efcore\\bunny.webapi\\config\\knife4net.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{28753039-0C3B-4FE5-95F8-7EDC92DCBA26}|Bunny.WebApi\\Bunny.WebApi.csproj|solutionrelative:bunny.webapi\\config\\knife4net.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 4,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "D:\\MyFolder\\Bunny\\Bunny-cli\\CSharp\\CSharp-Single-EFCore\\Bunny.WebApi\\Program.cs",
|
||||
"RelativeDocumentMoniker": "Bunny.WebApi\\Program.cs",
|
||||
"ToolTip": "D:\\MyFolder\\Bunny\\Bunny-cli\\CSharp\\CSharp-Single-EFCore\\Bunny.WebApi\\Program.cs",
|
||||
"RelativeToolTip": "Bunny.WebApi\\Program.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-09-02T00:54:57.227Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "ServiceRegistration.cs",
|
||||
"DocumentMoniker": "D:\\MyFolder\\Bunny\\Bunny-cli\\CSharp\\CSharp-Single-EFCore\\Bunny.WebApi\\Config\\ServiceRegistration.cs",
|
||||
"RelativeDocumentMoniker": "Bunny.WebApi\\Config\\ServiceRegistration.cs",
|
||||
"ToolTip": "D:\\MyFolder\\Bunny\\Bunny-cli\\CSharp\\CSharp-Single-EFCore\\Bunny.WebApi\\Config\\ServiceRegistration.cs",
|
||||
"RelativeToolTip": "Bunny.WebApi\\Config\\ServiceRegistration.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-09-02T00:54:44.07Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 3,
|
||||
"Title": "Knife4Net.cs",
|
||||
"DocumentMoniker": "D:\\MyFolder\\Bunny\\Bunny-cli\\CSharp\\CSharp-Single-EFCore\\Bunny.WebApi\\Config\\Knife4Net.cs",
|
||||
"RelativeDocumentMoniker": "Bunny.WebApi\\Config\\Knife4Net.cs",
|
||||
"ToolTip": "D:\\MyFolder\\Bunny\\Bunny-cli\\CSharp\\CSharp-Single-EFCore\\Bunny.WebApi\\Config\\Knife4Net.cs",
|
||||
"RelativeToolTip": "Bunny.WebApi\\Config\\Knife4Net.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-09-02T00:54:28.202Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "BaseConfig.cs",
|
||||
"DocumentMoniker": "D:\\MyFolder\\Bunny\\Bunny-cli\\CSharp\\CSharp-Single-EFCore\\Bunny.WebApi\\Config\\BaseConfig.cs",
|
||||
"RelativeDocumentMoniker": "Bunny.WebApi\\Config\\BaseConfig.cs",
|
||||
"ToolTip": "D:\\MyFolder\\Bunny\\Bunny-cli\\CSharp\\CSharp-Single-EFCore\\Bunny.WebApi\\Config\\BaseConfig.cs",
|
||||
"RelativeToolTip": "Bunny.WebApi\\Config\\BaseConfig.cs",
|
||||
"ViewState": "AQIAABAAAAAAAAAAAAAowBwAAAARAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-09-02T00:54:22.184Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,35 @@
|
|||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Bunny.Dao.Model.Constant;
|
||||
|
||||
namespace Bunny.Common.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义Json转换器,用于将DateTime类型转换为JSON格式
|
||||
/// </summary>
|
||||
public class JsonDateTimeConverter : JsonConverter<DateTime>
|
||||
{
|
||||
/// <summary>
|
||||
/// 重写读取方法,将JSON数据转换为DateTime类型
|
||||
/// </summary>
|
||||
/// <param name="reader">JSON读取器</param>
|
||||
/// <param name="typeToConvert">要转换的目标类型</param>
|
||||
/// <param name="options">JSON序列化选项</param>
|
||||
/// <returns>转换后的DateTime对象</returns>
|
||||
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
return DateTime.TryParse(reader.GetString(), out var date) ? date : default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写写入方法,将DateTime对象转换为JSON格式并写入JSON写入器
|
||||
/// </summary>
|
||||
/// <param name="writer">JSON写入器</param>
|
||||
/// <param name="value">要写入的DateTime对象</param>
|
||||
/// <param name="options">JSON序列化选项</param>
|
||||
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
|
||||
{
|
||||
// 将DateTime对象转换为特定格式的字符串并写入JSON写入器
|
||||
writer.WriteStringValue(value.ToString(LocalDateTimeConstant.DefaultDateTimeSecondFormat));
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
using Bunny.Common.Exception;
|
||||
using Bunny.Dao.Entity.Constant;
|
||||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Model.Constant;
|
||||
using Bunny.Dao.Model.Result;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Net;
|
||||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Model.Result;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using Bunny.Common.Exception;
|
||||
using Bunny.Dao.Entity.Constant;
|
||||
using Bunny.Dao.Model.Constant;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bunny.Common.Utils.Jwt;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Bunny.Common.Connect;
|
||||
using Bunny.Common.Exception;
|
||||
using Bunny.Dao.Entity.Constant;
|
||||
using Bunny.Dao.Model.Constant;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Minio.DataModel;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Net;
|
||||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Model.Result;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Bunny.Common.Utils.Net;
|
||||
|
|
|
@ -10,4 +10,8 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Model\"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
namespace Bunny.Dao.Entity.Enum;
|
||||
|
||||
public enum Enum
|
||||
{
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Constant;
|
||||
namespace Bunny.Dao.Model.Constant;
|
||||
|
||||
/// <summary>
|
||||
/// 错误常量
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Constant;
|
||||
namespace Bunny.Dao.Model.Constant;
|
||||
|
||||
/// <summary>
|
||||
/// 文件消息相关常量
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Constant;
|
||||
namespace Bunny.Dao.Model.Constant;
|
||||
|
||||
/// <summary>
|
||||
/// 事件相关常量
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Constant;
|
||||
namespace Bunny.Dao.Model.Constant;
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱消息先关常量
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Constant;
|
||||
namespace Bunny.Dao.Model.Constant;
|
||||
|
||||
/// <summary>
|
||||
/// Redis相关常量
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Result.Constant;
|
||||
namespace Bunny.Dao.Model.Constant.Result;
|
||||
|
||||
/// <summary>
|
||||
/// 发生时的错误敞亮
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Result.Constant;
|
||||
namespace Bunny.Dao.Model.Constant.Result;
|
||||
|
||||
public class SuccessConstant
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Constant;
|
||||
namespace Bunny.Dao.Model.Constant;
|
||||
|
||||
/// <summary>
|
||||
/// 鉴权相关常量
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Constant;
|
||||
namespace Bunny.Dao.Model.Constant;
|
||||
|
||||
/// <summary>
|
||||
/// 数据库相关常量
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Constant;
|
||||
namespace Bunny.Dao.Model.Constant;
|
||||
|
||||
/// <summary>
|
||||
/// 状态相关常量
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Constant;
|
||||
namespace Bunny.Dao.Model.Constant;
|
||||
|
||||
/// <summary>
|
||||
/// 用户相关常量
|
|
@ -0,0 +1,5 @@
|
|||
namespace Bunny.Dao.Model.Enum;
|
||||
|
||||
public enum Enum
|
||||
{
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
namespace Bunny.Dao.Entity.Result;
|
||||
namespace Bunny.Dao.Model.Result;
|
||||
|
||||
public class PageResult<T>
|
||||
{
|
|
@ -1,8 +1,8 @@
|
|||
using System.Net;
|
||||
using Bunny.Dao.Entity.Result.Constant;
|
||||
using Bunny.Dao.Model.Constant.Result;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Bunny.Dao.Entity.Result;
|
||||
namespace Bunny.Dao.Model.Result;
|
||||
|
||||
[Serializable]
|
||||
public class Result<T>(HttpStatusCode code, T? data, string? message)
|
|
@ -1,7 +1,7 @@
|
|||
using System.Net;
|
||||
using Bunny.Common.Utils.Jwt;
|
||||
using Bunny.Common.Utils.Net;
|
||||
using Bunny.Dao.Entity.Constant;
|
||||
using Bunny.Dao.Model.Constant;
|
||||
using Bunny.Dao.Vo.User;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Entity.System;
|
||||
using Bunny.Dao.Entity.System;
|
||||
using Bunny.Dao.Model.Result;
|
||||
|
||||
namespace Bunny.Service.IService;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Bunny.Common.Connect;
|
||||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Entity.System;
|
||||
using Bunny.Dao.Model.Result;
|
||||
|
||||
namespace Bunny.Service.IService.Service;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
using Bunny.Common.Exception;
|
||||
using Bunny.Common.Utils.Jwt;
|
||||
using Bunny.Common.Utils.Net;
|
||||
using Bunny.Dao.Dto.User;
|
||||
using Bunny.Dao.Entity.Constant;
|
||||
using Bunny.Dao.Vo.User;
|
||||
|
||||
namespace Bunny.Service.IService.Service;
|
||||
namespace Bunny.Service.IService.Service;
|
||||
|
||||
public class LoginService : ILoginService
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Net;
|
||||
using Bunny.Dao.Entity.Constant;
|
||||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Model.Constant;
|
||||
using Bunny.Dao.Model.Result;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Bunny.Common;
|
||||
using Bunny.Common.Configuration;
|
||||
using Bunny.Common.Connect;
|
||||
using Bunny.Service.WebSocket;
|
||||
|
||||
|
@ -15,21 +16,22 @@ public class BaseConfig(WebApplicationBuilder builder)
|
|||
UseCors();
|
||||
// 配置日志相关
|
||||
// builder.Logging.AddLog4Net("Config/log4net.config");
|
||||
// 自定义时间格式
|
||||
builder.Services.AddControllers().AddJsonOptions(options =>
|
||||
options.JsonSerializerOptions.Converters.Add(new JsonDateTimeConverter()));
|
||||
// 添加使用自定义配置文件
|
||||
builder.Services.AddSingleton(new AppSettings(builder.Configuration));
|
||||
// 添加 SignalR
|
||||
builder.Services.AddSignalR();
|
||||
builder.WebHost.ConfigureKestrel((context, options) =>
|
||||
builder.WebHost.ConfigureKestrel((_, options) =>
|
||||
{
|
||||
// 设置文件最大上传大小
|
||||
options.Limits.MaxRequestBodySize = 1024 * 1024 * 100;
|
||||
});
|
||||
// 添加Service服务
|
||||
builder.AddApplicationServices();
|
||||
// 添加后台服务
|
||||
// 添加定时任务
|
||||
builder.AddApplicationBackendServices();
|
||||
// 添加验证码
|
||||
builder.AddCaptcha();
|
||||
// 设置过滤器
|
||||
builder.AddFilterConfigInitialize();
|
||||
// 初始化Redis
|
||||
|
@ -40,6 +42,8 @@ public class BaseConfig(WebApplicationBuilder builder)
|
|||
builder.AddKnife4Net();
|
||||
// 启动 webSocket
|
||||
builder.AddWebSocketInitial();
|
||||
// 添加验证码
|
||||
builder.AddCaptcha();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Bunny.WebApi.Config;
|
||||
|
||||
public class JsonDateTimeConverter : JsonConverter<DateTime>
|
||||
{
|
||||
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
return DateTime.TryParse(reader.GetString(), out var date) ? date : default;
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Entity.System;
|
||||
using Bunny.Dao.Entity.System;
|
||||
using Bunny.Dao.Model.Result;
|
||||
using Bunny.Service.IService;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Entity.Result.Constant;
|
||||
using Bunny.Dao.Model.Constant.Result;
|
||||
using Bunny.Dao.Model.Result;
|
||||
using Lazy.Captcha.Core;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Model.Result;
|
||||
using Bunny.Service.IService;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Model.Result;
|
||||
using Bunny.Service.IService;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Minio.DataModel;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Model.Result;
|
||||
using Bunny.Service.IService;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Bunny.Dao.Entity.Result;
|
||||
using Bunny.Dao.Model.Result;
|
||||
using Bunny.Service.IService;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
|
Loading…
Reference in New Issue