summaryrefslogblamecommitdiff
path: root/db/query.sql.go
blob: 7c287233fb0c6c602bf8363d3f25d0bd9b174c9c (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                        









                                                                              












                                                                             








                                                    
                          

                                     

                          











                                                                               
 
                                                       
                             





















                                                                          
                                        
                                                                












                                                                      
// 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 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 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 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
}