ZR.Admin.NET Documentation

repository·main·Indexed 23 days ago

https://github.com/izhaorui/zr.admin.net

A high-performance rapid development framework for administrative back-ends built with .NET 8 and Vue (2.x/3.x/uniapp). It features a decoupled architecture, an RBAC permission system, automated code generation, and a built-in SaaS multi-tenancy solution using a DB-per-tenant architecture with SqlSugar. The technology stack includes Web API, SignalR, Quartz.NET, Redis, and NLog.

Tokens
25.1K
Snippets
22
Records
141
Agent score
81%

What's inside ZR.Admin.NET

  1. Overview of ZR.Admin.NET

    main
    ZR.Admin.NET is a rapid development framework based on .NET 8 and Vue (2.x/3.x/uniapp) using a decoupled front-end and back-end architecture. It implements a general permission management platform using the RBAC (Role-Based Access Control) model. The framework is designed to be lightweight, easy to extend, and aims to automate approximately 70% of repetitive web development tasks through features like code generation and built-in SaaS multi-tenancy.
  2. Key advantages of ZR.Admin.NET

    main

    ZR.Admin.NET is designed to accelerate development by providing a pre-built administrative foundation. Key benefits include:

    • Reduced Boilerplate: The front-end system handles login, authorization, and authentication automatically, allowing developers to focus solely on business modules.
    • Ready-to-use Backend: The background system is functional immediately upon release without requiring secondary development.
    • Decoupled Architecture: The front-end and back-end are separate systems, allowing for independent deployment and independent domain names.
    • Robust Error Handling: Features unified handling of global exceptions.
    • Developer Productivity: Includes custom code generation features and has low dependency requirements for easy onboarding.
    • Documentation: Comes with comprehensive documentation.
  3. How SaaS Multi-tenancy works in ZR.Admin.NET

    main

    The project includes a built-in SaaS Multi-tenancy solution using a DB-per-tenant (independent database) architecture. It leverages SqlSugar's SugarScope multi-configuration capability to perform dynamic database routing.

    Key Concepts:

    • Data Isolation: Each tenant has its own independent database instance for physical data isolation. Tenant, package, and menu metadata are stored in a central Main Database.
    • Activation: Multi-tenancy can be toggled on or off using the TenantSettings:UseTenant configuration key. When disabled, the system behaves as a single-tenant application.
    • Authorization Model: A tenant's capabilities are determined by the intersection of their assigned Role Menus and the Package Menus (Role Menus ∩ Package Menus).
    • Lifecycle Management: Supports full lifecycle management including provisioning (creating records, tables, seed data, and default packages), suspension, renewal, and cancellation.
    • User Quotas: The system automatically validates user counts against the limits defined by the tenant's current package during user creation or import.
  4. Understand the ZR.Admin.NET technology stack

    main

    ZR.Admin.NET is a rapid development framework using a front-end and back-end separation mode.

    Back-end Stack

    • Core Framework: .NET 7.0/8.0 + Web API
    • ORM: SqlSugar (supports sharding and high performance)
    • API Documentation: Swagger
    • Real-time: SignalR
    • Task Scheduling: Quartz.NET (supports executing assemblies or HTTP requests)
    • Caching: Built-in memory cache and Redis
    • Rate Limiting: IpRateLimit
    • Logging: NLog (Login, Operation, and Scheduled Task logs)
    • Security: Data permission filtering, SQL injection protection, and request forgery protection

    Front-end Stack

    • Frameworks: Vue 2.x, Vue 3.x, and UniApp
    • UI Libraries: Element-UI and Ant Design Vue
    • Core Tools: Vue-router, Vue-CLI, Axios, i18N (Internationalization)
  5. Understand the ZR.Admin.NET project structure

    main

    The project is organized into several layers to separate business logic, system services, and data access:

    • ZR.Service: Your business service layer library; provides WebApi interface calls.
    • ZR.ServiceCore: System service layer library; provides WebApi interface calls.
    • ZR.Repository: Repository layer library; used for executing stored procedures and data access.
    • ZR.Model: Entity layer library; contains database tables and Data Transfer Objects (DTOs).
    • ZR.Admin.WebApi: The Web API entry point; provides services for Vue versions or third-party systems.
    • ZR.Tasks: Scheduled task library; implements project-specific scheduled tasks.
    • ZR.CodeGenerator: Code generation module; contains templates and methods for generating code.
    • ZR.Vue: Front-end UI layer (Vue 2.0 version; Vue 3 is recommended for new projects).
    • document: Contains database scripts and documentation.
  6. Understand the Project Structure

    main

    The backend solution is organized into several specialized layers:

    • ZR.Service: Your business service layer; provides API interfaces for your custom business logic.
    • ZR.ServiceCore: The system service layer; provides core system API interfaces.
    • ZR.Repository: The repository layer; facilitates database operations, including stored procedures.
    • ZR.Model: The entity layer; contains business database tables and Data Transfer Objects (DTOs).
    • ZR.Admin.WebApi: The Web API entry point; provides services for Vue front-ends or third-party systems.
    • ZR.Tasks: The task library; contains implementations for scheduled tasks.
    • ZR.CodeGenerator: The code generation module; contains templates and logic for generating code.
    • ZR.Mall: The backend for the integrated Mall/Store module.
    • ZR.Vue: The Vue 2.0 UI layer (Note: Vue 3 is recommended for new projects).
    ├─ZR.Service                ->[你的业务服务层类库]:提供自己业务数据Api接口调用;
    ├─ZR.ServiceCore            ->[系统服务层类库]:提供系统Api接口;
    ├─ZR.Repository             ->[仓库层类库]:方便提供有执行存储过程的操作;
    ├─ZR.Model                	->[实体层类库]:自己业务库表、数据传输对象;
    ├─ZR.Admin.WebApi           ->[webapi接口]:为Vue版或其他三方系统提供接口服务。
    ├─ZR.Tasks               	->[定时任务类库]:提供项目定时任务实现功能;
    ├─ZR.CodeGenerator          ->[代码生成功能]:包含代码生成的模板、方法、代码生成的下载。
    ├─ZR.Mall                   ->[商城后端]:商城相关的后端代码。
    ├─ZR.Vue               		->[前端UI]:vue2.0版本UI层(已经不再更新推荐使用vue3)。
    └─document               	->[文档]:数据库脚本(已弃用)
  7. Setup the ZR.Vue frontend development environment

    main

    To start developing the ZR.Vue frontend, clone the repository, navigate to the ZR.Vue directory, and install dependencies using npm.

    Note on dependency installation: It is strongly recommended not to use cnpm as it may cause unpredictable bugs. If you are experiencing slow download speeds with standard npm, use the Taobao registry instead.

    Once dependencies are installed, start the development server and access the application via your browser.