-
Notifications
You must be signed in to change notification settings - Fork 5
/
spacetmplservice.go
35 lines (30 loc) · 929 Bytes
/
spacetmplservice.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package service
import (
"github.com/mangohow/cloud-ide/cmd/webserver/internal/caches"
"github.com/mangohow/cloud-ide/cmd/webserver/internal/dao"
"github.com/mangohow/cloud-ide/cmd/webserver/internal/model"
)
type SpaceTmplService struct {
dao *dao.SpaceTemplateDao
tmplCache *caches.TmplCache
specCache *caches.SpecCache
}
func NewSpaceTmplService() *SpaceTmplService {
d := dao.NewSpaceTemplateDao()
return &SpaceTmplService{
dao: d,
tmplCache: caches.CacheFactory().TmplCache(d),
specCache: caches.CacheFactory().SpecCache(d),
}
}
func (s *SpaceTmplService) GetAllUsingTmpl() ([]*model.SpaceTemplate, []*model.TmplKind, error) {
tmpls := s.tmplCache.GetAllTmpl()
kinds := s.tmplCache.GetAllKinds()
for i := 0; i < len(tmpls); i++ {
tmpls[i].Image = ""
}
return tmpls, kinds, nil
}
func (s *SpaceTmplService) GetAllSpec() ([]*model.SpaceSpec, error) {
return s.specCache.GetAll(), nil
}