WWB.NET.Framework 1.0.1

dotnet add package WWB.NET.Framework --version 1.0.1
                    
NuGet\Install-Package WWB.NET.Framework -Version 1.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="WWB.NET.Framework" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WWB.NET.Framework" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="WWB.NET.Framework" />
                    
Project file
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 WWB.NET.Framework --version 1.0.1
                    
#r "nuget: WWB.NET.Framework, 1.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 WWB.NET.Framework@1.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=WWB.NET.Framework&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=WWB.NET.Framework&version=1.0.1
                    
Install as a Cake Tool

NetAdmin 基础设施框架

基于 .NET 10 的可复用后端基础设施框架,提供通用能力基座(多库持久化、缓存/Redis、雪花 Id、任务调度、JWT、种子数据、仓储、工作单元、AOP 等),供中小项目直接复用,避免重复搭建。

本仓库为后端基础设施框架,不含前端代码与管理后台业务模块(Admin / Bpm 已移除,租户能力已彻底去除)。

技术栈(后端)

技术 说明
.NET 10 / ASP.NET Core 宿主框架(可按需挂载多个宿主)
SqlSugar ORM 数据访问(PostgreSQL / MySQL / SQL Server / SQLite),单库模式
JWT 无状态认证
SignalR 实时通信(在线用户、消息推送)
Quartz.NET 定时任务调度
Serilog 结构化日志(控制台 + 按天滚动文件)
Redis 缓存 / 分布式锁(可选,未配置回退内存缓存)
AspectCore AOP 动态代理(事务、Redis 锁等拦截器)

分层架构

backend/
  src/
    WWB.NET.Framework/                合并后的基础设施框架(Web/JWT/响应、SqlSugar/Repository/UoW、缓存、AOP、Quartz、SignalR、Serilog、领域事件、雪花 Id、Utilities 纯静态工具)
    WWB.NET.Simple.Demo/               示例业务模块(Todo,演示基础设施复用)
    WWB.NET.Simple.Host/               轻量示例宿主(仅引用 WWB.NET.Framework + WWB.NET.Simple.Demo)
  tests/
    Net.Tests/                     xUnit 单元测试(缓存、JWT、响应包装、序列化、领域事件、模块装配等)

依赖方向:业务模块 → WWB.NET.Framework(契约与实现合一,纯静态工具在 WWB.NET.Framework/Utilities/ 自包含零依赖,可被任意宿主复用)。宿主 Program.cs 按需调用各独立 Setup,并通过模块 Marker(AddNetModule<TMarker>)显式指定参与扫描的程序集。

快速开始

环境要求

  • .NET 10 SDK
  • PostgreSQL 14+ / MySQL / SQL Server(任选其一;小项目可用 SQLite 免装数据库服务)
  • Redis 6+(可选,未配置回退内存缓存)

启动示例宿主

配置数据库与 Redis(敏感连接串在 appsettings.Development.json,主配置 appsettings.json 仅保留非敏感占位):

  • Database.DbConfigs[0].ConnectionString:数据库连接串(PostgreSQL / MySQL / SQL Server / SQLite)
  • ConnectionStrings.Redis:Redis 连接串(无本地 Redis 请留空,回退内存缓存)

SQLite 零配置示例(单文件库,免装数据库服务,适合小项目 / 本地开发):

{
  "Database": {
    "DbConfigs": [
      {
        "ConfigId": "main",
        "DbType": "Sqlite",
        "ConnectionString": "Data Source=app.db",
        "EnableUnderLine": false
      }
    ]
  },
  "ConnectionStrings": {
    "Quartz": "Data Source=app.db"
  }
}

DbType 可选值:PostgreSQL / MySql / SqlServer / Sqlite。SQLite 下自动禁用 Quartz 集群锁;分表实体在 SQLite 上同样支持。

cd backend
dotnet run --project src/WWB.NET.Simple.Host/WWB.NET.Simple.Host.csproj --launch-profile http

宿主默认监听 https://localhost:63007http://localhost:63008,首次启动自动建库建表并写入种子数据。

新增自己的业务模块

  1. 新建 WWB.NET.{YourModule} 程序集,仅引用基础设施框架 WWB.NET.Framework(含全部契约与实现)。
  2. 定义模块 Marker 类型(如 YourModuleMarker 空类),在宿主中调用 services.AddNetModule<YourModuleMarker>() 将其纳入框架扫描范围(自动注入、种子、调度发现均依赖此目录)。
  3. 实体继承 EntityBase,入参出参放 Dtos/
  4. Controller 继承 ApiControllerBase,在宿主中调用 AddApplicationPart(typeof(YourModuleMarker).Assembly) 暴露。
  5. 宿主 Program.cs 按需编排共享层(AddWwbNetWebInfrastructure / AddWwbNetPersistence / AddWwbNetScheduling 等),无需重复实现基础设施。

配置说明

backend/src/WWB.NET.Simple.Host/appsettings.json 关键节点:

节点 说明
Serilog 日志级别、输出模板与滚动文件策略
Cors 允许跨域的来源
Database.DbConfigs 单库配置(SqlSugar),DbType 支持 PostgreSQL/MySql/SqlServer/SqliteEnableInitDb/EnableInitTable/EnableInitSeed 控制自动建库建表与种子
Jwt 密钥、签发者、访问令牌与刷新令牌有效期
ConnectionStrings.Redis Redis 连接串(含库与键前缀)
ConnectionStrings.Quartz Quartz 持久化库连接串(缺省回退到 Database 主库;SQLite 下与 Database 共用同一文件库,且自动禁用集群锁)

敏感配置分离appsettings.json 不提交明文密钥。Redis 连接串、数据库密码、JWT Secret 等敏感值放在 appsettings.Development.json(已被 .gitignore 忽略),本地开发由 ASPNETCORE_ENVIRONMENT=Development 自动合并。生产环境请通过 appsettings.Production.json 或环境变量注入密钥。

开发说明

  • 种子数据由 [IncreSeed] + JsonSeedLoader 驱动,仅扫描宿主通过 AddNetModule<TMarker> 显式指定的模块程序集,修改后重启后端即可生效。
  • 框架反射扫描(自动注入、仓储、调度、种子)均基于 INetModuleCatalog,必须通过模块 Marker 显式登记程序集,不会隐式扫描宿主的全部引用。
  • 架构约束与开发规范见 AGENTS.md
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 90 9/7/2026
1.0.0 147 8/17/2026