2026-05-28 18:26:20 +08:00
|
|
|
|
package model
|
|
|
|
|
|
|
2026-06-01 19:08:43 +08:00
|
|
|
|
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)
|
2026-05-28 18:26:20 +08:00
|
|
|
|
|
|
|
|
|
|
// OTA 固件升级记录
|
|
|
|
|
|
type OTA struct {
|
2026-06-01 19:08:43 +08:00
|
|
|
|
ID int `json:"-"`
|
2026-05-28 18:26:20 +08:00
|
|
|
|
VerCode int `json:"verCode"`
|
|
|
|
|
|
VerName string `json:"verName"`
|
|
|
|
|
|
URL string `json:"url"`
|
|
|
|
|
|
MD5 string `json:"md5"`
|
2026-06-01 19:08:43 +08:00
|
|
|
|
Force BoolInt `json:"force"`
|
2026-05-28 18:26:20 +08:00
|
|
|
|
Desc *string `json:"desc,omitempty"`
|
|
|
|
|
|
Model *string `json:"model,omitempty"`
|
|
|
|
|
|
HW int `json:"hw"`
|
2026-06-01 19:08:43 +08:00
|
|
|
|
Target BoolInt `json:"target"`
|
|
|
|
|
|
Beta BoolInt `json:"beta"`
|
|
|
|
|
|
PawVerCode int `json:"-"`
|
|
|
|
|
|
PawVerName string `json:"-"`
|
|
|
|
|
|
PawURL string `json:"-"`
|
|
|
|
|
|
PawMD5 string `json:"-"`
|
2026-05-28 18:26:20 +08:00
|
|
|
|
StartTime *time.Time `json:"startTime,omitempty"`
|
|
|
|
|
|
EndTime *time.Time `json:"endTime,omitempty"`
|
2026-06-01 19:08:43 +08:00
|
|
|
|
Status int `json:"-"`
|
2026-05-28 18:26:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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"`
|
|
|
|
|
|
}
|