Files
app-api/internal/model/ota.go
T
eafonyang a52adf7e27 refactor(ota): 移除 OTA 相关冗余字段及清理代码
- 从 OTA 结构体中删除 pawVerCode、pawVerName、pawUrl、pawMd5 字段
- 更新数据库查询,去除对上述字段的扫描
- 调整 SQL 迁移脚本,删除对应的数据库列
- 简化相关存储库方法的查询逻辑,提升代码维护性
2026-06-30 11:05:55 +08:00

63 lines
1.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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"`
}