From 49fbd046446fb647d634023c249733eec02364f9 Mon Sep 17 00:00:00 2001 From: douxu Date: Tue, 12 Aug 2025 17:19:38 +0800 Subject: [PATCH] optimize component struct http://server.baseware.net:9000/project/datart/task/47 --- database/create_component.go | 1 - database/update_component.go | 1 - network/circuit_diagram_update_request.go | 1 - orm/circuit_diagram_component.go | 3 +-- orm/circuit_diagram_page.go | 19 +++++++++---------- pool/concurrency_model_parse.go | 1 - 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/database/create_component.go b/database/create_component.go index e4c1644..9c3a907 100644 --- a/database/create_component.go +++ b/database/create_component.go @@ -30,7 +30,6 @@ func CreateComponentIntoDB(ctx context.Context, tx *gorm.DB, componentInfo netwo GridID: strconv.FormatInt(componentInfo.GridID, 10), ZoneID: strconv.FormatInt(componentInfo.ZoneID, 10), StationID: strconv.FormatInt(componentInfo.StationID, 10), - PageID: componentInfo.PageID, Tag: componentInfo.Tag, ComponentType: componentInfo.ComponentType, Name: componentInfo.Name, diff --git a/database/update_component.go b/database/update_component.go index 2032f9d..3ee38d6 100644 --- a/database/update_component.go +++ b/database/update_component.go @@ -40,7 +40,6 @@ func UpdateComponentIntoDB(ctx context.Context, tx *gorm.DB, componentInfo netwo GridID: strconv.FormatInt(componentInfo.GridID, 10), ZoneID: strconv.FormatInt(componentInfo.ZoneID, 10), StationID: strconv.FormatInt(componentInfo.StationID, 10), - PageID: componentInfo.PageID, Tag: componentInfo.Tag, ComponentType: componentInfo.ComponentType, Name: componentInfo.Name, diff --git a/network/circuit_diagram_update_request.go b/network/circuit_diagram_update_request.go index db55852..bf58501 100644 --- a/network/circuit_diagram_update_request.go +++ b/network/circuit_diagram_update_request.go @@ -41,7 +41,6 @@ type ComponentUpdateInfo struct { GridID int64 `json:"grid_id"` ZoneID int64 `json:"zone_id"` StationID int64 `json:"station_id"` - PageID int64 `json:"page_id"` ComponentType int `json:"component_type"` Params string `json:"params"` Op int `json:"op"` diff --git a/orm/circuit_diagram_component.go b/orm/circuit_diagram_component.go index bccc7e5..a2c67ee 100644 --- a/orm/circuit_diagram_component.go +++ b/orm/circuit_diagram_component.go @@ -28,9 +28,8 @@ type Component struct { Op int `gorm:"column:OP"` Ts time.Time `gorm:"column:TS"` - // TODO 解决删除ID、ComponentType、PageID后的报错 + // TODO 解决删除ID、ComponentType 后的报错 ID int64 `gorm:"column:id;primaryKey"` - PageID int64 `gorm:"column:page_id"` ComponentType int `gorm:"column:TYPE"` } diff --git a/orm/circuit_diagram_page.go b/orm/circuit_diagram_page.go index d99f05d..ff290a4 100644 --- a/orm/circuit_diagram_page.go +++ b/orm/circuit_diagram_page.go @@ -5,18 +5,17 @@ import "time" // Page structure define circuit diagram page info set type Page struct { - ID int64 `gorm:"column:id;primaryKey"` - Status int `gorm:"column:status"` - Op int `gorm:"column:op"` - Label string `gorm:"column:label"` - Context string `gorm:"column:context"` - Description string `gorm:"column:description"` - Tag string `gorm:"column:tag"` - Name string `gorm:"column:name"` - Ts time.Time `gorm:"column:ts"` + ID int64 `gorm:"column:ID;primaryKey"` + Tag string `gorm:"column:TAG"` + Name string `gorm:"column:NAME"` + Label map[string]interface{} `gorm:"column:LABEL;type:jsonb;default:'{}'"` + Context map[string]interface{} `gorm:"column:CONTEXT;type:jsonb;default:'{}'"` + Description string `gorm:"column:DESCRIPTION"` + Op int `gorm:"column:OP"` + Ts time.Time `gorm:"column:TS"` } // TableName func respresent return table name of Page func (p *Page) TableName() string { - return "page" + return "PAGE" } diff --git a/pool/concurrency_model_parse.go b/pool/concurrency_model_parse.go index 797d197..fe2e356 100644 --- a/pool/concurrency_model_parse.go +++ b/pool/concurrency_model_parse.go @@ -53,7 +53,6 @@ var ParseFunc = func(parseConfig interface{}) { unmarshalMap["grid_id"] = modelParseConfig.ComponentInfo.GridID unmarshalMap["zone_id"] = modelParseConfig.ComponentInfo.ZoneID unmarshalMap["station_id"] = modelParseConfig.ComponentInfo.StationID - unmarshalMap["page_id"] = modelParseConfig.ComponentInfo.PageID unmarshalMap["component_type"] = modelParseConfig.ComponentInfo.ComponentType unmarshalMap["name"] = modelParseConfig.ComponentInfo.Name unmarshalMap["context"] = modelParseConfig.ComponentInfo.Context