This commit is contained in:
2025-07-19 02:03:24 +08:00
commit ac6eeff8c9
44 changed files with 10305 additions and 0 deletions

26
internal/global/global.go Normal file
View File

@ -0,0 +1,26 @@
package global
import (
"sync"
"unR2/internal/config"
"unR2/internal/ent"
)
var (
dbOnce sync.Once
db *ent.Client
AppConfig = &config.Conf
)
func SetDB(client *ent.Client) {
dbOnce.Do(func() {
db = client
})
}
func DB() *ent.Client {
if db == nil {
panic("DB is not initialized")
}
return db
}