mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-05-12 14:52:07 +08:00
孪生体
This commit is contained in:
@@ -6,6 +6,7 @@ package api
|
||||
// 生成人:panda
|
||||
// ==========================================================================
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
@@ -80,6 +81,14 @@ func (p *VisualScreenApi) UpdateScreenStatus(rc *restfulx.ReqCtx) {
|
||||
p.VisualScreenApp.Update(screen)
|
||||
}
|
||||
|
||||
func (p *VisualScreenApi) ScreenTwinData(rc *restfulx.ReqCtx) {
|
||||
twin := `[{"twinId":"1001","name":"监测站001","attrs":[{"key":"wd","type":"int64","name":"温度"},{"key":"sd","type":"int64","name":"湿度"}]},{"twinId":"2001","name":"控制器001","attrs":[{"key":"q","type":"int64","name":"灯光强度"},{"key":"open","type":"bool","name":"灯光开关"}]}]`
|
||||
|
||||
data := make([]map[string]interface{}, 0)
|
||||
json.Unmarshal([]byte(twin), &data)
|
||||
rc.ResData = data
|
||||
}
|
||||
|
||||
func (p *VisualScreenApi) ScreenTwin(request *restful.Request, response *restful.Response) {
|
||||
screenId := request.QueryParameter("screenId")
|
||||
if screenId == "" {
|
||||
|
||||
@@ -75,5 +75,11 @@ func InitVisualScreenRouter(container *restful.Container) {
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.VisualScreen{}))
|
||||
|
||||
ws.Route(ws.GET("/twin/data").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("孪生体数据").Handle(s.ScreenTwinData)
|
||||
}).
|
||||
Doc("孪生体数据").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user