Files
app-api/internal/model/ota.go
T
eafonyang c4cd8b6f5d feat(equalize): 添加目标曲线获取及缓存功能
- 新增CurveCache实现Redis曲线数据缓存与分布式锁机制,避免重复请求
- 增加CurveHandler支持目标曲线接口,通过EQ API获取并缓存曲线数据
- Config新增EqualizeConfig配置,支持环境变量动态配置
- Repository新增CurveRepository,按brand和name查询模型与目标曲线数据
- 路由更新,集成/getCurve接口处理目标曲线请求
- OTA模型字段优化,bool类型改为BoolInt,实现数据库int与JSON bool映射
- 统一响应格式,调整response包中OK和Fail函数消息字段命名
- 修改服务端配置默认DB IP,支持Equalize参数传递到路由层
- 新增CSV解析实现,从文件读取测量与目标曲线数据
- 修改OTA处理逻辑,修复定向升级判断bug
- Java层新增EqualizeController和ModelService对应功能,保持客户端接口兼容与调用逻辑一致
2026-06-01 19:08:43 +08:00

67 lines
1.6 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"`
PawVerCode int `json:"-"`
PawVerName string `json:"-"`
PawURL string `json:"-"`
PawMD5 string `json:"-"`
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"`
}