mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-30 00:51:24 +08:00
@@ -1,25 +1,26 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/PandaXGO/PandaKit/model"
|
"pandax/apps/system/api/form"
|
||||||
"github.com/PandaXGO/PandaKit/token"
|
"pandax/apps/system/api/vo"
|
||||||
|
"pandax/apps/system/entity"
|
||||||
|
"pandax/kit/model"
|
||||||
|
"pandax/kit/token"
|
||||||
|
|
||||||
"github.com/dgrijalva/jwt-go"
|
"github.com/dgrijalva/jwt-go"
|
||||||
"github.com/emicklei/go-restful/v3"
|
"github.com/emicklei/go-restful/v3"
|
||||||
"github.com/kakuilan/kgo"
|
"github.com/kakuilan/kgo"
|
||||||
"github.com/mssola/user_agent"
|
"github.com/mssola/user_agent"
|
||||||
"pandax/apps/system/api/form"
|
|
||||||
"pandax/apps/system/api/vo"
|
|
||||||
"pandax/apps/system/entity"
|
|
||||||
|
|
||||||
logEntity "pandax/apps/log/entity"
|
logEntity "pandax/apps/log/entity"
|
||||||
logServices "pandax/apps/log/services"
|
logServices "pandax/apps/log/services"
|
||||||
|
|
||||||
"github.com/PandaXGO/PandaKit/biz"
|
|
||||||
"github.com/PandaXGO/PandaKit/captcha"
|
|
||||||
filek "github.com/PandaXGO/PandaKit/file"
|
|
||||||
"github.com/PandaXGO/PandaKit/restfulx"
|
|
||||||
"github.com/PandaXGO/PandaKit/utils"
|
|
||||||
"pandax/apps/system/services"
|
"pandax/apps/system/services"
|
||||||
|
"pandax/kit/biz"
|
||||||
|
"pandax/kit/captcha"
|
||||||
|
filek "pandax/kit/file"
|
||||||
|
"pandax/kit/restfulx"
|
||||||
|
"pandax/kit/utils"
|
||||||
"pandax/pkg/global"
|
"pandax/pkg/global"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -37,7 +38,7 @@ type UserApi struct {
|
|||||||
|
|
||||||
// GenerateCaptcha 获取验证码
|
// GenerateCaptcha 获取验证码
|
||||||
func (u *UserApi) GenerateCaptcha(request *restful.Request, response *restful.Response) {
|
func (u *UserApi) GenerateCaptcha(request *restful.Request, response *restful.Response) {
|
||||||
id, image := captcha.Generate()
|
id, image, _ := captcha.Generate()
|
||||||
response.WriteEntity(vo.CaptchaVo{Base64Captcha: image, CaptchaId: id})
|
response.WriteEntity(vo.CaptchaVo{Base64Captcha: image, CaptchaId: id})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ type RpcRequest struct {
|
|||||||
// RequestCmd 下发指令
|
// RequestCmd 下发指令
|
||||||
func (rpc RpcRequest) RequestCmd(deviceId, rpcPayload string) error {
|
func (rpc RpcRequest) RequestCmd(deviceId, rpcPayload string) error {
|
||||||
topic := fmt.Sprintf(RpcReqTopic, rpc.RequestId)
|
topic := fmt.Sprintf(RpcReqTopic, rpc.RequestId)
|
||||||
value, ok := MqttClient.Load(deviceId)
|
value, ok := Session.Load(deviceId)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("为获取到设备的MQTT连接")
|
return errors.New("为获取到设备的MQTT连接")
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ func (rpc RpcRequest) RequestCmd(deviceId, rpcPayload string) error {
|
|||||||
|
|
||||||
func (rpc RpcRequest) Pub(deviceId, reqPayload string) error {
|
func (rpc RpcRequest) Pub(deviceId, reqPayload string) error {
|
||||||
topic := fmt.Sprintf(RpcRespTopic, rpc.RequestId)
|
topic := fmt.Sprintf(RpcRespTopic, rpc.RequestId)
|
||||||
value, ok := MqttClient.Load(deviceId)
|
value, ok := Session.Load(deviceId)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("为获取到设备的MQTT连接")
|
return errors.New("为获取到设备的MQTT连接")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,23 +38,23 @@ func newInstanceWithManifest(m *manifest.Manifest) (*RuleChainInstance, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
r := &RuleChainInstance{
|
r := &RuleChainInstance{
|
||||||
firstRuleNodeID: m.FirstRuleNodeID,
|
firstRuleNodeID: m.FirstRuleNodeId,
|
||||||
nodes: nodes,
|
nodes: nodes,
|
||||||
}
|
}
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RuleChainInstance) StartRuleChain(ctx context.Context, msg *message.Message) error {
|
func (c *RuleChainInstance) StartRuleChain(ctx context.Context, msg *message.Message) error {
|
||||||
debugChan := make(chan *message.DebugMessage, 100)
|
debugChan := make(chan *message.DebugData, 100)
|
||||||
endDebugChan := make(chan struct{})
|
endDebugChan := make(chan struct{})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case debugMsg := <-debugChan:
|
case debugMsg := <-debugChan:
|
||||||
ruleChainDebugData.Add(c.ruleID, debugMsg.NodeID, debugMsg)
|
ruleChainDebugData.Add(c.ruleID, debugMsg.NodeId, *debugMsg)
|
||||||
case <-endDebugChan:
|
case <-endDebugChan:
|
||||||
logrus.Debugf("规则链%s,执行结束", msg.ID)
|
logrus.Debugf("规则链%s,执行结束", msg.Id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user