You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.6 KiB

package common_models
import (
"encoding/json"
"time"
)
type EsTheme struct {
SensorName string `json:"sensor_name"`
FactorName string `json:"factor_name"`
FactorProtoCode string `json:"factor_proto_code"`
Data map[string]any `json:"data"`
FactorProtoName string `json:"factor_proto_name"`
Factor int `json:"factor"`
CollectTime time.Time `json:"collect_time"`
Sensor int `json:"sensor"`
Structure int `json:"structure"`
IotaDevice []string `json:"iota_device"`
CreateTime time.Time `json:"create_time"`
}
func (the EsTheme) MarshalJSON() ([]byte, error) {
type Alias EsTheme
return json.Marshal(&struct {
CollectTime string `json:"collect_time"`
CreateTime string `json:"create_time"`
*Alias
}{
CollectTime: the.CollectTime.Format("2006-01-02T15:04:05.000+08:00"),
CreateTime: the.CreateTime.Format("2006-01-02T15:04:05.000+08:00"),
Alias: (*Alias)(&the),
})
}
type EsThemeResp struct {
Took int `json:"took"`
TimedOut bool `json:"timed_out"`
Shards struct {
Total int `json:"total"`
Successful int `json:"successful"`
Skipped int `json:"skipped"`
Failed int `json:"failed"`
} `json:"_shards"`
Hits struct {
Total int `json:"total"`
MaxScore float64 `json:"max_score"`
Hits []HitTheme `json:"hits"`
} `json:"hits"`
}
type HitTheme struct {
Index string `json:"_index"`
Type string `json:"_type"`
Id string `json:"_id"`
Score float64 `json:"_score"`
Source EsTheme `json:"_source"`
}