### Install Dependencies and Develop Web Project Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/README-en.md Instructions for setting up the web project, including installing dependencies and starting the development server. Navigate to the 'web' directory first. ```bash cd web npm install npm run serve ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/web/README.md Run this command to install all necessary dependencies for the project. ```bash npm install ``` -------------------------------- ### Install Swagger (Outside Mainland China) Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/README-en.md Command to install the Swagger tool using go get. This method is recommended for users outside of mainland China. ```bash go get -u github.com/swaggo/swag/cmd/swag ``` -------------------------------- ### Clone and Run Server Project Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/README-en.md Steps to clone the server project, install dependencies, compile, and run the binary. Ensure you are in the 'server' directory after cloning. ```bash git clone https://github.com/flipped-aurora/gin-vue-admin.git cd server go generate go build -o server main.go (windows the compile command is go build -o server.exe main.go ) ./server (windows The run command is server.exe) ``` -------------------------------- ### Compile and Hot-Reload for Development Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/web/README.md Use this command to start the development server, which includes hot-reloading for faster development cycles. ```bash npm run serve ``` -------------------------------- ### Go Service Example: Get Order List Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/aiDoc/examples/backend/service-example.md This Go code snippet demonstrates how to implement a service function to retrieve a paginated and filtered list of orders from the database. It handles query building, filtering by name and status, and pagination. ```go package system import ( "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/system" systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" ) type OrderService struct{} func (s *OrderService) GetOrderList(info systemReq.OrderSearch) (list []system.Order, total int64, err error) { limit := info.PageSize offset := info.PageSize * (info.Page - 1) db := global.GVA_DB.Model(&system.Order{}) if info.Name != "" { db = db.Where("name LIKE ?", "%"+info.Name+"%") } if info.Status != nil { db = db.Where("status = ?", *info.Status) } err = db.Count(&total).Error if err != nil { return nil, 0, err } err = db.Limit(limit).Offset(offset).Order("id desc").Find(&list).Error return list, total, err } ``` -------------------------------- ### Install Go Modules for Server Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/README-en.md Command to install or update Go modules for the server project using go.mod. ```bash go list (go mod tidy) ``` -------------------------------- ### Initialize Email Plugin with Configuration Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/plugin/email/README.MD Integrate the email plugin into the GVA router by calling PluginInit. This example shows how to pass configuration values from the GVA config file. ```go PluginInit(PrivateGroup, email.CreateEmailPlug( global.GVA_CONFIG.Email.To, global.GVA_CONFIG.Email.From, global.GVA_CONFIG.Email.Host, global.GVA_CONFIG.Email.Secret, global.GVA_CONFIG.Email.Nickname, global.GVA_CONFIG.Email.Port, global.GVA_CONFIG.Email.IsSSL, global.GVA_CONFIG.Email.IsLoginAuth, )) ``` -------------------------------- ### Initialize Email Plugin with Hardcoded Values Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/plugin/email/README.MD Integrate the email plugin into the GVA router by calling PluginInit. This example demonstrates passing configuration values directly within the function call. ```go PluginInit(PrivateGroup, email.CreateEmailPlug( "a@qq.com", "b@qq.com", "smtp.qq.com", "global.GVA_CONFIG.Email.Secret", "登录密钥", 465, true, true, )) ``` -------------------------------- ### Frontend Plugin API Example Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/aiDoc/examples/plugin/full-plugin-example.md This JavaScript file defines API request functions for the frontend plugin, specifically for order-related operations. ```javascript import { get, post } from '@/utils/request' export const getOrderList = (data) => { return get('/order/getOrderList', data) } export const addOrder = (data) => { return post('/order/addOrder', data) } export const editOrder = (data) => { return post('/order/editOrder', data) } export const deleteOrder = (data) => { return post('/order/deleteOrder', data) } ``` -------------------------------- ### GVA Email Sending Plugin Setup and Configuration Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/plugin/email/README.MD Instructions on how to integrate the email plugin into your GVA application and details on configuration options. ```APIDOC ## GVA 邮件发送功能插件 ### 使用步骤 #### 1. 前往GVA主程序下的initialize/router.go 在Routers 方法最末尾按照你需要的及安全模式添加本插件 例: 本插件可以采用gva的配置文件 也可以直接写死内容作为配置 建议为gva添加配置文件结构 然后将配置传入 PluginInit(PrivateGroup, email.CreateEmailPlug( global.GVA_CONFIG.Email.To, global.GVA_CONFIG.Email.From, global.GVA_CONFIG.Email.Host, global.GVA_CONFIG.Email.Secret, global.GVA_CONFIG.Email.Nickname, global.GVA_CONFIG.Email.Port, global.GVA_CONFIG.Email.IsSSL, global.GVA_CONFIG.Email.IsLoginAuth, )) 同样也可以再传入时写死 PluginInit(PrivateGroup, email.CreateEmailPlug( "a@qq.com", "b@qq.com", "smtp.qq.com", "global.GVA_CONFIG.Email.Secret", "登录密钥", 465, true, true, )) ### 2. 配置说明 #### 2-1 全局配置结构体说明 //其中 Form 和 Secret 通常来说就是用户名和密码 type Email struct { To string // 收件人:多个以英文逗号分隔 例:a@qq.com b@qq.com 正式开发中请把此项目作为参数使用 此处配置主要用于发送错误监控邮件 From string // 发件人 你自己要发邮件的邮箱 Host string // 服务器地址 例如 smtp.qq.com 请前往QQ或者你要发邮件的邮箱查看其smtp协议 Secret string // 密钥 用于登录的密钥 最好不要用邮箱密码 去邮箱smtp申请一个用于登录的密钥 Nickname string // 昵称 发件人昵称 自定义即可 可以不填 Port int // 端口 请前往QQ或者你要发邮件的邮箱查看其smtp协议 大多为 465 IsSSL bool // 是否SSL 是否开启SSL IsLoginAuth bool // 是否LoginAuth 是否使用LoginAuth认证方式(适用于IBM、微软邮箱服务器等) } #### 2-2 入参结构说明 //其中 Form 和 Secret 通常来说就是用户名和密码 type Email struct { To string `json:"to"` // 邮件发送给谁 Subject string `json:"subject"` // 邮件标题 Body string `json:"body"` // 邮件内容 } ``` -------------------------------- ### Backend Plugin Initialization - Service Entry Point Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/aiDoc/examples/plugin/full-plugin-example.md This file acts as the entry point for the plugin's service layer, aggregating service definitions. ```go package service var ( UserService = &userService{} ) ``` -------------------------------- ### Backend Plugin Initialization - API Entry Point Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/aiDoc/examples/plugin/full-plugin-example.md This file serves as the entry point for the plugin's API layer, aggregating API definitions. ```go package api var ( UserService = &userService{} ) ``` -------------------------------- ### Compile and Minify for Production Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/web/README.md Execute this command to build a production-ready, minified version of the project. ```bash npm run build ``` -------------------------------- ### Build Server Binary Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/README-en.md Command to build the server executable. This command assumes you are using go.mod. ```bash go build ``` -------------------------------- ### Run Project Tests Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/web/README.md This command executes the project's test suite. ```bash npm run test ``` -------------------------------- ### Gin-Vue-Admin Web Project Structure Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/web/README.md Overview of the gin-vue-admin web project's directory and file structure. ```lua web ├── babel.config.js ├── Dockerfile ├── favicon.ico ├── index.html -- 主页面 ├── limit.js -- 助手代码 ├── package.json -- 包管理器代码 ├── src -- 源代码 │ ├── api -- api 组 │ ├── App.vue -- 主页面 │ ├── assets -- 静态资源 │ ├── components -- 全局组件 │ ├── core -- gva 组件包 │ │ ├── config.js -- gva网站配置文件 │ │ ├── gin-vue-admin.js -- 注册欢迎文件 │ │ └── global.js -- 统一导入文件 │ ├── directive -- v-auth 注册文件 │ ├── main.js -- 主文件 │ ├── permission.js -- 路由中间件 │ ├── pinia -- pinia 状态管理器,取代vuex │ │ ├── index.js -- 入口文件 │ │ └── modules -- modules │ │ ├── dictionary.js │ │ ├── router.js │ │ └── user.js │ ├── router -- 路由声明文件 │ │ └── index.js │ ├── style -- 全局样式 │ │ ├── base.scss │ │ ├── basics.scss │ │ ├── element_visiable.scss -- 此处可以全局覆盖 element-plus 样式 │ │ ├── iconfont.css -- 顶部几个icon的样式文件 │ │ ├── main.scss │ │ ├── mobile.scss │ │ └── newLogin.scss │ ├── utils -- 方法包库 │ │ ├── asyncRouter.js -- 动态路由相关 │ │ ├── bus.js -- 全局mitt声明文件 │ │ ├── date.js -- 日期相关 │ │ ├── dictionary.js -- 获取字典方法 │ │ ├── downloadImg.js -- 下载图片方法 │ │ ├── format.js -- 格式整理相关 │ │ ├── image.js -- 图片相关方法 │ │ ├── page.js -- 设置页面标题 │ │ ├── request.js -- 请求 │ │ └── stringFun.js -- 字符串文件 | ├── view -- 主要view代码 | | ├── about -- 关于我们 | | ├── dashboard -- 面板 | | ├── error -- 错误 | | ├── example --上传案例 | | ├── iconList -- icon列表 | | ├── init -- 初始化数据 | | | ├── index -- 新版本 | | | ├── init -- 旧版本 | | ├── layout -- layout约束页面 | | | ├── aside | | | ├── bottomInfo -- bottomInfo | | | ├── screenfull -- 全屏设置 | | | ├── setting -- 系统设置 | | | └── index.vue -- base 约束 | | ├── login --登录 | | ├── person --个人中心 | | ├── superAdmin -- 超级管理员操作 | | ├── system -- 系统检测页面 | | ├── systemTools -- 系统配置相关页面 | | └── routerHolder.vue -- page 入口页面 ├── vite.config.js -- vite 配置文件 └── yarn.lock ``` -------------------------------- ### Recommended Backend Plugin Directory Structure Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/aiDoc/examples/plugin/full-plugin-example.md This structure provides a clear separation of concerns for backend plugin development, including API, configuration, initialization, models, routing, and service layers. ```text server/plugin/order/ ├── api/ │ ├── enter.go │ └── order.go ├── config/ │ └── config.go ├── initialize/ │ ├── api.go │ ├── gorm.go │ ├── menu.go │ ├── router.go │ └── viper.go ├── model/ │ ├── order.go │ └── request/order.go ├── router/ │ ├── enter.go │ └── order.go ├── service/ │ ├── enter.go │ └── order.go └── plugin.go ``` -------------------------------- ### Initialize Order Router Groups with Middleware Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/aiDoc/examples/backend/router-example.md This snippet demonstrates how to initialize router groups for 'order' related routes in a Gin application. It shows how to apply middleware like OperationRecord to specific groups and exclude it from others. ```go package system import ( "github.com/flipped-aurora/gin-vue-admin/server/middleware" "github.com/gin-gonic/gin" ) type OrderRouter struct{} func (r *OrderRouter) InitOrderRouter(Router *gin.RouterGroup) { orderRouter := Router.Group("order").Use(middleware.OperationRecord()) orderRouterWithoutRecord := Router.Group("order") { orderRouter.POST("createOrder", orderApi.CreateOrder) orderRouter.PUT("updateOrder", orderApi.UpdateOrder) orderRouter.DELETE("deleteOrder", orderApi.DeleteOrder) } { orderRouterWithoutRecord.POST("getOrderList", orderApi.GetOrderList) orderRouterWithoutRecord.GET("findOrder", orderApi.FindOrder) } } ``` -------------------------------- ### Go Request Structs for Order Creation and Search Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/aiDoc/examples/backend/request-example.md Defines structs for creating orders and searching orders, including pagination and filtering fields. Use these for new list query parameters, create/update request bodies, or when reusing pagination/sorting/filtering fields. ```go package request import common "github.com/flipped-aurora/gin-vue-admin/server/model/common/request" type CreateOrderReq struct { Name string `json:"name" form:"name"` Status int `json:"status" form:"status"` Remark string `json:"remark" form:"remark"` } type OrderSearch struct { common.PageInfo Name string `json:"name" form:"name"` Status *int `json:"status" form:"status"` OrderKey string `json:"orderKey" form:"orderKey"` Desc bool `json:"desc" form:"desc"` } ``` -------------------------------- ### Recommended Frontend Plugin Directory Structure Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/aiDoc/examples/plugin/full-plugin-example.md This structure mirrors the backend plugin organization, facilitating a symmetrical approach to frontend plugin development with distinct directories for API, components, forms, and views. ```text web/src/plugin/order/ ├── api/ │ └── order.js ├── components/ ├── form/ ├── view/ │ └── index.vue └── config.js ``` -------------------------------- ### Lint and Fix Files Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/web/README.md Run this command to lint the project files and automatically fix any style issues. ```bash npm run lint ``` -------------------------------- ### Email Configuration Structure Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/plugin/email/README.MD Defines the structure for global email configuration settings. 'Form' and 'Secret' typically represent username and password. ```go type Email struct { To string // 收件人:多个以英文逗号分隔 例:a@qq.com b@qq.com 正式开发中请把此项目作为参数使用 此处配置主要用于发送错误监控邮件 From string // 发件人 你自己要发邮件的邮箱 Host string // 服务器地址 例如 smtp.qq.com 请前往QQ或者你要发邮件的邮箱查看其smtp协议 Secret string // 密钥 用于登录的密钥 最好不要用邮箱密码 去邮箱smtp申请一个用于登录的密钥 Nickname string // 昵称 发件人昵称 自定义即可 可以不填 Port int // 端口 请前往QQ或者你要发邮件的邮箱查看其smtp协议 大多为 465 IsSSL bool // 是否SSL 是否开启SSL IsLoginAuth bool // 是否LoginAuth 是否使用LoginAuth认证方式(适用于IBM、微软邮箱服务器等) } ``` -------------------------------- ### Send Test Email Utility Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/plugin/email/README.MD Utility function to send a test email. Requires a subject and body as arguments. ```go utils.EmailTest("测试邮件","测试邮件") ``` -------------------------------- ### VSCode Go Tool Environment Variables Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/README.md Configure Go tool environment variables within VSCode workspace settings. Use 'go.gopath' and 'go.goroot' to specify Go versions in multi-version systems. ```json "go.gopath": null, "go.goroot": null, ``` -------------------------------- ### Send Error Monitoring Email Utility Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/plugin/email/README.MD Utility function for sending error monitoring emails. Requires a subject and body as arguments. ```go utils.ErrorToEmail("测试邮件","测试邮件") ``` -------------------------------- ### Email Input Structure for API Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/plugin/email/README.MD Defines the input structure for email sending operations via API. 'Form' and 'Secret' typically represent username and password. ```go type Email struct { To string `json:"to"` // 邮件发送给谁 Subject string `json:"subject"` // 邮件标题 Body string `json:"body"` // 邮件内容 } ``` -------------------------------- ### GVA Email Sending Plugin Utility Methods Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/plugin/email/README.MD Available utility functions for sending emails within the GVA application. ```APIDOC ### 3. 方法API utils.EmailTest(邮件标题,邮件主体) 发送测试邮件 例:utils.EmailTest("测试邮件","测试邮件") utils.ErrorToEmail(邮件标题,邮件主体) 错误监控 例:utils.ErrorToEmail("测试邮件","测试邮件") utils.Email(目标邮箱多个的话用逗号分隔,邮件标题,邮件主体) 发送测试邮件 例:utils.Email(”a.qq.com,b.qq.com“,"测试邮件","测试邮件") ``` -------------------------------- ### POST /email/emailTest Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/plugin/email/README.MD An endpoint to test email sending functionality. It is configured with Swagger. ```APIDOC ## POST /email/emailTest ### Description Tests the email sending functionality. ### Method POST ### Endpoint /email/emailTest ### Parameters #### Query Parameters - **title** (string) - Required - The title of the test email. - **body** (string) - Required - The body content of the test email. ### Request Example ```json { "title": "Test Email Title", "body": "This is the body of the test email." } ``` ### Response #### Success Response (200) - **msg** (string) - A success message indicating the email was sent. #### Response Example ```json { "msg": "Email sent successfully" } ``` -------------------------------- ### Send Email Utility with Multiple Recipients Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/plugin/email/README.MD Utility function to send an email to multiple recipients. Recipients are provided as a comma-separated string, along with the subject and body. ```go utils.Email(”a.qq.com,b.qq.com“,"测试邮件","测试邮件") ``` -------------------------------- ### POST /email/emailSend Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/plugin/email/README.MD An endpoint to send emails. It accepts email details in the request body and is configured with Swagger. ```APIDOC ## POST /email/emailSend ### Description Sends an email to specified recipients. ### Method POST ### Endpoint /email/emailSend ### Parameters #### Request Body - **to** (string) - Required - The recipient's email address. Multiple addresses can be separated by commas. - **subject** (string) - Required - The subject of the email. - **body** (string) - Required - The content of the email. ### Request Example ```json { "to": "recipient@example.com", "subject": "Important Notification", "body": "This is the content of the email." } ``` ### Response #### Success Response (200) - **msg** (string) - A success message indicating the email was sent. #### Response Example ```json { "msg": "Email sent successfully" } ``` -------------------------------- ### Root-Level Aggregation in Go Service Layer Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/aiDoc/examples/backend/enter-go-example.md Aggregates service groups at the root level. Import necessary service modules and declare a `ServiceGroup` struct to hold them. ```go package service import ( "github.com/flipped-aurora/gin-vue-admin/server/service/example" "github.com/flipped-aurora/gin-vue-admin/server/service/system" ) var ServiceGroupApp = new(ServiceGroup) type ServiceGroup struct { SystemServiceGroup system.ServiceGroup ExampleServiceGroup example.ServiceGroup } ``` -------------------------------- ### Module-Level Aggregation in Go System Router Layer Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/aiDoc/examples/backend/enter-go-example.md Aggregates router groups within a specific module (e.g., system). Define a `RouterGroup` struct and alias commonly used APIs. ```go package system import api "github.com/flipped-aurora/gin-vue-admin/server/api/v1" type RouterGroup struct { UserRouter OrderRouter } var ( baseApi = api.ApiGroupApp.SystemApiGroup.BaseApi orderApi = api.ApiGroupApp.SystemApiGroup.OrderApi ) ``` -------------------------------- ### Decode WeChat Group QR Code String Source: https://github.com/flipped-aurora/gin-vue-admin/blob/main/README.md Decode a base64 encoded string to obtain information for joining the WeChat group. This is used to prevent automated bot entries. ```go str := "5Yqg5YWlR1ZB5Lqk5rWB576k" decodeBytes, err := base64.StdEncoding.DecodeString(str) fmt.Println(decodeBytes, err) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.