2021-09-26 02:35:02 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
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
|
2022-05-05 05:46:55 +00:00
|
|
|
var NewVersionApp map[string]string
|
2022-02-17 10:43:25 +00:00
|
|
|
var SocketRun bool
|
|
|
|
|
2021-09-26 02:35:02 +00:00
|
|
|
type Repository interface {
|
|
|
|
App() AppService
|
|
|
|
User() UserService
|
|
|
|
Docker() DockerService
|
2022-03-09 08:37:03 +00:00
|
|
|
Casa() CasaService
|
2021-09-26 02:35:02 +00:00
|
|
|
Disk() DiskService
|
|
|
|
Notify() NotifyServer
|
|
|
|
Rely() RelyService
|
|
|
|
System() SystemService
|
|
|
|
Shortcuts() ShortcutsService
|
2022-02-17 10:43:25 +00:00
|
|
|
Person() PersonService
|
2022-03-11 10:01:09 +00:00
|
|
|
Friend() FriendService
|
2022-03-16 07:41:14 +00:00
|
|
|
Download() DownloadService
|
2022-05-05 05:46:55 +00:00
|
|
|
DownRecord() DownRecordService
|
2021-09-26 02:35:02 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 10:19:45 +00:00
|
|
|
func NewService(db *gorm.DB) Repository {
|
2021-11-09 10:57:50 +00:00
|
|
|
|
2021-09-26 02:35:02 +00:00
|
|
|
return &store{
|
2022-06-29 03:09:58 +00:00
|
|
|
app: NewAppService(db),
|
|
|
|
user: NewUserService(db),
|
|
|
|
docker: NewDockerService(),
|
|
|
|
casa: NewCasaService(),
|
|
|
|
disk: NewDiskService(db),
|
|
|
|
notify: NewNotifyService(db),
|
|
|
|
rely: NewRelyService(db),
|
|
|
|
system: NewSystemService(),
|
|
|
|
shortcuts: NewShortcutsService(db),
|
|
|
|
person: NewPersonService(db),
|
|
|
|
friend: NewFriendService(db),
|
|
|
|
download: NewDownloadService(db),
|
|
|
|
downrecord: NewDownRecordService(db),
|
2021-09-26 02:35:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type store struct {
|
2022-06-29 03:09:58 +00:00
|
|
|
db *gorm.DB
|
|
|
|
app AppService
|
|
|
|
user UserService
|
|
|
|
docker DockerService
|
|
|
|
casa CasaService
|
|
|
|
disk DiskService
|
|
|
|
notify NotifyServer
|
|
|
|
rely RelyService
|
|
|
|
system SystemService
|
|
|
|
shortcuts ShortcutsService
|
|
|
|
person PersonService
|
|
|
|
friend FriendService
|
|
|
|
download DownloadService
|
|
|
|
downrecord DownRecordService
|
2022-05-05 05:46:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *store) DownRecord() DownRecordService {
|
|
|
|
return c.downrecord
|
2021-09-26 02:35:02 +00:00
|
|
|
}
|
|
|
|
|
2022-03-16 07:41:14 +00:00
|
|
|
func (c *store) Download() DownloadService {
|
|
|
|
return c.download
|
|
|
|
}
|
2022-03-11 10:01:09 +00:00
|
|
|
func (c *store) Friend() FriendService {
|
|
|
|
return c.friend
|
|
|
|
}
|
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) User() UserService {
|
|
|
|
return c.user
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *store) Docker() DockerService {
|
|
|
|
return c.docker
|
|
|
|
}
|
|
|
|
|
2022-03-09 08:37:03 +00:00
|
|
|
func (c *store) Casa() CasaService {
|
|
|
|
return c.casa
|
2021-09-26 02:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *store) Disk() DiskService {
|
|
|
|
return c.disk
|
|
|
|
}
|