组织数据读取权限完成

This commit is contained in:
XM-GO
2023-09-15 15:13:39 +08:00
parent b5ee2a54b9
commit 6630ebdb02
37 changed files with 717 additions and 59 deletions

View File

@@ -32,17 +32,17 @@ type Message struct {
Id string //uuid 消息Id
Ts time.Time //时间戳
MsgType string //消息类型, attributes参数telemetry遥测Connect连接事件
UserId string //客户Id UUID 设备发布人
User string //客户 设备发布人 设备所有者
Msg Msg //数据 数据结构JSON 设备原始数据 msg
Metadata Metadata //消息的元数据 包括设备Id设备类型产品ID等
}
// NewMessage ...
func NewMessage(userId, messageType string, msg Msg, metadata Metadata) *Message {
func NewMessage(user, messageType string, msg Msg, metadata Metadata) *Message {
return &Message{
Id: uuid.New().String(),
Ts: time.Now(),
UserId: userId,
User: user,
MsgType: messageType,
Msg: msg,
Metadata: metadata,

View File

@@ -61,6 +61,7 @@ func (n *createAlarmNode) Handle(msg *message.Message) error {
alarm.Type = n.AlarmType
alarm.Time = time.Now()
alarm.OrgId = msg.Metadata.GetValue("orgId").(int64)
alarm.Owner = msg.Metadata.GetValue("owner").(string)
marshal, _ := json.Marshal(msg.Msg)
alarm.Details = string(marshal)
err := services.DeviceAlarmModelDao.Insert(*alarm)

View File

@@ -41,6 +41,7 @@ func (n *logNode) Handle(msg *message.Message) error {
MsgType: msg.MsgType,
DeviceId: msg.Metadata["deviceId"].(string),
OrgId: msg.Metadata["orgId"].(int64),
Owner: msg.Metadata["owner"].(string),
DeviceName: msg.Metadata["deviceName"].(string),
Ts: msg.Ts,
Content: logMessage,