实现 pc 服务端数据上传处理
This commit is contained in:
@ -5,11 +5,13 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"server/internal/consts"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/service"
|
||||
"server/utility/mqtt"
|
||||
"server/utility/mqtt/emqx"
|
||||
)
|
||||
|
||||
type sStoreDesktopSetting struct {
|
||||
@ -63,15 +65,26 @@ func (s *sStoreDesktopSetting) Save(ctx context.Context, in model.SaveDesktopSet
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
marshal, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client, b := mqtt.GetClient("emqx")
|
||||
if !b {
|
||||
return nil, gerror.New("获取MQTT客户端失败")
|
||||
}
|
||||
err = client.Publish(fmt.Sprintf("/desktop/%d", in.StoreId), marshal)
|
||||
downData := emqx.DownData{
|
||||
CMD: consts.CmdDesktopSetting,
|
||||
StoreId: int(in.StoreId),
|
||||
Data: struct {
|
||||
RightComponentVisible int `json:"rightComponentVisible"`
|
||||
TopComponentVisible int `json:"topComponentVisible"`
|
||||
}{
|
||||
RightComponentVisible: in.RightComponentVisible,
|
||||
TopComponentVisible: in.TopComponentVisible,
|
||||
},
|
||||
}
|
||||
marshal, err := json.Marshal(downData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = client.Publish(fmt.Sprintf("/%d/down", in.StoreId), marshal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user