qixiaoning
2025-08-11 ad4ad76f4cd6db55ddceedcff5bf588547786f31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package vo
 
import (
    "encoding/json"
    "strings"
    "vamicro/push-service/models"
)
 
type EventPushVo struct {
    Id           string `json:"id"`
    Name         string `json:"name"`
    PushType     int    `json:"push_type"`
    TimeStart    string `json:"time_start"`
    TimeEnd      string `json:"time_end"`
    IsSatisfyAll bool   `json:"is_satisfy_all"`
    RuleText     string `json:"rule_text"`
    Enable       bool   `json:"enable"`
    LinkType     string `json:"link_type"`
    LinkDevice   string `json:"link_device"`
 
    IpPorts []EventPushServerPortVo `json:"ip_ports"`
    Urls    []EventUrlVo            `json:"urls"`
    Rules   []models.EventPushRule  `json:"rules"`
 
    FiltRename map[string]string `json:"filtRename"`
    PushSet    []PushSetMenu     `json:"push_set"`
}
 
type PushSetMenu struct {
    Id       string        `json:"id"`
    Name     string        `json:"name"`
    Checked  bool          `json:"checked"`
    Alias    string        `json:"alias"`
    Children []PushSetMenu `json:"children"`
}
 
type EventPushServerPortVo struct {
    ServerIp string `json:"server_ip"`
    Port     int    `json:"port"`
    Enable   bool   `json:"enable"`
}
 
type EventUrlVo struct {
    Url      string `json:"url"`
    ServerIp string `json:"server_ip"`
    Port     int    `json:"port"`
    Enable   bool   `json:"enable"`
}
 
func (epv *EventPushVo) SetFiltRename() {
    epv.FiltRename = make(map[string]string)
    if epv.PushSet != nil {
        for _, set := range epv.PushSet {
            if set.Children != nil {
                for _, child := range set.Children {
                    if child.Checked {
                        prefix := ""
                        idx := strings.LastIndex(child.Id, ".")
                        if idx > -1 {
                            prefix = child.Id[:idx+1]
                        }
                        epv.FiltRename[child.Id] = prefix + child.Alias
                    }
                }
            }
        }
    }
}
 
func (epv *EventPushVo) CopyToEventPush() models.EventPush {
    d, _ := json.Marshal(epv.PushSet)
    return models.EventPush{
        Id:           epv.Id,
        Name:         epv.Name,
        TimeStart:    epv.TimeStart,
        TimeEnd:      epv.TimeEnd,
        IsSatisfyAll: epv.IsSatisfyAll,
        RuleText:     epv.RuleText,
        Enable:       epv.Enable,
        PushType:     epv.PushType,
        LinkType:     epv.LinkType,
        LinkDevice:   epv.LinkDevice,
        PushSet:      string(d),
    }
}
 
func (epv *EventPushVo) CopyFromEventPush(epE *models.EventPush) {
    epv.Id = epE.Id
    epv.Name = epE.Name
    epv.TimeStart = epE.TimeStart
    epv.TimeEnd = epE.TimeEnd
    epv.IsSatisfyAll = epE.IsSatisfyAll
    epv.PushType = epE.PushType
    epv.RuleText = epE.RuleText
    epv.Enable = epE.Enable
    epv.LinkType = epE.LinkType
    epv.LinkDevice = epE.LinkDevice
    if epE.PushSet != "" {
        var set []PushSetMenu
        if err := json.Unmarshal([]byte(epE.PushSet), &set); err == nil {
            epv.PushSet = set
        } else {
            epv.PushSet = make([]PushSetMenu, 0)
        }
    } else {
        epv.PushSet = make([]PushSetMenu, 0)
    }
}
 
type KeyValueVo struct {
    Value string `json:"value"`
    Name  string `json:"name"`
}