diff --git a/configmanage/server/internal/dnsfile.go b/configmanage/server/internal/dnsfile.go index 5cc8e1fda63230dd5ef30c3e39243071efb710c8..64379d9b56ef4e1e5d2b46e4f3e0d931d8d3c892 100644 --- a/configmanage/server/internal/dnsfile.go +++ b/configmanage/server/internal/dnsfile.go @@ -16,7 +16,7 @@ type DNSFile struct { Name string `json:"name"` Content json.RawMessage `gorm:"type:json" json:"content"` Version string `gorm:"type:varchar(50)" json:"version"` - IsActive bool `json:"isactive"` + IsActive bool `gorm:"default:false" json:"isactive"` IsFromHost bool `gorm:"default:false" json:"isfromhost"` Hostuuid string `gorm:"type:varchar(50)" json:"hostuuid"` CreatedAt time.Time @@ -50,13 +50,14 @@ func (df *DNSFile) Add() error { ).Error } +// 根据配置uuid获取用户自己创建的配置信息 func GetDNSFileByInfoUUID(uuid string, isindex interface{}) (DNSFile, error) { var file DNSFile if isindex != nil { - err := db.MySQL().Model(&DNSFile{}).Where("config_info_uuid=? && is_index = ?", uuid, isindex).Find(&file).Error + err := db.MySQL().Model(&DNSFile{}).Where("config_info_uuid=? and is_from_host=0 and is_index = ?", uuid, isindex).Find(&file).Error return file, err } - err := db.MySQL().Model(&DNSFile{}).Where("config_info_uuid=?", uuid).Find(&file).Error + err := db.MySQL().Model(&DNSFile{}).Where("config_info_uuid=? and is_from_host=0", uuid).Find(&file).Error return file, err } diff --git a/configmanage/server/internal/hostfile.go b/configmanage/server/internal/hostfile.go index b37b3408671c1ae87e7a007b17f480983781dbd1..91137280094642548d13a6473a431afa34939c09 100644 --- a/configmanage/server/internal/hostfile.go +++ b/configmanage/server/internal/hostfile.go @@ -16,7 +16,7 @@ type HostFile struct { Name string `json:"name"` Content json.RawMessage `gorm:"type:json" json:"content"` Version string `gorm:"type:varchar(50)" json:"version"` - IsActive bool `json:"isactive"` + IsActive bool `gorm:"default:false" json:"isactive"` IsFromHost bool `gorm:"default:false" json:"isfromhost"` Hostuuid string `gorm:"type:varchar(50)" json:"hostuuid"` CreatedAt time.Time @@ -50,13 +50,14 @@ func (hf *HostFile) Add() error { ).Error } +// 根据配置uuid获取用户自己创建的配置信息 func GetHostFileByInfoUUID(uuid string, isindex interface{}) (HostFile, error) { var file HostFile if isindex != nil { - err := db.MySQL().Model(&HostFile{}).Where("config_info_uuid=? && is_index = ?", uuid, isindex).Find(&file).Error + err := db.MySQL().Model(&HostFile{}).Where("config_info_uuid=? and is_from_host=0 and is_index = ?", uuid, isindex).Find(&file).Error return file, err } - err := db.MySQL().Model(&HostFile{}).Where("config_info_uuid=?", uuid).Find(&file).Error + err := db.MySQL().Model(&HostFile{}).Where("config_info_uuid=? and is_from_host=0 ", uuid).Find(&file).Error return file, err } diff --git a/configmanage/server/internal/repofile.go b/configmanage/server/internal/repofile.go index 872962b4a6976b08d04ad9cffebbe7eb52fff75c..adae5f92ae5699f12e64bf1ec2cf6185bbfc7d4d 100644 --- a/configmanage/server/internal/repofile.go +++ b/configmanage/server/internal/repofile.go @@ -16,7 +16,7 @@ type RepoFile struct { Name string `json:"name"` Content json.RawMessage `gorm:"type:json" json:"content"` Version string `gorm:"type:varchar(50)" json:"version"` - IsActive bool `json:"isactive"` + IsActive bool `gorm:"default:false" json:"isactive"` IsFromHost bool `gorm:"default:false" json:"isfromhost"` Hostuuid string `gorm:"type:varchar(50)" json:"hostuuid"` CreatedAt time.Time @@ -26,13 +26,14 @@ func (rf *RepoFile) Add() error { return db.MySQL().Save(&rf).Error } +// 根据配置uuid获取用户自己创建的配置信息 func GetRepoFileByInfoUUID(uuid string, isindex interface{}) (RepoFile, error) { var file RepoFile if isindex != nil { - err := db.MySQL().Model(&RepoFile{}).Where("config_info_uuid=? && is_index = ?", uuid, isindex).Find(&file).Error + err := db.MySQL().Model(&RepoFile{}).Where("config_info_uuid=? and is_from_host=0 and is_index = ?", uuid, isindex).Find(&file).Error return file, err } - err := db.MySQL().Model(&RepoFile{}).Where("config_info_uuid=?", uuid).Find(&file).Error + err := db.MySQL().Model(&RepoFile{}).Where("config_info_uuid=? and is_from_host=0", uuid).Find(&file).Error return file, err } diff --git a/configmanage/server/internal/ssh.go b/configmanage/server/internal/ssh.go index 2ea1c78bf279c72b6824c5dacbae089f5d152035..d42dc49c4c4d84273f936241aec036e27fed9c31 100644 --- a/configmanage/server/internal/ssh.go +++ b/configmanage/server/internal/ssh.go @@ -16,7 +16,7 @@ type SSHFile struct { Name string `json:"name"` Content json.RawMessage `gorm:"type:json" json:"content"` Version string `gorm:"type:varchar(50)" json:"version"` - IsActive bool `json:"isactive"` + IsActive bool `gorm:"default:false" json:"isactive"` IsFromHost bool `gorm:"default:false" json:"isfromhost"` Hostuuid string `gorm:"type:varchar(50)" json:"hostuuid"` CreatedAt time.Time @@ -26,13 +26,14 @@ func (sf *SSHFile) Add() error { return db.MySQL().Save(&sf).Error } +// 根据配置uuid获取用户自己创建的配置信息 func GetSSHFileByInfoUUID(uuid string, isindex interface{}) (SSHFile, error) { var file SSHFile if isindex != nil { - err := db.MySQL().Model(&SSHFile{}).Where("config_info_uuid=? && is_index = ?", uuid, isindex).Find(&file).Error + err := db.MySQL().Model(&SSHFile{}).Where("config_info_uuid=? and is_from_host=0 and is_index = ?", uuid, isindex).Find(&file).Error return file, err } - err := db.MySQL().Model(&SSHFile{}).Where("config_info_uuid=?", uuid).Find(&file).Error + err := db.MySQL().Model(&SSHFile{}).Where("config_info_uuid=? and is_from_host=0", uuid).Find(&file).Error return file, err } diff --git a/configmanage/server/internal/sshd.go b/configmanage/server/internal/sshd.go index f91156da75a2f140deb7daf3c70cb1eb143f9a6d..f7d51fd792908ffa0791bdcabb41160bc9684555 100644 --- a/configmanage/server/internal/sshd.go +++ b/configmanage/server/internal/sshd.go @@ -16,7 +16,7 @@ type SSHDFile struct { Name string `json:"name"` Content json.RawMessage `gorm:"type:json" json:"content"` Version string `gorm:"type:varchar(50)" json:"version"` - IsActive bool `json:"isactive"` + IsActive bool `gorm:"default:false" json:"isactive"` IsFromHost bool `gorm:"default:false" json:"isfromhost"` Hostuuid string `gorm:"type:varchar(50)" json:"hostuuid"` CreatedAt time.Time @@ -25,13 +25,15 @@ type SSHDFile struct { func (sdf *SSHDFile) Add() error { return db.MySQL().Save(&sdf).Error } + +// 根据配置uuid获取用户自己创建的配置信息 func GetSSHDFileByInfoUUID(uuid string, isindex interface{}) (SSHDFile, error) { var file SSHDFile if isindex != nil { - err := db.MySQL().Model(&SSHDFile{}).Where("config_info_uuid=? && is_index = ?", uuid, isindex).Find(&file).Error + err := db.MySQL().Model(&SSHDFile{}).Where("config_info_uuid=? and is_from_host=0 and is_index = ?", uuid, isindex).Find(&file).Error return file, err } - err := db.MySQL().Model(&SSHDFile{}).Where("config_info_uuid=?", uuid).Find(&file).Error + err := db.MySQL().Model(&SSHDFile{}).Where("config_info_uuid=? and is_from_host=0", uuid).Find(&file).Error return file, err } diff --git a/configmanage/server/internal/sysctl.go b/configmanage/server/internal/sysctl.go index 0aae238301de290156bef020897f9c47057b5d30..4d6220b1c1c68598618ddb3321cecb73f1df4df7 100644 --- a/configmanage/server/internal/sysctl.go +++ b/configmanage/server/internal/sysctl.go @@ -16,7 +16,7 @@ type SysctlFile struct { Name string `json:"name"` Content json.RawMessage `gorm:"type:json" json:"content"` Version string `gorm:"type:varchar(50)" json:"version"` - IsActive bool `json:"isactive"` + IsActive bool `gorm:"default:false" json:"isactive"` IsFromHost bool `gorm:"default:false" json:"isfromhost"` Hostuuid string `gorm:"type:varchar(50)" json:"hostuuid"` CreatedAt time.Time @@ -26,13 +26,14 @@ func (sysf *SysctlFile) Add() error { return db.MySQL().Save(&sysf).Error } +// 根据配置uuid获取用户自己创建的配置信息 func GetSysctlFileByInfoUUID(uuid string, isindex interface{}) (SysctlFile, error) { var file SysctlFile if isindex != nil { - err := db.MySQL().Model(&SysctlFile{}).Where("config_info_uuid=? && is_index = ?", uuid, isindex).Find(&file).Error + err := db.MySQL().Model(&SysctlFile{}).Where("config_info_uuid=? and is_from_host=0 and is_index = ?", uuid, isindex).Find(&file).Error return file, err } - err := db.MySQL().Model(&SysctlFile{}).Where("config_info_uuid=?", uuid).Find(&file).Error + err := db.MySQL().Model(&SysctlFile{}).Where("config_info_uuid=? and is_from_host=0", uuid).Find(&file).Error return file, err }