CasaOS/service/service.go

136 lines
2.8 KiB
Go
Raw Normal View History

2021-09-26 02:35:02 +00:00
package service
import (
2021-09-27 06:17:36 +00:00
loger2 "github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
2022-02-17 10:43:25 +00:00
"github.com/gorilla/websocket"
"github.com/patrickmn/go-cache"
2021-09-26 02:35:02 +00:00
"gorm.io/gorm"
)
var Cache *cache.Cache
2021-09-26 02:35:02 +00:00
var MyService Repository
2022-02-17 10:43:25 +00:00
var WebSocketConns []*websocket.Conn
var SocketRun bool
2021-09-26 02:35:02 +00:00
type Repository interface {
App() AppService
DDNS() DDNSService
User() UserService
Docker() DockerService
//Redis() RedisService
ZeroTier() ZeroTierService
ZiMa() ZiMaService
Casa() CasaService
2021-09-26 02:35:02 +00:00
Disk() DiskService
Notify() NotifyServer
ShareDirectory() ShareDirService
Task() TaskService
Rely() RelyService
System() SystemService
Shortcuts() ShortcutsService
Search() SearchService
2022-02-17 10:43:25 +00:00
Person() PersonService
2021-09-26 02:35:02 +00:00
}
func NewService(db *gorm.DB, log loger2.OLog) Repository {
2021-09-26 02:35:02 +00:00
return &store{
app: NewAppService(db, log),
ddns: NewDDNSService(db, log),
user: NewUserService(),
2021-12-03 08:48:07 +00:00
docker: NewDockerService(log),
2021-09-26 02:35:02 +00:00
//redis: NewRedisService(rp),
zerotier: NewZeroTierService(),
zima: NewZiMaService(),
casa: NewCasaService(),
disk: NewDiskService(log, db),
2021-09-26 02:35:02 +00:00
notify: NewNotifyService(db),
shareDirectory: NewShareDirService(db, log),
task: NewTaskService(db, log),
rely: NewRelyService(db, log),
2021-09-27 06:17:36 +00:00
system: NewSystemService(log),
2021-09-26 02:35:02 +00:00
shortcuts: NewShortcutsService(db),
search: NewSearchService(),
person: NewPersonService(db),
2021-09-26 02:35:02 +00:00
}
}
type store struct {
db *gorm.DB
app AppService
ddns DDNSService
user UserService
docker DockerService
zerotier ZeroTierService
zima ZiMaService
casa CasaService
2021-09-26 02:35:02 +00:00
disk DiskService
notify NotifyServer
shareDirectory ShareDirService
task TaskService
rely RelyService
system SystemService
shortcuts ShortcutsService
search SearchService
2022-02-17 10:43:25 +00:00
person PersonService
2021-09-26 02:35:02 +00:00
}
func (c *store) Rely() RelyService {
return c.rely
}
func (c *store) Shortcuts() ShortcutsService {
return c.shortcuts
}
2022-02-17 10:43:25 +00:00
func (c *store) Person() PersonService {
return c.person
}
2021-09-26 02:35:02 +00:00
func (c *store) System() SystemService {
return c.system
}
func (c *store) Notify() NotifyServer {
return c.notify
}
func (c *store) App() AppService {
return c.app
}
func (c *store) DDNS() DDNSService {
return c.ddns
}
func (c *store) User() UserService {
return c.user
}
func (c *store) Docker() DockerService {
return c.docker
}
func (c *store) ZeroTier() ZeroTierService {
return c.zerotier
}
func (c *store) ZiMa() ZiMaService {
return c.zima
}
func (c *store) Casa() CasaService {
return c.casa
2021-09-26 02:35:02 +00:00
}
func (c *store) Disk() DiskService {
return c.disk
}
func (c *store) ShareDirectory() ShareDirService {
return c.shareDirectory
}
func (c *store) Task() TaskService {
return c.task
}
func (c *store) Search() SearchService {
return c.search
}