mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.8 KiB
77 lines
1.8 KiB
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.25.0
|
|
// source: security.sql
|
|
|
|
package pgc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createPhoneCaptcha = `-- name: CreatePhoneCaptcha :one
|
|
INSERT INTO p_captcha (phone, captcha, expired_on, created_on)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING id
|
|
`
|
|
|
|
type CreatePhoneCaptchaParams struct {
|
|
Phone pgtype.Text
|
|
Captcha pgtype.Text
|
|
ExpiredOn int64
|
|
CreatedOn int64
|
|
}
|
|
|
|
func (q *Queries) CreatePhoneCaptcha(ctx context.Context, arg *CreatePhoneCaptchaParams) (int64, error) {
|
|
row := q.db.QueryRow(ctx, createPhoneCaptcha,
|
|
arg.Phone,
|
|
arg.Captcha,
|
|
arg.ExpiredOn,
|
|
arg.CreatedOn,
|
|
)
|
|
var id int64
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const getLatestPhoneCaptcha = `-- name: GetLatestPhoneCaptcha :one
|
|
|
|
SELECT id, phone, captcha, use_times, expired_on, created_on, modified_on, deleted_on, is_del FROM p_captcha WHERE phone=$1 AND is_del=0
|
|
`
|
|
|
|
// ------------------------------------------------------------------------------
|
|
// security sql dml
|
|
// ------------------------------------------------------------------------------
|
|
func (q *Queries) GetLatestPhoneCaptcha(ctx context.Context, phone pgtype.Text) (*PCaptcha, error) {
|
|
row := q.db.QueryRow(ctx, getLatestPhoneCaptcha, phone)
|
|
var i PCaptcha
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Phone,
|
|
&i.Captcha,
|
|
&i.UseTimes,
|
|
&i.ExpiredOn,
|
|
&i.CreatedOn,
|
|
&i.ModifiedOn,
|
|
&i.DeletedOn,
|
|
&i.IsDel,
|
|
)
|
|
return &i, err
|
|
}
|
|
|
|
const usePhoneCaptcha = `-- name: UsePhoneCaptcha :exec
|
|
UPDATE p_captcha SET use_times=use_times+1, modified_on=$1 WHERE id=$2 AND is_del=0
|
|
`
|
|
|
|
type UsePhoneCaptchaParams struct {
|
|
ModifiedOn int64
|
|
ID int64
|
|
}
|
|
|
|
func (q *Queries) UsePhoneCaptcha(ctx context.Context, arg *UsePhoneCaptchaParams) error {
|
|
_, err := q.db.Exec(ctx, usePhoneCaptcha, arg.ModifiedOn, arg.ID)
|
|
return err
|
|
}
|