diff --git a/apps/system/api/system.go b/apps/system/api/system.go index ab3c576..999bd34 100644 --- a/apps/system/api/system.go +++ b/apps/system/api/system.go @@ -1,6 +1,7 @@ package api import ( + "context" "fmt" "github.com/XM-GO/PandaKit/biz" "github.com/XM-GO/PandaKit/restfulx" @@ -9,6 +10,8 @@ import ( "github.com/gorilla/websocket" "github.com/kakuilan/kgo" "pandax/pkg/middleware" + "pandax/pkg/rule_engine" + "pandax/pkg/rule_engine/message" "runtime" ) @@ -80,3 +83,15 @@ func (s *System) ConnectWs(request *restful.Request, response *restful.Response) la := rc.LoginAccount ws.Put(uint64(la.UserId), wsConn) } + +func (s *System) TestRuleChain(request *restful.Request, response *restful.Response) { + parameter := request.QueryParameter("code") + instance, _ := rule_engine.NewRuleChainInstance([]byte(parameter)) + newMessage := message.NewMessage() + instance.StartRuleChain(context.Background(), newMessage) + + response.WriteEntity(map[string]any{ + "code": 200, + "logs": []map[string]interface{}{}, + }) +} diff --git a/apps/system/router/system.go b/apps/system/router/system.go index 40be1c2..7be0199 100644 --- a/apps/system/router/system.go +++ b/apps/system/router/system.go @@ -11,5 +11,6 @@ func InitSystemRouter(container *restful.Container) { ws.Path("/system").Produces(restful.MIME_JSON) ws.Route(ws.GET("/").To(s.ConnectWs)) ws.Route(ws.GET("/server").To(s.ServerInfo)) + ws.Route(ws.GET("/test/rulechain").To(s.ServerInfo)) container.Add(ws) } diff --git a/pkg/rule_engine/nodes/filter_device_type_switch_node.go b/pkg/rule_engine/nodes/filter_device_type_switch_node.go index 9615b2a..5908330 100644 --- a/pkg/rule_engine/nodes/filter_device_type_switch_node.go +++ b/pkg/rule_engine/nodes/filter_device_type_switch_node.go @@ -11,8 +11,8 @@ const ( GATEWAY = "GATEWAY" ) -//检查关联关系 -//该消息来自与哪个实体或到那个实体 +// 检查关联关系 +// 该消息来自与哪个实体或到那个实体 type deviceTypeSwitchNode struct { bareNode }