/
guild_borderwall_requests_query.sql.go
230 lines (214 loc) · 5.94 KB
/
guild_borderwall_requests_query.sql.go
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.26.0
// source: guild_borderwall_requests_query.sql
package database
import (
"context"
"database/sql"
"github.com/gofrs/uuid"
"github.com/jackc/pgtype"
)
const CreateBorderwallRequest = `-- name: CreateBorderwallRequest :one
INSERT INTO borderwall_requests (request_uuid, created_at, updated_at, guild_id, user_id, is_verified)
VALUES (uuid_generate_v7(), now(), now(), $1, $2, FALSE)
RETURNING
request_uuid, created_at, updated_at, guild_id, user_id, is_verified, verified_at, ip_address, recaptcha_score, ipintel_score, country_code, ua_family, ua_family_version, ua_os, ua_os_version
`
type CreateBorderwallRequestParams struct {
GuildID int64 `json:"guild_id"`
UserID int64 `json:"user_id"`
}
func (q *Queries) CreateBorderwallRequest(ctx context.Context, arg *CreateBorderwallRequestParams) (*BorderwallRequests, error) {
row := q.db.QueryRow(ctx, CreateBorderwallRequest, arg.GuildID, arg.UserID)
var i BorderwallRequests
err := row.Scan(
&i.RequestUuid,
&i.CreatedAt,
&i.UpdatedAt,
&i.GuildID,
&i.UserID,
&i.IsVerified,
&i.VerifiedAt,
&i.IpAddress,
&i.RecaptchaScore,
&i.IpintelScore,
&i.CountryCode,
&i.UaFamily,
&i.UaFamilyVersion,
&i.UaOs,
&i.UaOsVersion,
)
return &i, err
}
const GetBorderwallRequest = `-- name: GetBorderwallRequest :one
SELECT
request_uuid, created_at, updated_at, guild_id, user_id, is_verified, verified_at, ip_address, recaptcha_score, ipintel_score, country_code, ua_family, ua_family_version, ua_os, ua_os_version
FROM
borderwall_requests
WHERE
request_uuid = $1
`
func (q *Queries) GetBorderwallRequest(ctx context.Context, requestUuid uuid.UUID) (*BorderwallRequests, error) {
row := q.db.QueryRow(ctx, GetBorderwallRequest, requestUuid)
var i BorderwallRequests
err := row.Scan(
&i.RequestUuid,
&i.CreatedAt,
&i.UpdatedAt,
&i.GuildID,
&i.UserID,
&i.IsVerified,
&i.VerifiedAt,
&i.IpAddress,
&i.RecaptchaScore,
&i.IpintelScore,
&i.CountryCode,
&i.UaFamily,
&i.UaFamilyVersion,
&i.UaOs,
&i.UaOsVersion,
)
return &i, err
}
const GetBorderwallRequestsByGuildIDUserID = `-- name: GetBorderwallRequestsByGuildIDUserID :many
SELECT
request_uuid, created_at, updated_at, guild_id, user_id, is_verified, verified_at, ip_address, recaptcha_score, ipintel_score, country_code, ua_family, ua_family_version, ua_os, ua_os_version
FROM
borderwall_requests
WHERE
guild_id = $1
AND user_id = $2
`
type GetBorderwallRequestsByGuildIDUserIDParams struct {
GuildID int64 `json:"guild_id"`
UserID int64 `json:"user_id"`
}
func (q *Queries) GetBorderwallRequestsByGuildIDUserID(ctx context.Context, arg *GetBorderwallRequestsByGuildIDUserIDParams) ([]*BorderwallRequests, error) {
rows, err := q.db.Query(ctx, GetBorderwallRequestsByGuildIDUserID, arg.GuildID, arg.UserID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []*BorderwallRequests{}
for rows.Next() {
var i BorderwallRequests
if err := rows.Scan(
&i.RequestUuid,
&i.CreatedAt,
&i.UpdatedAt,
&i.GuildID,
&i.UserID,
&i.IsVerified,
&i.VerifiedAt,
&i.IpAddress,
&i.RecaptchaScore,
&i.IpintelScore,
&i.CountryCode,
&i.UaFamily,
&i.UaFamilyVersion,
&i.UaOs,
&i.UaOsVersion,
); err != nil {
return nil, err
}
items = append(items, &i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetBorderwallRequestsByIPAddress = `-- name: GetBorderwallRequestsByIPAddress :many
SELECT
request_uuid, created_at, updated_at, guild_id, user_id, is_verified, verified_at, ip_address, recaptcha_score, ipintel_score, country_code, ua_family, ua_family_version, ua_os, ua_os_version
FROM
borderwall_requests
WHERE
ip_address = $1
`
func (q *Queries) GetBorderwallRequestsByIPAddress(ctx context.Context, ipAddress pgtype.Inet) ([]*BorderwallRequests, error) {
rows, err := q.db.Query(ctx, GetBorderwallRequestsByIPAddress, ipAddress)
if err != nil {
return nil, err
}
defer rows.Close()
items := []*BorderwallRequests{}
for rows.Next() {
var i BorderwallRequests
if err := rows.Scan(
&i.RequestUuid,
&i.CreatedAt,
&i.UpdatedAt,
&i.GuildID,
&i.UserID,
&i.IsVerified,
&i.VerifiedAt,
&i.IpAddress,
&i.RecaptchaScore,
&i.IpintelScore,
&i.CountryCode,
&i.UaFamily,
&i.UaFamilyVersion,
&i.UaOs,
&i.UaOsVersion,
); err != nil {
return nil, err
}
items = append(items, &i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const UpdateBorderwallRequest = `-- name: UpdateBorderwallRequest :execrows
UPDATE
borderwall_requests
SET
updated_at = now(),
is_verified = $2,
verified_at = $3,
ip_address = $4,
recaptcha_score = $5,
ipintel_score = $6,
country_code = $7,
ua_family = $8,
ua_family_version = $9,
ua_os = $10,
ua_os_version = $11
WHERE
request_uuid = $1
`
type UpdateBorderwallRequestParams struct {
RequestUuid uuid.UUID `json:"request_uuid"`
IsVerified bool `json:"is_verified"`
VerifiedAt sql.NullTime `json:"verified_at"`
IpAddress pgtype.Inet `json:"ip_address"`
RecaptchaScore sql.NullFloat64 `json:"recaptcha_score"`
IpintelScore sql.NullFloat64 `json:"ipintel_score"`
CountryCode sql.NullString `json:"country_code"`
UaFamily sql.NullString `json:"ua_family"`
UaFamilyVersion sql.NullString `json:"ua_family_version"`
UaOs sql.NullString `json:"ua_os"`
UaOsVersion sql.NullString `json:"ua_os_version"`
}
func (q *Queries) UpdateBorderwallRequest(ctx context.Context, arg *UpdateBorderwallRequestParams) (int64, error) {
result, err := q.db.Exec(ctx, UpdateBorderwallRequest,
arg.RequestUuid,
arg.IsVerified,
arg.VerifiedAt,
arg.IpAddress,
arg.RecaptchaScore,
arg.IpintelScore,
arg.CountryCode,
arg.UaFamily,
arg.UaFamilyVersion,
arg.UaOs,
arg.UaOsVersion,
)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}