diff --git a/apps/visual/api/visual_screen.go b/apps/visual/api/visual_screen.go index d5d8fd3..300d386 100644 --- a/apps/visual/api/visual_screen.go +++ b/apps/visual/api/visual_screen.go @@ -11,6 +11,7 @@ import ( "github.com/XM-GO/PandaKit/restfulx" "github.com/emicklei/go-restful/v3" "github.com/kakuilan/kgo" + "log" "pandax/pkg/global" "strings" @@ -82,13 +83,32 @@ func (p *VisualScreenApi) UpdateScreenStatus(rc *restfulx.ReqCtx) { } func (p *VisualScreenApi) ScreenTwinData(rc *restfulx.ReqCtx) { - twin := `[{"key":"1001","name":"监测站001","attrs":[{"key":"wd","type":"int64","name":"温度"},{"key":"sd","type":"int64","name":"湿度"}]},{"key":"2001","name":"控制器001","attrs":[{"key":"q","type":"int64","name":"灯光强度1"},{"key":"open","type":"bool","name":"灯光开关"}]}]` + twin := `[{"key":"1001","name":"监测站001","attrs":[{"key":"wd","type":"int64","name":"温度"},{"key":"sd","type":"float64","name":"湿度"}]},{"key":"2001","name":"控制器001","attrs":[{"key":"q","type":"struct","name":"灯光强度1"},{"key":"open","type":"bool","name":"灯光开关"}]}]` data := make([]map[string]interface{}, 0) json.Unmarshal([]byte(twin), &data) rc.ResData = data } +func (p *VisualScreenApi) ScreenTwinData1(rc *restfulx.ReqCtx) { + products := `[{"classId": "p313123","name": "微型环境监测站"},{"classId": "p313124","name": "温湿度传感器"}]` + twin := `[{"twinId":"1001","name":"监测站001","attrs":[{"key":"wd","type":"int64","name":"温度"},{"key":"sd","type":"float64","name":"湿度"}]},{"twinId":"2001","name":"控制器001","attrs":[{"key":"q","type":"struct","name":"灯光强度1"},{"key":"open","type":"bool","name":"灯光开关"}]}]` + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + classId := restfulx.QueryParam(rc, "classId") + if classId == "" { + data := make([]map[string]interface{}, 0) + json.Unmarshal([]byte(products), &data) + rc.ResData = data + } else { + //todo 分页查询孪生体 + log.Println(pageNum, pageSize) + 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 == "" { diff --git a/apps/visual/entity/rulechain.go b/apps/visual/entity/rulechain.go index 7c2b53c..6b84c91 100644 --- a/apps/visual/entity/rulechain.go +++ b/apps/visual/entity/rulechain.go @@ -8,6 +8,7 @@ import ( type VisualRuleChainBase struct { UserId string `gorm:"userId;type:varchar(64);comment:用户Id" json:"userId"` RuleId string `gorm:"primary_key;" json:"ruleId"` + Root bool `gorm:"root;comment:根链" json:"root"` RuleName string `gorm:"ruleName;type:varchar(50);comment:名称" json:"ruleName"` RuleBase64 string `gorm:"ruleBase64;type:longtext;comment:Base64缩略图" json:"ruleBase64"` //缩略图 base64 RuleRemark string `gorm:"ruleRemark;type:varchar(256);comment:说明" json:"ruleRemark"` diff --git a/apps/visual/router/visual_screen.go b/apps/visual/router/visual_screen.go index b6048a3..55a1cb7 100644 --- a/apps/visual/router/visual_screen.go +++ b/apps/visual/router/visual_screen.go @@ -81,5 +81,11 @@ func InitVisualScreenRouter(container *restful.Container) { Doc("孪生体数据"). Metadata(restfulspec.KeyOpenAPITags, tags)) + ws.Route(ws.GET("/twin/data1").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithNeedCasbin(false).WithLog("孪生体数据").Handle(s.ScreenTwinData1) + }). + Doc("孪生体数据"). + Metadata(restfulspec.KeyOpenAPITags, tags)) + container.Add(ws) }