risk.sql.go56 lines, 1.2 KB
| 1 | // Code generated by sqlc. DO NOT EDIT. |
| 2 | // versions: |
| 3 | // sqlc v1.31.1 |
| 4 | // source: risk.sql |
| 5 | |
| 6 | package transferdb |
| 7 | |
| 8 | import ( |
| 9 | "context" |
| 10 | |
| 11 | "github.com/google/uuid" |
| 12 | ) |
| 13 | |
| 14 | const insertDecision = `-- name: InsertDecision :exec |
| 15 | INSERT INTO risk_decisions (transfer_id, decision, reasons, decided_by, note) |
| 16 | VALUES ($1, $2, coalesce($3::text[], '{}'), $4, $5) |
| 17 | ` |
| 18 | |
| 19 | type InsertDecisionParams struct { |
| 20 | TransferID uuid.UUID |
| 21 | Decision string |
| 22 | Reasons []string |
| 23 | DecidedBy string |
| 24 | Note string |
| 25 | } |
| 26 | |
| 27 | func (q *Queries) InsertDecision(ctx context.Context, arg InsertDecisionParams) error { |
| 28 | _, err := q.db.Exec(ctx, insertDecision, |
| 29 | arg.TransferID, |
| 30 | arg.Decision, |
| 31 | arg.Reasons, |
| 32 | arg.DecidedBy, |
| 33 | arg.Note, |
| 34 | ) |
| 35 | return err |
| 36 | } |
| 37 | |
| 38 | const paidBefore = `-- name: PaidBefore :one |
| 39 | SELECT EXISTS ( |
| 40 | SELECT 1 FROM transfers |
| 41 | WHERE user_id = $1 AND to_wallet_id = $2 AND state = 'completed' |
| 42 | ) |
| 43 | ` |
| 44 | |
| 45 | type PaidBeforeParams struct { |
| 46 | UserID uuid.UUID |
| 47 | ToWalletID uuid.UUID |
| 48 | } |
| 49 | |
| 50 | // Has this user ever completed a transfer to this wallet? |
| 51 | func (q *Queries) PaidBefore(ctx context.Context, arg PaidBeforeParams) (bool, error) { |
| 52 | row := q.db.QueryRow(ctx, paidBefore, arg.UserID, arg.ToWalletID) |
| 53 | var exists bool |
| 54 | err := row.Scan(&exists) |
| 55 | return exists, err |
| 56 | } |