|
@@ -7,13 +7,12 @@ import (
|
|
|
"github.com/gogf/gf/container/gmap"
|
|
|
"github.com/gogf/gf/v2/os/gcron"
|
|
|
"sparrow/pkg/server"
|
|
|
- "sparrow/services/scene-service/internal/service"
|
|
|
)
|
|
|
|
|
|
type TimerSceneConfig struct {
|
|
|
SceneId string `json:"scene_id"`
|
|
|
Conditions []*TimerTaskCondition `json:"conditions"`
|
|
|
- Actions []*service.Action `json:"actions"`
|
|
|
+ Actions []*Action `json:"actions"`
|
|
|
}
|
|
|
|
|
|
type TimerTaskCondition struct {
|
|
@@ -58,9 +57,9 @@ func (t *TimerSceneService) Add(config string) error {
|
|
|
//server.Log.Debugf("AddTimeScene :%s", c.SceneId)
|
|
|
return nil
|
|
|
}
|
|
|
-func (t *TimerSceneService) addTask(c *TimerTaskCondition, actions []*service.Action) error {
|
|
|
+func (t *TimerSceneService) addTask(c *TimerTaskCondition, actions []*Action) error {
|
|
|
_, err := t.cron.AddTimes(context.Background(), c.Cron, c.Times, func(ctx context.Context) {
|
|
|
- if err := service.NewTaskExecutor(actions).Do(); err != nil {
|
|
|
+ if err := NewTaskExecutor(actions).Do(); err != nil {
|
|
|
server.Log.Errorf("do task :%s error:%s", c.TaskId, err.Error())
|
|
|
}
|
|
|
}, c.TaskId)
|