owpengram-server/internal/store/postgres/sqlcgen/account.sql.go
2026-06-04 01:37:39 +08:00

87 lines
2.2 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: account.sql
package sqlcgen
import (
"context"
)
const getPasswordByUser = `-- name: GetPasswordByUser :one
SELECT
user_id, has_recovery, has_secure_values, has_password, hint,
email_unconfirmed_pattern, login_email_pattern, secure_random
FROM account_passwords
WHERE user_id = $1
`
type GetPasswordByUserRow struct {
UserID int64
HasRecovery bool
HasSecureValues bool
HasPassword bool
Hint string
EmailUnconfirmedPattern string
LoginEmailPattern string
SecureRandom []byte
}
func (q *Queries) GetPasswordByUser(ctx context.Context, userID int64) (GetPasswordByUserRow, error) {
row := q.db.QueryRow(ctx, getPasswordByUser, userID)
var i GetPasswordByUserRow
err := row.Scan(
&i.UserID,
&i.HasRecovery,
&i.HasSecureValues,
&i.HasPassword,
&i.Hint,
&i.EmailUnconfirmedPattern,
&i.LoginEmailPattern,
&i.SecureRandom,
)
return i, err
}
const upsertPassword = `-- name: UpsertPassword :exec
INSERT INTO account_passwords (
user_id, has_recovery, has_secure_values, has_password, hint,
email_unconfirmed_pattern, login_email_pattern, secure_random
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
ON CONFLICT (user_id) DO UPDATE SET
has_recovery = EXCLUDED.has_recovery,
has_secure_values = EXCLUDED.has_secure_values,
has_password = EXCLUDED.has_password,
hint = EXCLUDED.hint,
email_unconfirmed_pattern = EXCLUDED.email_unconfirmed_pattern,
login_email_pattern = EXCLUDED.login_email_pattern,
secure_random = EXCLUDED.secure_random,
updated_at = now()
`
type UpsertPasswordParams struct {
UserID int64
HasRecovery bool
HasSecureValues bool
HasPassword bool
Hint string
EmailUnconfirmedPattern string
LoginEmailPattern string
SecureRandom []byte
}
func (q *Queries) UpsertPassword(ctx context.Context, arg UpsertPasswordParams) error {
_, err := q.db.Exec(ctx, upsertPassword,
arg.UserID,
arg.HasRecovery,
arg.HasSecureValues,
arg.HasPassword,
arg.Hint,
arg.EmailUnconfirmedPattern,
arg.LoginEmailPattern,
arg.SecureRandom,
)
return err
}