# HzyAdmin **Repository Path**: JayLi2000/HzyAdmin ## Basic Information - **Project Name**: HzyAdmin - **Description**: HzyAdmin 是前后端分离权限管理系统基架!演示地址:http://124.221.128.7:5600 数据权限、按钮权限、动态菜单、动态任务调度、动态WebApi、定时标记 [Scheduled("0/5 * * * * ?")] 、代码生成 - **Primary Language**: C# - **License**: MIT - **Default Branch**: master - **Homepage**: https://hzy6.gitee.io/docs - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 472 - **Created**: 2023-08-09 - **Last Updated**: 2026-11-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # HzyAdmin - General Management Platform 📚 **Secondary Development Guide**: For full architecture documentation, feature walkthroughs, and getting-started tutorials, see [**`docs/index.html`**](docs/index.html) (visit after starting the backend). It covers modular startup, the ApplicationService inheritance chain, dynamic APIs, three-layer authentication and authorization, data permissions, dictionary translation, Quartz scheduled tasks, MCP integration, EF Core monitoring, and more, with a complete hands-on example of "adding a new business module". [中文](README.md) | [Issues](https://gitee.com/hzy6/HzyAdmin/issues/new) > If the `.slnx` file cannot be opened, use Rider or Visual Studio 2022 with `.slnx` preview support enabled. ![HzyAdmin](gitee/images/image_cover.png) HzyAdmin is a front-end and back-end separated admin platform based on **.NET 10 + React 19**. It uses a modular backend architecture and an Ant Design Pro frontend, with built-in user management, role management, menu management, API permissions, data permissions, scheduled tasks, operation logs, file management, and localization. ## Highlights - Front-end and back-end separation: the backend exposes Web APIs, and the React frontend proxies `/api/v1/*` requests. - Modular backend: startup modules, dynamic APIs, repositories, AOP, filters, and middleware. - Complete permission model: JWT authentication, menu permissions, function permissions, API permissions, and role-based data permissions. - React-only frontend: `hzy-frontend-admin-react/` is the only frontend project; the Vue frontend has been removed. - Multi-database support: PostgreSQL by default, with optional SqlServer, MySQL, and Oracle support. - Practical tooling: Docker Compose, Swagger, NUnit backend tests, and Playwright frontend E2E tests. ## Tech Stack ### Backend | Technology | Description | | --- | --- | | .NET 10 | Web API framework | | Entity Framework Core 10 | ORM | | HZY.Framework | DI, dynamic APIs, repositories, entity base classes | | Rougamo.Fody | AOP programming | | JWT | Authentication | | Redis / FreeRedis | Distributed cache | | Quartz.NET | Scheduled tasks | | Mapster | Object mapping | | MiniExcel | Excel import/export | | Swagger / Knife4j | API documentation | | NUnit / Moq / FluentAssertions | Backend tests | ### Frontend | Technology | Description | | --- | --- | | React 19 | Frontend framework | | Umi Max 4 | Application framework, routing, build tooling | | Ant Design 5 | UI component library | | Ant Design Pro / ProComponents | Admin layout, advanced tables, forms | | TypeScript 5 | Type system | | Biome | Linting | | Playwright | E2E testing | | ECharts / AntV | Charts and visualization | ## Project Structure ```text HzyAdmin/ ├── src/ │ ├── HZY.Host.Admin/ # Web API host, controllers, ApplicationServices │ ├── HZY.Repository.Admin/ # EF Core repositories, entities, DbContext │ ├── HZY.Shared.Admin/ # Admin shared layer, DTOs, filters, middleware, bases │ ├── HZY.Shared/ # Base shared module │ ├── HZY.Core/ # Core module │ ├── HZY.Core.EntityFramework/ # EF Core extensions │ ├── HZY.Core.Identity/ # JWT authentication │ ├── HZY.Core.Redis/ # Redis cache │ ├── HZY.Core.Quartz/ # Scheduled tasks │ ├── HZY.Core.UploadFile/ # File uploads │ ├── HZY.Core.Swagger/ # Swagger docs │ └── HZY.Core.* # Other extension modules ├── hzy-frontend-admin-react/ # React 19 + Ant Design Pro frontend ├── tests/ # Backend NUnit tests ├── doc/ # Database initialization scripts ├── admin-generate-ef-seed-data/ # Seed data generator ├── gitee/ # README image assets └── HZY.Admin.slnx # .NET solution ``` ## Feature Modules | Module | Description | | --- | --- | | User Management | User CRUD, role assignment, password reset | | Role Management | Role settings, menu permissions, function permissions, data permissions | | Menu Management | Menus, routes, function buttons, icons | | API Management | API resources and API permission control | | Organization | Department tree management | | Post Management | Position management | | Dictionary Management | System dictionary maintenance | | File Management | File upload and file metadata management | | Operation Log | User operation logging and querying | | Data Permission | Role-based row-level data filtering | | Localization | Internationalization configuration | | Server Monitor | Server runtime status | | Scheduled Tasks | Quartz task management | | EF Core Monitor | EF Core runtime monitoring | | Personal Center | Profile and password changes | ## Requirements - .NET 10.0 SDK - Node.js 20+ - PostgreSQL 16+ by default - Redis 7+ - Rider or Visual Studio 2022 - VS Code or WebStorm for frontend development Default development endpoints: | Service | URL | | --- | --- | | Backend API | `http://localhost:5500` | | Swagger | `http://localhost:5500/swagger` | | Offline Docs | `http://localhost:5500/docs` | | React Frontend | `http://localhost:8000` | | PostgreSQL | `localhost:5432` | | Redis | `localhost:6379` | Default account: | Login Name | Password | | --- | --- | | `admin` | `123456` | ## Quick Start ### 1. Prepare PostgreSQL and Redis Development settings are in `src/HZY.Host.Admin/appsettings.Development.json`. Defaults: ```text PostgreSQL: User ID=root;Password=123456;Host=localhost;Port=5432;Database=hzy_admin_2026 Redis: 127.0.0.1:6379,password=123456,defaultDatabase=0 ``` Initialize the database: ```bash psql -U root -d hzy_admin_2026 -f doc/hzy_admin_2026_pgsql.sql ``` Or start PostgreSQL and Redis with Docker: ```bash cd src/HZY.Host.Admin docker-compose up -d postgres redis ``` ### 2. Start the Backend ```bash # Run from repository root dotnet restore dotnet run --project src/HZY.Host.Admin ``` ### 3. Start the React Frontend ```bash cd hzy-frontend-admin-react npm install npm run dev ``` The React development server proxies `/api/v1/*` to `http://localhost:5500`. ## Common Commands ### Backend ```bash # Build dotnet build HZY.Admin.slnx # Run tests dotnet test # Run a single test dotnet test --filter "FullyQualifiedName~Test1" # EF Core migrations dotnet ef migrations add --project src/HZY.Host.Admin dotnet ef database update --project src/HZY.Host.Admin ``` ### Frontend ```bash cd hzy-frontend-admin-react # Development server npm run dev # Production build npm run build # Type check npm run tsc # Lint (Biome + TypeScript) npm run lint # Unit tests npm run test # E2E tests npx playwright test ``` ## React Frontend The React frontend lives in `hzy-frontend-admin-react/`: ```text hzy-frontend-admin-react/ ├── config/ │ ├── config.ts # Umi Max configuration │ ├── defaultSettings.ts # ProLayout default theme │ ├── proxy.ts # /api/v1 proxy │ └── routes.ts # Static routes ├── mock/ # Example mocks ├── src/ │ ├── app.tsx # Runtime entry, layout, request │ ├── access.ts # Access control │ ├── components/ # Shared components │ ├── pages/ # Pages │ ├── services/ # API services │ └── utils/ # token, request, menu converter, etc. ├── e2e/ # Playwright E2E tests └── package.json ``` The backend `SysMenu` table uses `react_url` and `react_router` to connect menu records with React pages: - `react_url`: component path, for example `./system/sys_user` - `react_router`: route path, for example `/system/sys_user` ## Backend Architecture Startup flow: ```text Program.cs └── HzyApplication.RunAsync() └── ImportStartupModule ├── CoreQuartzStartup ├── CoreRedisStartup ├── CoreIdentityStartup ├── CoreFileStartup ├── AdminRepositoryStartup ├── CoreSwaggerJwtStartup └── SharedAdminStartup ``` Key conventions: - Dynamic API routes keep their original casing and use the `/api/v1/admin/` prefix. - ASP.NET Core removes the `Async` suffix from action names, so frontend requests should not include `Async`. - `AdminControllerBase` enables `[Authorize]` by default. - `IndentityControllerBase` uses the `/api/v1/identity/` prefix; login and refresh-token endpoints are public. - `ApiAuthorizationMiddleware` handles JWT validation and URL permission checks. - `TakeUpTimeMiddleware` records API execution time and writes `SysOperationLog`. ## Data Permissions Data permission is a role-based row-level filtering mechanism: | Type | Description | | --- | --- | | All Data | No filtering | | Self Only | Only data created by the current user | | Organization Only | Data from the current organization | | Organization and Sub-organizations | Data from the current organization and descendants | | Custom | Manually selected organizations | Priority: 1. Users with `IsAdministrator=true` skip all filtering. 2. If any role has "All Data", no filtering is applied. 3. If any role has "Self Only", filtering is applied by user ID. 4. Organization permissions from multiple roles are merged. Services inheriting `ApplicationService` apply data permissions in standard queries by default. If an entity does not have `CreateBy` or `OrganizationId`, use `DataPermissionConfig` to skip or customize field names. ## Docker Deployment ```bash cd src/HZY.Host.Admin # Start API, PostgreSQL, and Redis docker-compose up -d # View API logs docker-compose logs -f hzy-admin # Stop services docker-compose down ``` Default Docker Compose services: | Service | Port | Description | | --- | --- | --- | | `hzy-admin` | `5500` | Backend API | | `postgres` | `5432` | PostgreSQL | | `redis` | `6379` | Redis | Configuration can be overridden by environment variables: - `AdminRepositoryOptions__ConnectionString` - `AdminRepositoryOptions__DefaultDatabaseType` - `ConnectionStrings__Redis` ## Frontend Production Deployment The React build output is generated in `hzy-frontend-admin-react/dist/`. To serve it from the backend: ```bash cd hzy-frontend-admin-react npm run build # Copy dist contents to backend static directory rsync -a --delete dist/ ../src/HZY.Host.Admin/wwwroot/client/ ``` The backend root path `/` redirects to `/client/index.html`. The React production build uses `publicPath: '/client/'` to match the backend static hosting directory. ## Database Scripts Initialization scripts are stored in `doc/`: | File | Description | | --- | --- | | `hzy_admin_2026_pgsql.sql` | PostgreSQL initialization script | | `hzy_admin_2026_mysql.sql` | MySQL initialization script | For other databases, create the schema with EF Core migrations and import seed data as needed. ## Related Links - Documentation / demo: http://47.98.179.56/docs - Bilibili video: https://www.bilibili.com/video/BV1tt4y157qH - MVC version: https://gitee.com/hzy6/hzy-admin-mvc - WebApi task scheduling platform: https://gitee.com/hzy6/hzy-quartz - NuGet packages: https://www.nuget.org/packages?q=hzy ## Screenshots ### Modular Project Structure ![Project Structure](gitee/images/project_map.jpg) ### Feature List ![Feature List](gitee/images/menu_map_2023-2-3.jpg) ### Microservice Case - Modular Project Structure ![Microservice Structure](gitee/images/project_1.jpg) ### Property Injection ![Property Injection](gitee/images/attr_inj.png) ### UI Screenshots ![UI](gitee/images/winform.png) | ![Dark Theme](gitee/images/theme_dark.png) | ![Dark Theme](gitee/images/theme_dark_1.png) | |---|---| | ![Data Authority](gitee/images/DataAuthority.png) | ![Function Permission](gitee/images/function.png) | |---|---| | ![Menu Info](gitee/images/MenuInfo.png) | ![Menu Function](gitee/images/menu_function.png) | |---|---| | ![Home](gitee/images/home.png) | ![Icons](gitee/images/icons.png) | |---|---| | ![Chart](gitee/images/chart.png) | ![More Charts](gitee/images/%E6%9B%B4%E5%A4%9A%E5%9B%BE%E8%A1%A8.png) | |---|---| | ![User List](gitee/images/user_list.png) | ![Rich Text Editor](gitee/images/wangeditor.png) | |---|---| | ![Code Generation](gitee/images/code_gen.png) | ![User Center](gitee/images/user_center.png) | |---|---| | ![API Docs](gitee/images/api_doc.png) | ![EF Core Monitor](gitee/images/Efcore%20%E7%9B%91%E6%8E%A7.png) | |---|---| ![Home](gitee/images/home1.png) ## Contributing 1. Fork this repository. 2. Create a feature branch, for example `feat_xxx`. 3. Commit your changes and make sure `dotnet test`, `npm run tsc`, and `npm run lint` pass. 4. Open a Pull Request. ## License This project is open-sourced under the [MIT](LICENSE) license.