feat: swagger

This commit is contained in:
Blizzard
2025-09-16 14:27:32 +08:00
parent 79c19bc47c
commit 237ac665e6
19 changed files with 4690 additions and 91 deletions
+15 -2
View File
@@ -2,11 +2,15 @@ package initialize
import (
"fmt"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"sundynix-go/docs"
"sundynix-go/global"
"sundynix-go/middleware"
"sundynix-go/router"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"go.uber.org/zap"
)
// Routers 初始化总路由
@@ -17,6 +21,8 @@ func Routers() {
if gin.Mode() == gin.DebugMode {
Router.Use(gin.Logger())
}
docs.SwaggerInfo.BasePath = global.Config.System.RouterPrefix
Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
// 系统组路由
systemRouter := router.GroupApp.System
@@ -41,6 +47,13 @@ func Routers() {
}
address := fmt.Sprintf(":%d", global.Config.System.Addr)
fmt.Printf(`
欢迎使用 sundynix-go
项目地址:
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
默认前端文件运行地址:http://127.0.0.1:8080
`, address)
err := Router.Run(address)
if err != nil {
global.Logger.Error("Gin run failed", zap.Error(err))