123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- package sandbox
- import (
- "eta/eta_hub/models/sandbox"
- )
- // ContentStruct 沙盘内容结构体
- type ContentStruct struct {
- Cells []struct {
- Attrs struct {
- Line struct {
- SourceMarker bool `json:"sourceMarker"`
- Stroke string `json:"stroke"`
- StrokeDasharray string `json:"strokeDasharray"`
- } `json:"line"`
- Rect struct {
- Fill string `json:"fill"`
- Stroke string `json:"stroke"`
- StrokeDasharray interface{} `json:"strokeDasharray"`
- StrokeWidth int64 `json:"strokeWidth"`
- } `json:"rect"`
- Text struct {
- Fill string `json:"fill"`
- FontSize float64 `json:"fontSize"`
- FontWeight string `json:"fontWeight"`
- LineHeight float64 `json:"lineHeight"`
- Text string `json:"text"`
- TextWrap struct {
- Text string `json:"text"`
- Width int64 `json:"width"`
- } `json:"textWrap"`
- } `json:"text"`
- } `json:"attrs"`
- Data struct {
- Key string `json:"key"`
- } `json:"data"`
- ID string `json:"id"`
- Ports struct {
- Groups struct {
- Port_bottom struct {
- Attrs struct {
- Circle struct {
- Fill string `json:"fill"`
- Magnet bool `json:"magnet"`
- R int64 `json:"r"`
- Stroke string `json:"stroke"`
- StrokeWidth int64 `json:"strokeWidth"`
- } `json:"circle"`
- } `json:"attrs"`
- Position string `json:"position"`
- ZIndex int64 `json:"zIndex"`
- } `json:"port-bottom"`
- Port_left struct {
- Attrs struct {
- Circle struct {
- Fill string `json:"fill"`
- Magnet bool `json:"magnet"`
- R int64 `json:"r"`
- Stroke string `json:"stroke"`
- StrokeWidth int64 `json:"strokeWidth"`
- } `json:"circle"`
- } `json:"attrs"`
- Position string `json:"position"`
- ZIndex int64 `json:"zIndex"`
- } `json:"port-left"`
- Port_right struct {
- Attrs struct {
- Circle struct {
- Fill string `json:"fill"`
- Magnet bool `json:"magnet"`
- R int64 `json:"r"`
- Stroke string `json:"stroke"`
- StrokeWidth int64 `json:"strokeWidth"`
- } `json:"circle"`
- } `json:"attrs"`
- Position string `json:"position"`
- ZIndex int64 `json:"zIndex"`
- } `json:"port-right"`
- Port_top struct {
- Attrs struct {
- Circle struct {
- Fill string `json:"fill"`
- Magnet bool `json:"magnet"`
- R int64 `json:"r"`
- Stroke string `json:"stroke"`
- StrokeWidth int64 `json:"strokeWidth"`
- } `json:"circle"`
- } `json:"attrs"`
- Position string `json:"position"`
- ZIndex int64 `json:"zIndex"`
- } `json:"port-top"`
- } `json:"groups"`
- Items []struct {
- Group string `json:"group"`
- ID string `json:"id"`
- } `json:"items"`
- } `json:"ports"`
- Position struct {
- X float64 `json:"x"`
- Y float64 `json:"y"`
- } `json:"position"`
- Shape string `json:"shape"`
- Size struct {
- Height float64 `json:"height"`
- Width float64 `json:"width"`
- } `json:"size"`
- Source struct {
- Cell string `json:"cell"`
- Port string `json:"port"`
- } `json:"source"`
- Target struct {
- Cell string `json:"cell"`
- Port string `json:"port"`
- } `json:"target"`
- ZIndex int64 `json:"zIndex"`
- } `json:"cells"`
- }
- type SendBoxNodeData struct {
- linkData []SandBoxLinkData `json:"linkData"`
- linkFold bool `json:"linkFold"`
- }
- type SandBoxLinkData struct {
- RId string `json:"RId"`
- Id int `json:"Id"`
- Name string `json:"Name"`
- Type int `json:"Type"`
- Editing bool `json:"editing"`
- DatabaseType int `json:"databaseType"`
- DetailParams SandBoxDetailParams `json:"detailParams"`
- }
- type SandBoxDetailParams struct {
- Code string `json:"code"`
- Id int `json:"id"`
- ClassifyId int `json:"classifyId"`
- }
- func sandboxClassifyHaveChild(allNode []*sandbox.SandboxClassifyItems, node *sandbox.SandboxClassifyItems) (childs []*sandbox.SandboxClassifyItems, yes bool) {
- for _, v := range allNode {
- if v.ParentId == node.SandboxClassifyId {
- childs = append(childs, v)
- }
- }
- if len(childs) > 0 {
- yes = true
- }
- return
- }
- func SandboxClassifyItemsMakeTree(allNode []*sandbox.SandboxClassifyItems, node *sandbox.SandboxClassifyItems) {
- childs, _ := sandboxClassifyHaveChild(allNode, node) //判断节点是否有子节点并返回
- if len(childs) > 0 {
- node.Children = append(node.Children, childs[0:]...) //添加子节点
- for _, v := range childs { //查询子节点的子节点,并添加到子节点
- _, has := sandboxClassifyHaveChild(allNode, v)
- if has {
- SandboxClassifyItemsMakeTree(allNode, v) //递归添加节点
- } else {
- childrenArr := make([]*sandbox.SandboxClassifyItems, 0)
- v.Children = childrenArr
- }
- }
- } else {
- childrenArr := make([]*sandbox.SandboxClassifyItems, 0)
- node.Children = childrenArr
- }
- }
- func SandboxClassifyItemsMakeTreeV2(allNode []*sandbox.SandboxClassifyItems, node *sandbox.SandboxClassifyItems) {
- childs, _ := sandboxClassifyHaveChildV2(allNode, node) //判断节点是否有子节点并返回
- if len(childs) > 0 {
- node.Children = append(node.Children, childs[0:]...) //添加子节点
- for _, v := range childs { //查询子节点的子节点,并添加到子节点
- _, has := sandboxClassifyHaveChildV2(allNode, v)
- if has {
- SandboxClassifyItemsMakeTreeV2(allNode, v) //递归添加节点
- }
- }
- }
- }
- func sandboxClassifyHaveChildV2(allNode []*sandbox.SandboxClassifyItems, node *sandbox.SandboxClassifyItems) (childs []*sandbox.SandboxClassifyItems, yes bool) {
- for _, v := range allNode {
- if v.ParentId == node.SandboxClassifyId && node.SandboxId == 0 {
- childs = append(childs, v)
- }
- }
- if len(childs) > 0 {
- yes = true
- }
- return
- }
|