mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 00:12:11 +08:00
add user model / service and database maintenance command
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"github.com/mayswind/lab/pkg/datastore"
|
||||
"github.com/mayswind/lab/pkg/settings"
|
||||
"github.com/mayswind/lab/pkg/uuid"
|
||||
)
|
||||
|
||||
type ServiceUsingDB struct {
|
||||
container *datastore.DataStoreContainer
|
||||
}
|
||||
|
||||
func (s *ServiceUsingDB) UserDB() *datastore.Database {
|
||||
return s.container.UserStore.Choose(0)
|
||||
}
|
||||
|
||||
func (s *ServiceUsingDB) TokenDB(uid int64) *datastore.Database {
|
||||
return s.container.TokenStore.Choose(uid)
|
||||
}
|
||||
|
||||
func (s *ServiceUsingDB) UserDataDB(uid int64) *datastore.Database {
|
||||
return s.container.UserDataStore.Choose(uid)
|
||||
}
|
||||
|
||||
type ServiceUsingConfig struct {
|
||||
container *settings.ConfigContainer
|
||||
}
|
||||
|
||||
func (s *ServiceUsingConfig) CurrentConfig() *settings.Config {
|
||||
return s.container.Current
|
||||
}
|
||||
|
||||
type ServiceUsingUuid struct {
|
||||
container *uuid.UuidContainer
|
||||
}
|
||||
|
||||
func (s *ServiceUsingUuid) GenerateUuid(uuidType uuid.UuidType) int64 {
|
||||
return s.container.GenerateUuid(uuidType)
|
||||
}
|
||||
Reference in New Issue
Block a user