| | |
| | | |
| | | type Positions struct { |
| | | Id uint `gorm:"column:id;primary_key;auto_increment;unique;not null;"` |
| | | DeviceId string `gorm:"column:device_id;" json:"device_id"` |
| | | DeviceId string `gorm:"column:device_id;index" json:"device_id"` |
| | | Pos string `gorm:"column:pos" json:"pos"` |
| | | CreateTime int64 `gorm:"column:create_time;"` |
| | | CreateTime int64 `gorm:"column:create_time;index"` |
| | | TimeString string `gorm:"column:time_string;"` |
| | | } |
| | | |
| | |
| | | return "positions" |
| | | } |
| | | |
| | | func (d *Positions) Save() error { |
| | | return db.Table(d.TableName()).Save(d).Error |
| | | } |
| | | func (d *Positions) FindDevicePosition(devId string, timestamp int64) error { |
| | | return db.Table(d.TableName()).Where("device_id = ? AND create_time <= ?", devId, timestamp).Order("create_time desc").First(&d).Error |
| | | } |