feat: 增加数据库前缀配置

增加数据库前缀配置
This commit is contained in:
yaoyilin
2022-11-01 10:34:03 +08:00
parent dbd3c3c247
commit fec60fcda9
4 changed files with 7 additions and 2 deletions

View File

@@ -44,6 +44,7 @@ type database struct {
Slave string
Debug bool
Log string
Prev string
}
type redisCfg struct {

View File

@@ -7,6 +7,7 @@ import (
widget2 "gitlab.52pay.top/go/easygoadmin/app/widget"
_ "gitlab.52pay.top/go/easygoadmin/boot"
cfg "gitlab.52pay.top/go/easygoadmin/library/cfg"
"gitlab.52pay.top/go/easygoadmin/router"
_ "gitlab.52pay.top/go/easygoadmin/router"
"html/template"
"path/filepath"
@@ -34,7 +35,7 @@ func main() {
//router.HTMLRender = LoadTemplates("views")
//router.GET("level/index", controller.Level.Index)
//router.GET("position/index", controller.Position.Index)
//router.Run(":8080") // 监听并在 0.0.0.0:8080 上启动服务
router.Router.Run(":9097") // 监听并在 0.0.0.0:8080 上启动服务
}
func LoadTemplates(templatesDir string) multitemplate.Renderer {

View File

@@ -20,6 +20,8 @@ import (
"time"
)
var Router *gin.Engine
func init() {
//gin.SetMode(gin.ReleaseMode)
//gin.SetMode(gin.DebugMode)
@@ -301,6 +303,7 @@ func init() {
example2.POST("/delete/:ids", controller.Example2.Delete)
example2.POST("/setStatus", controller.Example2.Status)
}
Router = router
// 启动
//router.Run(":9097")
}

View File

@@ -48,7 +48,7 @@ func init() {
XormDb.SetMaxOpenConns(30)
// 结构体与数据表的映射
tbMapper := core.NewPrefixMapper(core.SnakeMapper{}, "sys_")
tbMapper := core.NewPrefixMapper(core.SnakeMapper{}, config.Database.Prev)
XormDb.SetTableMapper(tbMapper)
// 开启调试模式和打印日志,会在控制台打印执行的sql