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"
|
2021-10-29 10:37:27 +00:00
|
|
|
"github.com/patrickmn/go-cache"
|
2021-09-26 02:35:02 +00:00
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
2021-10-29 10:37:27 +00:00
|
|
|
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
|
2021-11-03 09:07:46 +00:00
|
|
|
OAPI() CasaService
|
2021-09-26 02:35:02 +00:00
|
|
|
Disk() DiskService
|
|
|
|
Notify() NotifyServer
|
|
|
|
ShareDirectory() ShareDirService
|
|
|
|
Task() TaskService
|
|
|
|
Rely() RelyService
|
|
|
|
System() SystemService
|
|
|
|
Shortcuts() ShortcutsService
|
2021-10-15 03:43:41 +00:00
|
|
|
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-11-09 10:57:50 +00:00
|
|
|
|
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(),
|
|
|
|
oapi: NewOasisService(),
|
2021-12-09 11:02:41 +00:00
|
|
|
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),
|
2021-10-15 03:43:41 +00:00
|
|
|
search: NewSearchService(),
|
2022-02-17 10:43:25 +00:00
|
|
|
person: NewPersonService(),
|
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
|
2021-11-03 09:07:46 +00:00
|
|
|
oapi CasaService
|
2021-09-26 02:35:02 +00:00
|
|
|
disk DiskService
|
|
|
|
notify NotifyServer
|
|
|
|
shareDirectory ShareDirService
|
|
|
|
task TaskService
|
|
|
|
rely RelyService
|
|
|
|
system SystemService
|
|
|
|
shortcuts ShortcutsService
|
2021-10-15 03:43:41 +00:00
|
|
|
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
|
|
|
|
}
|
2021-11-03 09:07:46 +00:00
|
|
|
func (c *store) OAPI() CasaService {
|
2021-09-26 02:35:02 +00:00
|
|
|
return c.oapi
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *store) Disk() DiskService {
|
|
|
|
return c.disk
|
|
|
|
}
|
|
|
|
func (c *store) ShareDirectory() ShareDirService {
|
|
|
|
return c.shareDirectory
|
|
|
|
}
|
|
|
|
func (c *store) Task() TaskService {
|
|
|
|
return c.task
|
|
|
|
}
|
2021-10-15 03:43:41 +00:00
|
|
|
func (c *store) Search() SearchService {
|
|
|
|
return c.search
|
|
|
|
}
|