mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-23 21:36:37 +08:00
实现基础的IP地址阈值
This commit is contained in:
31
internal/db/models/node_ip_address_threshold_model_ext.go
Normal file
31
internal/db/models/node_ip_address_threshold_model_ext.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||
)
|
||||
|
||||
func (this *NodeIPAddressThreshold) DecodeItems() (result []*nodeconfigs.NodeValueThresholdItemConfig) {
|
||||
if len(this.Items) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
err := json.Unmarshal([]byte(this.Items), &result)
|
||||
if err != nil {
|
||||
remotelogs.Error("NodeIPAddressThreshold", "decode items: "+err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *NodeIPAddressThreshold) DecodeActions() (result []*nodeconfigs.NodeValueThresholdActionConfig) {
|
||||
if len(this.Actions) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
err := json.Unmarshal([]byte(this.Actions), &result)
|
||||
if err != nil {
|
||||
remotelogs.Error("NodeIPAddressThreshold", "decode actions: "+err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user