mirror of
https://github.com/gl-inet/glkvm-cloud.git
synced 2026-09-23 03:03:21 +00:00
7931fa0efd
Refactor legacy login endpoint and keep compatibility with existing authentication logic. Signed-off-by: GL.iNet-Yongping.Xie <yongping.xie@gl-inet.com>
32 lines
474 B
Go
Executable File
32 lines
474 B
Go
Executable File
package sqlite
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"sync"
|
|
)
|
|
|
|
type Container struct {
|
|
Gorm *gorm.DB
|
|
DeviceMeta *DeviceMetaRepo
|
|
}
|
|
|
|
var (
|
|
gContainer *Container
|
|
mu sync.RWMutex
|
|
)
|
|
|
|
func SetContainer(c *Container) {
|
|
mu.Lock()
|
|
defer mu.Unlock()
|
|
gContainer = c
|
|
}
|
|
|
|
func MustContainer() *Container {
|
|
mu.RLock()
|
|
defer mu.RUnlock()
|
|
if gContainer == nil {
|
|
panic("sqlite container not initialized")
|
|
}
|
|
return gContainer
|
|
}
|