This commit is contained in:
PandaX-Go
2024-08-25 19:58:05 +08:00
parent 96e2500fad
commit 77ac18c21b
157 changed files with 249 additions and 5190 deletions

View File

@@ -2,7 +2,7 @@ package cache
import (
"context"
"pandax/kit/rediscli"
"github.com/PandaXGO/PandaKit/rediscli"
"time"
)

View File

@@ -1,7 +1,7 @@
package cache
import (
"pandax/kit/cache"
"github.com/PandaXGO/PandaKit/cache"
"time"
)

View File

@@ -1,7 +1,7 @@
package cache
import (
"pandax/kit/cache"
"github.com/PandaXGO/PandaKit/cache"
"strings"
"time"
)

View File

@@ -3,8 +3,8 @@ package config
import (
"flag"
"fmt"
"pandax/kit/biz"
"pandax/kit/utils"
"github.com/PandaXGO/PandaKit/biz"
"github.com/PandaXGO/PandaKit/utils"
"path/filepath"
)

View File

@@ -1,7 +1,7 @@
package config
import (
"pandax/kit/biz"
"github.com/PandaXGO/PandaKit/biz"
)
type Jwt struct {

View File

@@ -1,11 +1,11 @@
package initialize
import (
"github.com/PandaXGO/PandaKit/biz"
devEntity "pandax/apps/develop/entity"
jobEntity "pandax/apps/job/entity"
logEntity "pandax/apps/log/entity"
systemEntity "pandax/apps/system/entity"
"pandax/kit/biz"
"pandax/pkg/global"
)

View File

@@ -3,10 +3,10 @@ package middleware
import (
"encoding/json"
"fmt"
"pandax/kit/biz"
"pandax/kit/logger"
"pandax/kit/restfulx"
"pandax/kit/utils"
"github.com/PandaXGO/PandaKit/biz"
"github.com/PandaXGO/PandaKit/restfulx"
"github.com/PandaXGO/PandaKit/utils"
"pandax/pkg/global"
"reflect"
"runtime/debug"
@@ -29,10 +29,10 @@ func LogHandler(rc *restfulx.ReqCtx) error {
lfs[req.Method] = req.URL.Path
if err := rc.Err; err != nil {
logger.Log.WithFields(lfs).Error(getErrMsg(rc, err))
global.Log.WithFields(lfs).Error(getErrMsg(rc, err))
return nil
}
logger.Log.WithFields(lfs).Info(getLogMsg(rc))
global.Log.WithFields(lfs).Info(getLogMsg(rc))
return nil
}

View File

@@ -1,11 +1,11 @@
package middleware
import (
"github.com/PandaXGO/PandaKit/restfulx"
"github.com/PandaXGO/PandaKit/utils"
"net/http"
"pandax/apps/log/entity"
"pandax/apps/log/services"
"pandax/kit/restfulx"
"pandax/kit/utils"
)
func OperationHandler(rc *restfulx.ReqCtx) error {

View File

@@ -1,10 +1,10 @@
package middleware
import (
"pandax/kit/biz"
"pandax/kit/casbin"
"pandax/kit/restfulx"
"pandax/kit/token"
"github.com/PandaXGO/PandaKit/biz"
"github.com/PandaXGO/PandaKit/casbin"
"github.com/PandaXGO/PandaKit/restfulx"
"github.com/PandaXGO/PandaKit/token"
"pandax/pkg/global"
"github.com/dgrijalva/jwt-go"

View File

@@ -2,9 +2,9 @@ package nodes
import (
"encoding/json"
"github.com/PandaXGO/PandaKit/utils"
"pandax/apps/device/entity"
"pandax/apps/device/services"
"pandax/kit/utils"
"pandax/pkg/global"
"pandax/pkg/rule_engine/message"
"time"
@@ -48,7 +48,7 @@ func (n *createAlarmNode) Handle(msg *message.Message) error {
}
} else {
alarm = &entity.DeviceAlarm{}
alarm.Id = utils.GenerateID()
alarm.Id = utils.GenerateID("")
alarm.DeviceId = msg.Metadata.GetValue("deviceId").(string)
alarm.ProductId = msg.Metadata.GetValue("productId").(string)
alarm.Name = msg.Metadata.GetValue("deviceName").(string)

View File

@@ -2,11 +2,11 @@ package nodes
import (
"errors"
"github.com/PandaXGO/PandaKit/utils"
"pandax/apps/device/services"
"pandax/iothub/client/mqttclient"
"pandax/iothub/client/tcpclient"
"pandax/iothub/client/udpclient"
"pandax/kit/utils"
devicerpc "pandax/pkg/device_rpc"
"pandax/pkg/global"
"pandax/pkg/rule_engine/message"
@@ -72,7 +72,7 @@ func (n *rpcRequestFromDeviceNode) Handle(msg *message.Message) error {
RequestId := n.RequestId
if RequestId == "" {
if msg.Metadata.GetValue("requestId") == nil {
rpc.RequestId = utils.GenerateID()
rpc.RequestId = utils.GenerateID("")
} else {
rpc.RequestId = msg.Metadata.GetValue("requestId").(string)
}

View File

@@ -3,12 +3,12 @@ package nodes
import (
"encoding/json"
"errors"
"github.com/PandaXGO/PandaKit/utils"
"pandax/apps/device/entity"
"pandax/apps/device/services"
"pandax/iothub/client/mqttclient"
"pandax/iothub/client/tcpclient"
"pandax/iothub/client/udpclient"
"pandax/kit/utils"
"pandax/pkg/global"
"pandax/pkg/global/model"
"pandax/pkg/rule_engine/message"
@@ -51,7 +51,7 @@ func (n *rpcRequestToDeviceNode) Handle(msg *message.Message) error {
// 构建指令记录
var data entity.DeviceCmdLog
data.Id = utils.GenerateID()
data.Id = utils.GenerateID("")
data.DeviceId = deviceId
data.CmdName = datas.Method
data.CmdContent = kgo.KConv.ToStr(datas.Params)

View File

@@ -6,8 +6,8 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/PandaXGO/PandaKit/httpclient"
"net/url"
"pandax/kit/httpclient"
"pandax/pkg/rule_engine/message"
"time"
)

View File

@@ -3,7 +3,7 @@ package nodes
import (
"encoding/json"
"errors"
"pandax/kit/httpclient"
"github.com/PandaXGO/PandaKit/httpclient"
"pandax/pkg/rule_engine/message"
)

View File

@@ -2,7 +2,7 @@ package nodes
import (
"encoding/json"
"pandax/kit/httpclient"
"github.com/PandaXGO/PandaKit/httpclient"
"pandax/pkg/rule_engine/message"
)

View File

@@ -4,7 +4,7 @@ import (
"database/sql"
"encoding/base64"
"fmt"
"pandax/kit/httpclient"
"github.com/PandaXGO/PandaKit/httpclient"
"strings"
"time"

View File

@@ -1,7 +1,7 @@
package tool
import (
"pandax/kit/utils"
"github.com/PandaXGO/PandaKit/utils"
"testing"
)
@@ -11,7 +11,7 @@ func TestToCamelCase(t *testing.T) {
}
func TestGenerateID(t *testing.T) {
id := utils.GenerateID()
id := utils.GenerateID("")
t.Log(id)
}

View File

@@ -3,7 +3,6 @@ package transport
import (
"context"
"net/http"
"pandax/kit/logger"
"pandax/pkg/global"
"github.com/emicklei/go-restful/v3"
@@ -60,9 +59,9 @@ func (s *HttpServer) Stop(ctx context.Context) error {
type httpLog struct{}
func (t *httpLog) Print(v ...any) {
logger.Log.Debug(v...)
global.Log.Debug(v...)
}
func (t *httpLog) Printf(format string, v ...any) {
logger.Log.Debugf(format, v...)
global.Log.Debugf(format, v...)
}