NetKernel.DotNetForge
1.0.0.1
dotnet add package NetKernel.DotNetForge --version 1.0.0.1
NuGet\Install-Package NetKernel.DotNetForge -Version 1.0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetKernel.DotNetForge" Version="1.0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetKernel.DotNetForge" Version="1.0.0.1" />
<PackageReference Include="NetKernel.DotNetForge" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetKernel.DotNetForge --version 1.0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NetKernel.DotNetForge, 1.0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetKernel.DotNetForge@1.0.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetKernel.DotNetForge&version=1.0.0.1
#tool nuget:?package=NetKernel.DotNetForge&version=1.0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DotNetForge
企业级 .NET 8.0 基础设施类库
项目概述
DotNetForge 是一个功能丰富的 .NET 企业级基础设施类库,集成了多种云服务、数据库操作、安全加密、Web API 开发等功能,旨在为 .NET 开发者提供开箱即用的组件支持。
- 框架版本: .NET 8.0
- 项目类型: 类库 (Class Library)
- NuGet 包依赖: 40+
核心模块
1. 基础设施 (Infrastructure)
| 模块 | 说明 |
|---|---|
Entity |
实体基类 (EntityBase, AuditEntity, FullAuditEntity) |
Dto |
DTO 基类 (DtoBase, ValueDto<T>) |
Exceptions |
自定义异常 (BadRequestException, NotFoundException, GatewayException) |
Security |
安全加密 (AES, RSA, MD5, SHA, HMAC, PasswordHasher) |
Utils |
工具类 (JSON, Image, Guard, DelegateExecutionChecker) |
Impl.QRCode |
二维码生成 (基于 SkiaSharp) |
2. Web 开发 (Web)
| 模块 | 说明 |
|---|---|
Api |
统一 API 返回格式 (ApiResult<T>) |
Jwt |
JWT 认证 (JwtProvider, IAuthenticator, RefreshTokenStore) |
Attributes |
MVC 特性 (ApiResultFilter, Authentication, ModelValidation) |
Authorization |
授权策略 |
ApiLog |
API 日志记录 |
Http |
HTTP 客户端封装 |
3. 数据库 (Databse)
| 模块 | 说明 |
|---|---|
Db |
数据库连接封装,支持事务 |
Dp |
Dapper 扩展 (CRUD, 批量操作) |
EF |
EntityFramework Core 支持 |
Infrastructure |
数据库基础设施 (多方言支持) |
支持的数据库: MySQL, Oracle, SQLServer 等
4. 文件处理 (File)
| 模块 | 说明 |
|---|---|
Compress |
压缩解压 (Zip, GZip) |
NPOI |
Excel/Word 读写 |
Aspose |
Aspose.Words 文档处理 |
Spire |
Spire.Doc 文档处理 |
Common |
通用文件操作 |
HtmlToOpenXml |
HTML 转 Word |
5. 云服务集成
腾讯云 (Tencent)
| 服务 | 说明 |
|---|---|
Cos |
对象存储 (COS) |
Sms |
短信服务 |
Captcha |
验证码 (WebApp/小程序) |
WeXin |
微信消息推送、认证 |
WxPay |
微信支付 |
TokenHub |
Token 管理 |
阿里云 (Alibaba)
| 服务 | 说明 |
|---|---|
Ocr |
OCR 文字识别 |
AddressPurification |
地址解析服务 |
6. 第三方服务
| 服务 | 说明 |
|---|---|
QiChaCha |
企查查 - 企业信息查询 |
TianYanCha |
天眼查 - 企业信息查询 |
Weather |
和风天气 API |
7. 消息队列 (Mq)
- RabbitMQ 集成
- 发布/订阅模式支持
8. 任务调度 (TaskSchedule)
- Hangfire 集成
- Quartz 定时任务
9. 反爬虫/防护 (AntiScraping)
- IP 限流
- 客户端限流
- 代理头处理
10. 日志系统 (Logger)
- Serilog 结构化日志
- LogDashboard 日志仪表盘
- 请求日志中间件
快速开始
安装
dotnet add package NetKernel.DotNetForge
服务注册
在 Program.cs 中使用扩展方法注册服务:
using DotNetForge.Extensions;
var builder = WebApplication.CreateBuilder(args);
// 添加 JSON 配置
builder.Configuration.AddJsonSetting("appsettings.json");
// JWT 认证
builder.Services.AddJwtAuthentication<Authenticator>(options =>
{
options.Secret = "your-secret-key";
options.ExpireMinutes = 30;
});
// Web API
builder.Services.AddWebApi();
// 腾讯云服务
builder.Services.AddTencentCos(builder.Configuration);
builder.Services.AddTencentSms(builder.Configuration);
// 阿里云服务
builder.Services.AddOcr(builder.Configuration);
// 数据库
builder.Services.AddMQ(builder.Configuration);
// 任务调度
builder.Services.AddHangfire(builder.Configuration);
// 日志
builder.Services.AddSerilog(builder.Configuration);
var app = builder.Build();
数据库操作
using var db = new Db("ConnectionString");
// 查询
var users = await db.QueryAsync<User>("SELECT * FROM Users");
// Dapper 扩展
var user = await db.GetAsync<User>(id);
// 事务
using var transaction = db.BeginTransaction();
try
{
db.Execute("INSERT INTO Logs (Message) VALUES (@Message)", new { Message = "test" });
transaction.Commit();
}
catch
{
transaction.Rollback();
}
JWT 认证
// 生成 Token
var provider = app.Services.GetRequiredService<JwtProvider>();
var token = await provider.GenerateTokenAsync(userId, claims);
// 验证
[Authentication] // 使用特性
public class SecureController : ControllerBase { }
云存储上传
public class MyCosService : BaseCosService
{
public override string Bucket => "my-bucket";
}
var service = new MyCosService();
await service.PutObject("file.txt", "local/path.txt");
项目结构
DotNetForge/
├── Alibaba/ # 阿里云服务
├── AntiScraping/ # 反爬虫防护
├── Databse/ # 数据库操作
├── File/ # 文件处理
├── Infrastructure/ # 核心基础设施
├── Logger/ # 日志系统
├── Middleware/ # 中间件
├── Mq/ # 消息队列
├── QiChaCha/ # 企查查 API
├── TaskSchedule/ # 任务调度
├── Tencent/ # 腾讯云服务
├── TianYanCha/ # 天眼查 API
├── Weather/ # 天气服务
└── Web/ # Web 开发支持
依赖包
| 类别 | 包名 | 用途 |
|---|---|---|
| ORM | EntityFramework Core, Dapper | 数据库操作 |
| 文档 | Aspose.Words, NPOI, Spire.Doc | Office 文档 |
| 云服务 | TencentCloudSDK, AlibabaCloud | 腾讯/阿里云 |
| 消息队列 | RabbitMQ.Client | RabbitMQ |
| 调度 | Hangfire, Quartz | 定时任务 |
| 日志 | Serilog, LogDashboard | 日志记录 |
| 安全 | JwtBearer | JWT 认证 |
| 其他 | AutoMapper, Newtonsoft.Json | 工具库 |
License
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- AlibabaCloud.SDK.Ocr-api20210707 (>= 3.1.1)
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.0)
- AspNetCoreRateLimit (>= 5.0.0)
- Aspose.Words (>= 24.12.0)
- COSXML.Wpre (>= 1.0.7)
- Dapper (>= 2.1.35)
- Dapper.SimpleCRUD (>= 2.3.0)
- DocumentFormat.OpenXml (>= 3.2.0)
- Hangfire (>= 1.8.14)
- Hangfire.MemoryStorage (>= 1.8.1.1)
- HtmlToOpenXml.dll (>= 3.2.2)
- LogDashboard (>= 1.4.8)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.10)
- Microsoft.EntityFrameworkCore (>= 8.0.10)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.10)
- MySql.Data (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
- NPOI (>= 2.7.1)
- Oracle.ManagedDataAccess.Core (>= 23.6.0)
- PdfSharpCore (>= 1.3.65)
- Pomelo.EntityFrameworkCore.MySql (>= 8.0.2)
- RabbitMQ.Client (>= 6.8.1)
- Serilog (>= 4.0.2)
- Serilog.Extensions.Hosting (>= 8.0.0)
- Serilog.Settings.Configuration (>= 8.0.4)
- Serilog.Sinks.Console (>= 6.0.0)
- Serilog.Sinks.File (>= 6.0.0)
- Serilog.Sinks.MySQL (>= 5.0.0)
- SkiaSharp (>= 3.119.0)
- SkiaSharp.QrCode (>= 0.7.0)
- Spire.Doc (>= 12.11.7)
- Swashbuckle.AspNetCore.SwaggerGen (>= 6.8.1)
- Swashbuckle.AspNetCore.SwaggerUI (>= 6.8.1)
- TencentCloudSDK (>= 3.0.1106)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.