feat: add swagger

This commit is contained in:
landaiqing
2024-07-31 18:05:47 +08:00
parent ff0fddd5c3
commit c187b102ed
9 changed files with 214 additions and 26 deletions

View File

@@ -11,6 +11,8 @@ import (
"time"
)
var DB *gorm.DB
func InitConfig() {
viper.SetConfigName("app")
viper.AddConfigPath("config")
@@ -31,10 +33,10 @@ func InitMySQL() *gorm.DB {
Colorful: true, //颜色
})
db, err := gorm.Open(mysql.Open(viper.GetString("mysql.dns")), &gorm.Config{Logger: newLogger})
DB, err := gorm.Open(mysql.Open(viper.GetString("mysql.dns")), &gorm.Config{Logger: newLogger})
if err != nil {
panic("failed to connect database")
}
fmt.Println("config mysql init")
return db
return DB
}