Skip to content

YangMufa/Roc.Admin

Repository files navigation

Roc.Net

基于C#+.Net10+Dapper+PostgreSql+Soybean-Admin-Vue的DDD领域驱动微服务开发框架, 内置用户权限管理、日志、代码生成 等模块,可根据需要新增模块.

📁 各项目详解与文件夹结构

1. 领域层

  • 项目类型.NET Standard 类库 或 .NET Core 类库。

  • 项目名称Roc.Domain

  • 必须包含的文件夹

    text

    Roc.Domain/
    ├── Aggregates/           # 聚合根
    │   └── OrderAggregate/
    │       ├── Order.cs
    │       ├── OrderItem.cs
    │       └── OrderStatus.cs
    ├── Entities/             # 非聚合根的实体(如果存在)
    ├── ValueObjects/         # 值对象
    │   └── Address.cs
    ├── DomainEvents/         # 领域事件定义
    │   └── OrderPlacedDomainEvent.cs
    ├── Services/             # 领域服务接口
    │   └── IOrderDomainService.cs
    ├── Repositories/         # 仓储接口
    │   └── IOrderRepository.cs
    ├── Specifications/       # 规约模式
    ├── Exceptions/           # 领域异常
    └── Enums/                # 领域相关的枚举
    
  • 关键点:此项目不引用任何其他项目,是解决方案的核心。

2. 应用层

  • 项目类型.NET Core 类库。

  • 项目名称Roc.Application

  • 必须包含的文件夹

    text

    Roc.Application/
    ├── Features/            # 【推荐】按功能组织
    │   ├── Orders/
    │   │   ├── Commands/
    │   │   │   ├── CreateOrder/
    │   │   │   │   ├── CreateOrderCommand.cs
    │   │   │   │   ├── CreateOrderCommandHandler.cs
    │   │   │   │   └── CreateOrderCommandValidator.cs
    │   │   │   └── CancelOrder/
    │   │   ├── Queries/
    │   │   │   └── GetOrderById/
    │   │   │       ├── GetOrderByIdQuery.cs
    │   │   │       └── GetOrderByIdQueryHandler.cs
    │   │   └── DTOs/        # 该功能专用的DTO
    │   └── Products/        # 另一个功能模块
    ├── Common/
    │   ├── Behaviors/       # MediatR管道行为(日志、验证、事务)
    │   ├── Interfaces/      # 应用层通用接口(如IEmailService)
    │   ├── Mappings/        # AutoMapper配置
    │   └── Exceptions/      # 应用层异常
    ├── DomainEventHandlers/ # 领域事件处理程序
    └── DependencyInjection.cs # 此层的服务注册扩展方法你的产品。
    
  • 关键点:此项目引用Domain项目。使用 MediatR 实现CQRS是当前主流模式。

3. 基础设施层

  • 项目类型.NET Core 类库。

  • 项目名称Roc.Infrastructure

  • 必须包含的文件夹

    text

    Roc.Infrastructure/
    ├── Persistence/          # 数据持久化
    │   ├── Contexts/         # DbContext
    │   ├── Configurations/   # EF Core实体配置
    │   ├── Migrations/       # 数据迁移
    │   └── Repositories/     # 仓储的具体实现
    ├── ExternalServices/     # 外部服务客户端(如支付、短信)
    ├── Messaging/            # 消息队列实现
    ├── Identity/             # 身份认证实现
    ├── FileStorage/          # 文件存储实现
    ├── Caching/              # 缓存实现
    └── DependencyInjection.cs # 此层的服务注册扩展方法
    
  • 关键点:此项目引用DomainApplication项目,并实现其中定义的接口。

4. 表现层

  • 项目类型ASP.NET Core Web APIBlazor Web App

  • 项目名称Roc.Admin.WebApi

  • 建议的文件夹结构

    text

    Roc.WebApi/
    ├── Controllers/          # API控制器
    │   └── OrdersController.cs
    ├── Endpoints/            # 【可选】使用Minimal API时的端点定义
    ├── Middlewares/          # 自定义中间件(如异常处理)
    ├── Filters/              # 动作过滤器
    ├── Program.cs            # 主程序入口
    └── appsettings.json      # 配置文件
    
  • 关键点:此项目引用ApplicationInfrastructure项目,是启动项目。

5. 共享内核

  • 项目类型.NET Standard 类库。
  • 项目名称Roc.SharedKernel
  • 包含内容:多个限界上下文共享的基类、工具、通用枚举、扩展方法等。
  • 关键点:此项目不依赖任何其他项目,可被Domain或其他项目引用。

About

基于C#+.Net10+Dapper+PostgreSql+Soybean-Admin-Vue的DDD领域驱动微服务后台管理框架, 内置用户权限管理、日志、代码生成 等模块,可根据需要新增模块.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages