From efd0f9f7a63aa90ae2d34b1a7e47ee27700c138b Mon Sep 17 00:00:00 2001 From: wubijie Date: Fri, 5 Jan 2024 15:01:42 +0800 Subject: [PATCH] Modify database table structure --- configmanage/server/internal/configinfo.go | 19 +++++++++++++++---- configmanage/server/internal/confignode.go | 10 +++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/configmanage/server/internal/configinfo.go b/configmanage/server/internal/configinfo.go index bb8f2d3e..925b4fee 100644 --- a/configmanage/server/internal/configinfo.go +++ b/configmanage/server/internal/configinfo.go @@ -3,16 +3,23 @@ package internal import "openeuler.org/PilotGo/configmanage-plugin/db" type ConfigInfo struct { + ID int `gorm:"AUTO_INCREMENT"` + UUID string `gorm:"type:varchar(50);primary_key" json:"uuid"` + Type string `json:"type"` + Description string `json:"description"` +} + +type Info2File struct { ID int `gorm:"primary_key;AUTO_INCREMENT"` - UUID string `gorm:"type:varchar(50)" json:"uuid"` + ConfigInfo ConfigInfo `gorm:"Foreignkey:ConfigInfoUUID"` + ConfigInfoUUID string ConfigFile ConfigFile `gorm:"Foreignkey:ConfigFileUUID"` ConfigFileUUID string - Type string `json:"type"` - Description string `json:"description"` + Version string `gorm:"type:varchar(50)" json:"version"` } func (cm *ConfigInfo) Add() error { - return db.MySQL().Save(&cm).Error + return db.MySQL().Create(cm).Error } func GetInfoByConfigUUID(configuuid string) (ConfigInfo, error) { @@ -26,3 +33,7 @@ func GetInfoByUUID(uuid string) ([]ConfigInfo, error) { err := db.MySQL().Where("uuid=?", uuid).Find(&cis).Error return cis, err } + +func (i2f *Info2File) Add() error { + return db.MySQL().Create(i2f).Error +} diff --git a/configmanage/server/internal/confignode.go b/configmanage/server/internal/confignode.go index eb7d7ffc..dc91b87c 100644 --- a/configmanage/server/internal/confignode.go +++ b/configmanage/server/internal/confignode.go @@ -3,21 +3,21 @@ package internal import "openeuler.org/PilotGo/configmanage-plugin/db" type ConfigNode struct { - ID int `gorm:"primary_key;AUTO_INCREMENT"` - ConfigInfoUUID string `json:"config_info_uuid"` - NodeId []string `json:"node_id"` //机器uuid + ID int `gorm:"primary_key;AUTO_INCREMENT"` + ConfigInfoUUID string `json:"config_info_uuid"` + NodeId string `json:"node_id"` //机器uuid } type ConfigBatch struct { ID int `gorm:"primary_key;AUTO_INCREMENT"` ConfigInfoUUID string `json:"config_info_uuid"` - BatchIDs []int `json:"batchids"` + BatchID int `json:"batch_id"` } type ConfigDepart struct { ID int `gorm:"primary_key;AUTO_INCREMENT"` ConfigInfoUUID string `json:"config_info_uuid"` - DepartIDs []int `json:"departids"` + DepartID int `json:"depart_id"` } func (cn *ConfigNode) Add() error { -- Gitee