refactor: 重构更新多个文件中的相关调用
This commit is contained in:
@@ -1,32 +1,17 @@
|
||||
package kpi_c_report
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type KpiCVal struct {
|
||||
KPIID string `json:"kpi_id" gorm:"column:kpi_id"`
|
||||
Value float64 `json:"value" gorm:"column:value"`
|
||||
Err string `json:"err" gorm:"column:err"`
|
||||
}
|
||||
|
||||
type KpiCValues []KpiCVal
|
||||
|
||||
type KpiCReport struct {
|
||||
ID int `gorm:"column:id;primary_key;auto_increment" json:"id"`
|
||||
NeType *string `gorm:"column:ne_type;default:NULL" json:"neType,omitempty"`
|
||||
NeName *string `gorm:"column:ne_name;default:" json:"neName,omitempty"`
|
||||
RmUID *string `gorm:"column:rm_uid;default:NULL" json:"rmUid,omitempty"`
|
||||
Date string `gorm:"column:date" json:"date"` // time.Time `gorm:"column:date" json:"date"`
|
||||
StartTime *string `gorm:"column:start_time;default:NULL" json:"startTime,omitempty"`
|
||||
EndTime *string `gorm:"column:end_time;default:NULL" json:"endTime,omitempty"`
|
||||
Index int16 `gorm:"column:index" json:"index"`
|
||||
Granularity *int8 `gorm:"column:granularity;default:60" json:"granularity,omitempty"` //Time granualarity: 5/10/.../60/300 (second)
|
||||
KpiValues KpiCValues `gorm:"column:kpi_values;type:json" json:"kpiValues,omitempty"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;default:current_timestamp()" json:"createdAt,omitempty"`
|
||||
ID int `gorm:"column:id;primary_key;auto_increment" json:"id"`
|
||||
NeType *string `gorm:"column:ne_type;default:NULL" json:"neType,omitempty"`
|
||||
NeName *string `gorm:"column:ne_name;default:" json:"neName,omitempty"`
|
||||
RmUID *string `gorm:"column:rm_uid;" json:"rmUid,omitempty"`
|
||||
Date string `gorm:"column:date" json:"date"` // time.Time `gorm:"column:date" json:"date"`
|
||||
StartTime *string `gorm:"column:start_time" json:"startTime,omitempty"`
|
||||
EndTime *string `gorm:"column:end_time" json:"endTime,omitempty"`
|
||||
Index int64 `gorm:"column:index" json:"index"`
|
||||
Granularity *int64 `gorm:"column:granularity" json:"granularity,omitempty"` //Time granualarity: 5/10/.../60/300 (second)
|
||||
KpiValues string `gorm:"column:kpi_values" json:"kpiValues,omitempty"`
|
||||
CreatedAt *int64 `gorm:"column:created_at" json:"createdAt,omitempty"`
|
||||
}
|
||||
|
||||
type KpiCReportQuery struct {
|
||||
@@ -55,17 +40,3 @@ type KpiCReport2FE struct {
|
||||
func TableName() string {
|
||||
return "kpi_c_report"
|
||||
}
|
||||
|
||||
// 将 KpiCValues 转换为 JSON 字节
|
||||
func (k KpiCValues) Value() (driver.Value, error) {
|
||||
return json.Marshal(k)
|
||||
}
|
||||
|
||||
// 从字节中扫描 KpiCValues
|
||||
func (k *KpiCValues) Scan(value interface{}) error {
|
||||
b, ok := value.([]byte)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to scan value: %v", value)
|
||||
}
|
||||
return json.Unmarshal(b, k)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user