# SevenAdmin **Repository Path**: CoolMoonGG/seven-admin ## Basic Information - **Project Name**: SevenAdmin - **Description**: SevenAdmin 是一个基于 Go + Vue3 的多租户管理后台系统,SaaS 应用设计。它提供了完整的基础功能和强大的代码生成工具,让你专注于业务开发而不是重复的基础代码。 - **Primary Language**: Go - **License**: MIT - **Default Branch**: v2 - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 16 - **Created**: 2026-03-22 - **Last Updated**: 2026-03-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SevenAdmin
SevenAdmin Logo
[![Go Version](https://img.shields.io/badge/Go-1.24+-00ADD8?style=flat&logo=go)](https://golang.org) [![Vue Version](https://img.shields.io/badge/Vue-3.x-4FC08D?style=flat&logo=vue.js)](https://vuejs.org) [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) [English](README_en.md) | [简体中文](README.md) --- ## 📖 Introduction SevenAdmin is a modern multi-tenant admin system based on **Go + Vue3** with SaaS architecture. It provides complete basic features and powerful code generation tools, allowing you to focus on business development. ### ✨ Core Features - **🏢 Multi-Tenant Architecture** - Transparent tenant isolation based on Context with full-chain automatic filtering - **🛠️ Powerful CLI** - One-click generation of complete frontend and backend code (Model, Repository, DTO, Service, Controller, Vue, API) - **🗄️ Multi-Database Support** - Supports SQL (PostgreSQL/MySQL/SQLite) and MongoDB with unified API - **🎯 Complete Basic Features** - User, role, permission, menu, tenant, log, file management, etc. out of the box - **⚡ Modern Tech Stack** - Go + Gin + GORM/MongoDB + Vue3 + TypeScript + Naive UI --- ## 📸 Screenshots ### Menu Management ![Menu Management](doc/image/menu.png) ### File Management ![File Management](doc/image/storage.png) ### Tenant Management ![Tenant Management](doc/image/tenant.png) --- ## 📋 Features | Module | Description | |---------|---------| | **User Management** | User CRUD, role assignment, multiple departments, enable/disable, password reset, quick login | | **Tenant Management** | Tenant CRUD, auto initialization, package configuration, enable/disable | | **Role Management** | Role CRUD, permission configuration, role grouping, batch operations | | **Menu Management** | Dynamic menu, permission binding, tree management | | **Permission Management** | Casbin-based RBAC, menu permissions, button permissions, data permissions | | **Dictionary Management** | Data dictionary categories/items, multi-column sorting, import/export | | **Operation Log** | Record all operations, request tracking, audit features, auto cleanup expired logs | | **File Management** | Multi-storage support (Local/OSS/MinIO/COS/S3), upload/download/preview/delete | | **Message System** | Real-time message push via SSE, multi-tenant message management, read/unread status, message center | | **Scheduled Tasks** | Cron-based task scheduler, system tasks, custom tasks, execution logs, manual execution | --- ## 🚀 Quick Start ### Requirements | Component | Version | |------|---------| | Go | 1.21+ | | Node.js | 18.x+ | | PostgreSQL | 13+ (recommended) / MySQL 8+ / SQLite 3 / MongoDB 6+ | ### 1. Clone Project ```bash git clone https://gitee.com/illusoryNone/seven-admin.git cd seven-admin ``` ### 2. Start Backend > **Note:** No need to manually import database. The system will automatically migrate table structure and initialize default super admin, roles, and menu data. ```bash cd backend # Install dependencies go mod download # Configure database (edit config/config.yaml) vim config/config.yaml # Run project go run cmd/main.go ``` Backend service runs at `http://localhost:8080` ### 3. Start Frontend ```bash cd frontend # Install dependencies pnpm install # Start dev server pnpm dev ``` Frontend service runs at `http://localhost:5173` ### 4. Access System Open browser and visit `http://localhost:5173` Default credentials: - Username: `admin` - Password: `admin123` --- ## 🔧 Core Features ### 1. CLI Code Generator Generate standardized frontend and backend code with one command. #### Build Tool ```bash cd backend go build -o generate cmd/generate/main.go ``` #### Generate Model + Repository ```bash # SQL database (default) ./generate model Product sys_product --comment=Product # MongoDB database ./generate model Product --db=mongo --comment=Product # Non-multi-tenant model ./generate model Tenant sys_tenant --comment=Tenant --tenant=false ``` #### Generate Application Layer (Backend) ```bash # Generate DTO + Service + Controller for existing model ./generate app Product --module=Product --comment=Product ``` #### Generate Frontend Code ```bash # Generate frontend page (TypeScript + Vue + API) ./generate frontend Product --module=product --comment=Product # Short form ./generate fe Product --comment=Product # Support multiple list modes ./generate fe Menu --mode=tree --comment=Menu # Tree list ./generate fe Product --mode=card --comment=Product # Card list ./generate fe Banner --mode=draggable --comment=Banner # Draggable list ``` **Documentation:** [CLI Tool Guide](doc/cli.md) --- ### 2. Multi-Tenant System Context-based transparent tenant isolation, ready to use. #### Request Flow ``` HTTP Request (Header: X-Tenant-ID) ↓ Middleware (Inject TenantID into Context) ↓ Controller (Pass ctx.Request.Context()) ↓ Service (Use ctx) ↓ Repository (Auto apply tenant filtering) ↓ Database (WHERE tenant_id = ?) ``` #### Usage Example ```go // Controller layer func (c *productController) List(ctx *gin.Context) { var req dto.ProductListReq if err := ctx.ShouldBindJSON(&req); err != nil { response.FailWithMsg(ctx, response.ParamsValidError, "Invalid parameters") return } // Use ctx.Request.Context() to pass tenant info data, err := c.srv.List(ctx.Request.Context(), &req) response.CheckAndRespWithData(ctx, data, err) } // Service layer func (s *productService) Create(ctx context.Context, req *dto.ProductCreateReq, operatorID uint) (*dto.ProductRes, error) { entity := &models.Product{ TenantBaseModel: types.TenantBaseModel{ TenantID: 0, // Will be set automatically by middleware CreatedBy: operatorID, }, Name: &req.Name, Price: &req.Price, } // Get tenant ID from context if tenantID, ok := database.GetTenantID(ctx); ok && tenantID > 0 { entity.TenantID = tenantID } // Repository will auto apply tenant filtering if err := s.repo.Create(ctx, entity); err != nil { return nil, err } return s.toDTO(entity), nil } ``` **Documentation:** [Multi-Tenant Guide](doc/multi-tenant-context.md) --- ### 3. Repository Data Access Layer Modern data access layer with unified API for SQL and MongoDB. #### Basic CRUD ```go // Create product := &models.Product{Name: "iPhone 15", Price: 5999} err := productRepo.Create(ctx, product) // Query product, err := productRepo.GetById(ctx, id) // Update product.Price = 6999 err := productRepo.Update(ctx, product) // Delete (soft delete) err := productRepo.Delete(ctx, id) ``` #### Advanced Query ```go // Filter query builder (works for both SQL and MongoDB) filter := types.NewFilter(). Set("status", 1). // WHERE status = 1 Set("price >=", 100). // AND price >= 100 Set("name LIKE", "%phone%"). // AND name LIKE '%phone%' Preload("Category"). // Preload category OrderBy("created_at DESC") // ORDER BY created_at DESC // Same API for SQL and MongoDB products, total, err := productRepo.GetPage(ctx, filter, page, pageSize) // Count count, err := productRepo.Count(ctx, filter) // Existence check exists, err := productRepo.Exists(ctx, filter) // Aggregation sum, err := orderRepo.Sum(ctx, "amount", filter) avg, err := productRepo.Avg(ctx, "price", filter) ``` #### Transaction Support ```go // Transaction with auto commit/rollback err := orderRepo.Transaction(ctx, func(txCtx context.Context) error { // Create order if err := orderRepo.Create(txCtx, order); err != nil { return err } // Reduce stock if err := productRepo.Update(txCtx, product); err != nil { return err } // Return nil to auto commit, return error to auto rollback return nil }) ``` **Documentation:** [Repository Guide](doc/repo.md) --- ## 📚 Documentation | Document | Description | |------|------| | [CLI Tool Guide](doc/cli.md) | Code generator detailed documentation | | [Multi-Tenant Guide](doc/multi-tenant-context.md) | Multi-tenant implementation and usage | | [Repository Guide](doc/repo.md) | Data access layer complete guide | | [Schedule System](doc/schedule-system.md) | Scheduled tasks development and usage guide | | [Route and Menu Guide](doc/route-and-menu-guide.md) | Route and menu configuration | | [Message System](doc/message-system.md) | SSE real-time message push system | --- ## 📄 License This project is licensed under [MIT License](LICENSE). --- ## 📞 Contact - **Gitee**: [https://gitee.com/illusoryNone/seven-admin](https://gitee.com/illusoryNone/seven-admin) - **Issues**: [Submit Issue](https://gitee.com/illusoryNone/seven-admin/issues) ---
**If this project helps you, please give it a ⭐️ Star ⭐️** Made with ❤️ by SevenAdmin Team