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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.26.0
// source: query.sql
package db
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const deleteDnsBlackList = `-- name: DeleteDnsBlackList :exec
DELETE FROM DnsBlackList
WHERE Name = $1
`
func (q *Queries) DeleteDnsBlackList(ctx context.Context, name string) error {
_, err := q.db.Exec(ctx, deleteDnsBlackList, name)
return err
}
const deleteMacBlackList = `-- name: DeleteMacBlackList :exec
DELETE FROM MacBlackList
WHERE HardwareAddr = $1
`
func (q *Queries) DeleteMacBlackList(ctx context.Context, hardwareaddr int64) error {
_, err := q.db.Exec(ctx, deleteMacBlackList, hardwareaddr)
return err
}
const enterDnsBlackList = `-- name: EnterDnsBlackList :exec
INSERT INTO DnsBlackList (
Name
) VALUES (
$1
)
`
func (q *Queries) EnterDnsBlackList(ctx context.Context, name string) error {
_, err := q.db.Exec(ctx, enterDnsBlackList, name)
return err
}
const enterMacBlackList = `-- name: EnterMacBlackList :exec
INSERT INTO MacBlackList (
HardwareAddr
) VALUES (
$1
)
`
func (q *Queries) EnterMacBlackList(ctx context.Context, hardwareaddr int64) error {
_, err := q.db.Exec(ctx, enterMacBlackList, hardwareaddr)
return err
}
const enterUsage = `-- name: EnterUsage :exec
INSERT INTO Usage (
HardwareAddr, StartTime, StopTime, Egress, Ingress
) VALUES (
$1, $2, $3, $4, $5
)
`
type EnterUsageParams struct {
Hardwareaddr int64
Starttime pgtype.Timestamp
Stoptime pgtype.Timestamp
Egress int64
Ingress int64
}
func (q *Queries) EnterUsage(ctx context.Context, arg EnterUsageParams) error {
_, err := q.db.Exec(ctx, enterUsage,
arg.Hardwareaddr,
arg.Starttime,
arg.Stoptime,
arg.Egress,
arg.Ingress,
)
return err
}
const getDnsBlackList = `-- name: GetDnsBlackList :many
SELECT name FROM DnsBlackList
`
func (q *Queries) GetDnsBlackList(ctx context.Context) ([]string, error) {
rows, err := q.db.Query(ctx, getDnsBlackList)
if err != nil {
return nil, err
}
defer rows.Close()
var items []string
for rows.Next() {
var name string
if err := rows.Scan(&name); err != nil {
return nil, err
}
items = append(items, name)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getMacBlackList = `-- name: GetMacBlackList :many
SELECT hardwareaddr FROM MacBlackList
`
func (q *Queries) GetMacBlackList(ctx context.Context) ([]int64, error) {
rows, err := q.db.Query(ctx, getMacBlackList)
if err != nil {
return nil, err
}
defer rows.Close()
var items []int64
for rows.Next() {
var hardwareaddr int64
if err := rows.Scan(&hardwareaddr); err != nil {
return nil, err
}
items = append(items, hardwareaddr)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getUsage = `-- name: GetUsage :one
SELECT SUM(Ingress) AS Ingress, SUM(Egress) AS Egress FROM Usage
`
type GetUsageRow struct {
Ingress int64
Egress int64
}
func (q *Queries) GetUsage(ctx context.Context) (GetUsageRow, error) {
row := q.db.QueryRow(ctx, getUsage)
var i GetUsageRow
err := row.Scan(&i.Ingress, &i.Egress)
return i, err
}
|