package models
|
|
import "time"
|
|
type SubPlatform struct {
|
Id string `gorm:"primary_key;" json:"id"`
|
Name string `gorm:"not null;default:''" json:"name"`
|
UserName string `gorm:"not null;default:''" json:"user_name"`
|
Realm string `gorm:"not null;default:''" json:"realm"`
|
Password string `gorm:"not null;default:''" json:"password"`
|
Description string `gorm:"not null;default:''" json:"description"`
|
RemoteIP string `gorm:"not null;default:''" json:"remote_ip"`
|
RemotePort int `gorm:"not null;default:0" json:"remote_port"`
|
HeartbeatTime string `gorm:"column:heartbeat_time" json:"heartbeat_time"`
|
CreateTime int64 `gorm:"column:create_time;autoCreateTime;" json:"create_time"`
|
UpdateTime int64 `gorm:"column:update_time;autoUpdateTime" json:"-"`
|
DeleteTime int64 `gorm:"column:delete_time" json:"-"`
|
}
|
|
func (s *SubPlatform) TableName() string {
|
return "sub_platforms"
|
}
|
|
func (s *SubPlatform) FindById(id string) error {
|
return db.Table(s.TableName()).First(&s, "id = ?", id).Error
|
}
|
|
func (s *SubPlatform) Save() error {
|
return db.Table(s.TableName()).Save(s).Error
|
}
|
|
func (s *SubPlatform) DeleteById(id string) error {
|
return db.Table(s.TableName()).Where("id = ?", id).Delete(s).Error
|
}
|
|
func (s *SubPlatform) FindAll() ([]SubPlatform, error) {
|
var list []SubPlatform
|
if err := db.Table(s.TableName()).Find(&list).Error; err != nil {
|
return nil, err
|
}
|
|
return list, nil
|
}
|
|
func (s *SubPlatform) Keepalive(id string) error {
|
return db.Table(s.TableName()).Where("id = ?", id).Update("heartbeat_time", time.Now().Format("2006-01-02 15:04:05")).Error
|
}
|