CasaOS/service/service.go

107 lines
2.1 KiB
Go
Raw Normal View History

/*
* @Author: LinkLeong link@icewhale.com
* @Date: 2022-07-12 09:48:56
* @LastEditors: LinkLeong
* @LastEditTime: 2022-07-27 10:28:48
* @FilePath: /CasaOS/service/service.go
* @Description:
* @Website: https://www.casaos.io
* Copyright (c) 2022 by icewhale, All Rights Reserved.
*/
2021-09-26 02:35:02 +00:00
package service
import (
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
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
Casa() CasaService
2021-09-26 02:35:02 +00:00
Disk() DiskService
Notify() NotifyServer
Rely() RelyService
System() SystemService
Shares() SharesService
Connections() ConnectionsService
2021-09-26 02:35:02 +00:00
}
func NewService(db *gorm.DB) Repository {
2021-09-26 02:35:02 +00:00
return &store{
app: NewAppService(db),
user: NewUserService(db),
docker: NewDockerService(),
casa: NewCasaService(),
disk: NewDiskService(db),
notify: NewNotifyService(db),
rely: NewRelyService(db),
system: NewSystemService(),
shares: NewSharesService(db),
connections: NewConnectionsService(db),
2021-09-26 02:35:02 +00:00
}
}
type store struct {
db *gorm.DB
app AppService
user UserService
docker DockerService
casa CasaService
disk DiskService
notify NotifyServer
rely RelyService
system SystemService
shares SharesService
connections ConnectionsService
}
func (s *store) Connections() ConnectionsService {
return s.connections
}
func (s *store) Shares() SharesService {
return s.shares
2021-09-26 02:35:02 +00:00
}
func (c *store) Rely() RelyService {
return c.rely
}
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
}
func (c *store) Casa() CasaService {
return c.casa
2021-09-26 02:35:02 +00:00
}
func (c *store) Disk() DiskService {
return c.disk
}