package models
|
|
type Report struct {
|
Id int `gorm:"column:id;primary_key;type:varchar(50);unique;not null;" json:"id"`
|
ServerAddr string `gorm:"column:serverAddr;" json:"serverAddr"` // 上报地址
|
Interval int64 `gorm:"column:interval;" json:"interval"` // 上报间隔
|
}
|
|
func (Report) TableName() string {
|
return "t_report"
|
}
|
|
func (i *Report) FindAll() (row Report, err error) {
|
if err := GetDB().Table(i.TableName()).First(&row).Error; err != nil {
|
return row, err
|
}
|
|
return row, nil
|
}
|
|
func (i *Report) Update() error {
|
return db.Where("id = 0").Save(&i).Error
|
}
|
|
func (i *Report) Read() (err error) {
|
return GetDB().Table(i.TableName()).First(i).Error
|
}
|