🎨 更新环境配置,添加 Dockerfile,优化代码结构

This commit is contained in:
2026-04-21 22:09:19 +08:00
parent 81d8466f88
commit 5c2a146a44
35 changed files with 6396 additions and 141 deletions

View File

@@ -10,5 +10,6 @@ func bizModel() error {
if err != nil {
return err
}
return nil
}

View File

@@ -1,6 +1,8 @@
package initialize
import (
"time"
"git.echol.cn/loser/Go-Web-Template/server/config"
"git.echol.cn/loser/Go-Web-Template/server/global"
"git.echol.cn/loser/Go-Web-Template/server/initialize/internal"
@@ -38,6 +40,8 @@ func initPgSqlDatabase(p config.Pgsql) *gorm.DB {
sqlDB, _ := db.DB()
sqlDB.SetMaxIdleConns(p.MaxIdleConns)
sqlDB.SetMaxOpenConns(p.MaxOpenConns)
sqlDB.SetConnMaxLifetime(30 * time.Minute)
sqlDB.SetConnMaxIdleTime(10 * time.Minute)
return db
}
}

View File

@@ -51,10 +51,11 @@ func Routers() *gin.Engine {
// Router.Static("/assets", "./dist/assets") // dist里面的静态资源
// Router.StaticFile("/", "./dist/index.html") // 前端网页入口页面
// 跨域,如需跨域可以打开下面的注释
Router.Use(middleware.Cors()) // 直接放行全部跨域请求(必须在 StaticFS 之前注册,否则静态文件不带 CORS 头)
// Router.Use(middleware.CorsByRules()) // 按照配置的规则放行跨域请求
Router.StaticFS(global.GVA_CONFIG.Local.StorePath, justFilesFilesystem{http.Dir(global.GVA_CONFIG.Local.StorePath)})
// Router.Use(middleware.LoadTls()) // 如果需要使用https 请打开此中间件 然后前往 core/server.go 将启动模式 更变为 Router.RunTLS("端口","你的cre/pem文件","你的key文件")
// 跨域,如需跨域可以打开下面的注释
Router.Use(middleware.Cors()) // 直接放行全部跨域请求
// Router.Use(middleware.CorsByRules()) // 按照配置的规则放行跨域请求
// global.GVA_LOG.Info("use middleware cors")
docs.SwaggerInfo.BasePath = global.GVA_CONFIG.System.RouterPrefix

View File

@@ -5,7 +5,6 @@ import (
"github.com/gin-gonic/gin"
)
// 占位方法保证文件可以正确加载避免go空变量检测报错请勿删除。
func holder(routers ...*gin.RouterGroup) {
_ = routers
_ = router.RouterGroupApp

View File

@@ -2,6 +2,7 @@ package initialize
import (
"fmt"
"git.echol.cn/loser/Go-Web-Template/server/task"
"github.com/robfig/cron/v3"