-
Notifications
You must be signed in to change notification settings - Fork 38
/
plugin.go
51 lines (45 loc) · 1.46 KB
/
plugin.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package interactor
import (
"context"
"github.com/reearth/reearth/server/internal/usecase"
"github.com/reearth/reearth/server/internal/usecase/gateway"
"github.com/reearth/reearth/server/internal/usecase/interfaces"
"github.com/reearth/reearth/server/internal/usecase/repo"
"github.com/reearth/reearth/server/pkg/id"
"github.com/reearth/reearth/server/pkg/plugin"
"github.com/reearth/reearthx/usecasex"
)
type Plugin struct {
common
sceneRepo repo.Scene
pluginRepo repo.Plugin
propertySchemaRepo repo.PropertySchema
propertyRepo repo.Property
layerRepo repo.Layer
file gateway.File
pluginRegistry gateway.PluginRegistry
transaction usecasex.Transaction
}
func NewPlugin(r *repo.Container, gr *gateway.Container) interfaces.Plugin {
return &Plugin{
sceneRepo: r.Scene,
layerRepo: r.Layer,
pluginRepo: r.Plugin,
propertySchemaRepo: r.PropertySchema,
propertyRepo: r.Property,
transaction: r.Transaction,
file: gr.File,
pluginRegistry: gr.PluginRegistry,
}
}
func (i *Plugin) pluginCommon() *pluginCommon {
return &pluginCommon{
pluginRepo: i.pluginRepo,
propertySchemaRepo: i.propertySchemaRepo,
file: i.file,
pluginRegistry: i.pluginRegistry,
}
}
func (i *Plugin) Fetch(ctx context.Context, ids []id.PluginID, operator *usecase.Operator) ([]*plugin.Plugin, error) {
return i.pluginRepo.FindByIDs(ctx, ids)
}