diff --git a/configmanage/server/internal/configinfo.go b/configmanage/server/internal/configinfo.go index bb8f2d3e5cfa23702aab430e86c2c409f8451bf4..925b4fee109d8f939eb8911a01fa132535a60fe0 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 eb7d7ffc045a4fd308b28a1e093a021870f92970..dc91b87cd1d900c2bc6d76d1a75ce5702a90a59e 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 {