rts-sim-testing-service/init.go

36 lines
691 B
Go

package main
import (
"fmt"
"time"
"go.uber.org/zap"
"joylink.club/bj-rtsts-server/db/dbquery"
ginzap "github.com/gin-contrib/zap"
"github.com/gin-gonic/gin"
"joylink.club/bj-rtsts-server/config"
"joylink.club/bj-rtsts-server/db"
"joylink.club/bj-rtsts-server/logger"
)
func InitServer() *gin.Engine {
config.LoadConfig()
fmt.Println("数据源配置为:", config.Config.Datasource.Dsn)
err := logger.InitLogger()
if err != nil {
panic(err)
}
err = db.InitDb()
if err != nil {
panic(err)
}
dbquery.SetDefault(db.DB)
engine := gin.New()
engine.Use(ginzap.Ginzap(zap.L(), time.DateTime, false))
engine.Use(ginzap.RecoveryWithZap(zap.L(), true))
return engine
}