2021-09-12 20:21:42 +08:00
|
|
|
package models
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
2024-07-27 14:15:25 +08:00
|
|
|
|
2021-09-12 20:21:42 +08:00
|
|
|
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
|
|
|
|
)
|
|
|
|
|
|
2021-09-14 19:38:44 +08:00
|
|
|
func (this *NodeIPAddressThreshold) DecodeItems() (result []*nodeconfigs.IPAddressThresholdItemConfig) {
|
2021-09-12 20:21:42 +08:00
|
|
|
if len(this.Items) == 0 {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-22 19:30:30 +08:00
|
|
|
err := json.Unmarshal(this.Items, &result)
|
2021-09-12 20:21:42 +08:00
|
|
|
if err != nil {
|
|
|
|
|
remotelogs.Error("NodeIPAddressThreshold", "decode items: "+err.Error())
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 19:38:44 +08:00
|
|
|
func (this *NodeIPAddressThreshold) DecodeActions() (result []*nodeconfigs.IPAddressThresholdActionConfig) {
|
2021-09-12 20:21:42 +08:00
|
|
|
if len(this.Actions) == 0 {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-22 19:30:30 +08:00
|
|
|
err := json.Unmarshal(this.Actions, &result)
|
2021-09-12 20:21:42 +08:00
|
|
|
if err != nil {
|
|
|
|
|
remotelogs.Error("NodeIPAddressThreshold", "decode actions: "+err.Error())
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|