62 lines
1.4 KiB
Go
62 lines
1.4 KiB
Go
package model
|
||
|
||
import (
|
||
"database/sql"
|
||
"time"
|
||
)
|
||
|
||
// BoolInt 数据库存储为 int(1/0),JSON 序列化为 bool(true/false)
|
||
type BoolInt bool
|
||
|
||
func (b *BoolInt) Scan(value interface{}) error {
|
||
if value == nil {
|
||
*b = false
|
||
return nil
|
||
}
|
||
switch v := value.(type) {
|
||
case int64:
|
||
*b = v == 1
|
||
case []byte:
|
||
*b = len(v) > 0 && v[0] == '1'
|
||
default:
|
||
*b = false
|
||
}
|
||
return nil
|
||
}
|
||
|
||
var _ sql.Scanner = (*BoolInt)(nil)
|
||
|
||
// OTA 固件升级记录
|
||
type OTA struct {
|
||
ID int `json:"-"`
|
||
VerCode int `json:"verCode"`
|
||
VerName string `json:"verName"`
|
||
URL string `json:"url"`
|
||
MD5 string `json:"md5"`
|
||
Force BoolInt `json:"force"`
|
||
Desc *string `json:"desc,omitempty"`
|
||
Model *string `json:"model,omitempty"`
|
||
HW int `json:"hw"`
|
||
Target BoolInt `json:"target"`
|
||
Beta BoolInt `json:"beta"`
|
||
StartTime *time.Time `json:"startTime,omitempty"`
|
||
EndTime *time.Time `json:"endTime,omitempty"`
|
||
Status int `json:"-"`
|
||
}
|
||
|
||
// BlackList OTA 黑名单
|
||
type BlackList struct {
|
||
ID int `json:"id"`
|
||
OTAID int `json:"ota_id"`
|
||
Mac string `json:"mac"`
|
||
CreateAt time.Time `json:"create_at"`
|
||
}
|
||
|
||
// OTATargetDevice OTA 灰度升级设备
|
||
type OTATargetDevice struct {
|
||
ID int `json:"id"`
|
||
OTAID int `json:"ota_id"`
|
||
MacAddr string `json:"mac_addr"`
|
||
CreateAt time.Time `json:"create_at"`
|
||
}
|