auth service

This commit is contained in:
2025-01-20 16:22:41 +08:00
parent 76d3d6f20a
commit bda2501bae
40 changed files with 3340 additions and 1 deletions
+33
View File
@@ -0,0 +1,33 @@
package mysql
import (
"fmt"
"github.com/joho/godotenv"
"github.com/suyiiyii/hertz101/app/auth/conf"
"os"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
var (
DB *gorm.DB
err error
)
func Init() {
err := godotenv.Load()
if err != nil {
panic(err)
}
dsn := fmt.Sprintf(conf.GetConf().MySQL.DSN, os.Getenv("MYSQL_USER"), os.Getenv("MYSQL_PASSWORD"), os.Getenv("MYSQL_HOST"), os.Getenv("MYSQL_PORT"))
DB, err = gorm.Open(mysql.Open(dsn),
&gorm.Config{
PrepareStmt: true,
SkipDefaultTransaction: true,
},
)
if err != nil {
panic(err)
}
}