Files
app-api/internal/model/ota.go
T

63 lines
1.4 KiB
Go
Raw Normal View History

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"`
Type int `json:"type"`
CreateAt time.Time `json:"create_at"`
}