feat(kol): add sqlc queries for all KOL tables
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
// source: kol_profile.sql
|
||||
|
||||
package generated
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const getKolProfileByID = `-- name: GetKolProfileByID :one
|
||||
SELECT id, tenant_id, user_id, display_name, bio, avatar_url,
|
||||
market_enabled, status, created_at, updated_at
|
||||
FROM kol_profiles
|
||||
WHERE id = $1 AND deleted_at IS NULL
|
||||
`
|
||||
|
||||
type GetKolProfileByIDRow struct {
|
||||
ID int64 `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Bio pgtype.Text `json:"bio"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
MarketEnabled bool `json:"market_enabled"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetKolProfileByID(ctx context.Context, id int64) (GetKolProfileByIDRow, error) {
|
||||
row := q.db.QueryRow(ctx, getKolProfileByID, id)
|
||||
var i GetKolProfileByIDRow
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.TenantID,
|
||||
&i.UserID,
|
||||
&i.DisplayName,
|
||||
&i.Bio,
|
||||
&i.AvatarUrl,
|
||||
&i.MarketEnabled,
|
||||
&i.Status,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getKolProfileByUser = `-- name: GetKolProfileByUser :one
|
||||
SELECT id, tenant_id, user_id, display_name, bio, avatar_url,
|
||||
market_enabled, status, created_at, updated_at
|
||||
FROM kol_profiles
|
||||
WHERE user_id = $1::bigint
|
||||
AND tenant_id = $2::bigint
|
||||
AND deleted_at IS NULL
|
||||
`
|
||||
|
||||
type GetKolProfileByUserParams struct {
|
||||
UserID int64 `json:"user_id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
}
|
||||
|
||||
type GetKolProfileByUserRow struct {
|
||||
ID int64 `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Bio pgtype.Text `json:"bio"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
MarketEnabled bool `json:"market_enabled"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetKolProfileByUser(ctx context.Context, arg GetKolProfileByUserParams) (GetKolProfileByUserRow, error) {
|
||||
row := q.db.QueryRow(ctx, getKolProfileByUser, arg.UserID, arg.TenantID)
|
||||
var i GetKolProfileByUserRow
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.TenantID,
|
||||
&i.UserID,
|
||||
&i.DisplayName,
|
||||
&i.Bio,
|
||||
&i.AvatarUrl,
|
||||
&i.MarketEnabled,
|
||||
&i.Status,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateKolProfile = `-- name: UpdateKolProfile :exec
|
||||
UPDATE kol_profiles
|
||||
SET display_name = $1,
|
||||
bio = $2,
|
||||
avatar_url = $3,
|
||||
updated_at = NOW()
|
||||
WHERE id = $4
|
||||
AND tenant_id = $5::bigint
|
||||
AND deleted_at IS NULL
|
||||
`
|
||||
|
||||
type UpdateKolProfileParams struct {
|
||||
DisplayName string `json:"display_name"`
|
||||
Bio pgtype.Text `json:"bio"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
ID int64 `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateKolProfile(ctx context.Context, arg UpdateKolProfileParams) error {
|
||||
_, err := q.db.Exec(ctx, updateKolProfile,
|
||||
arg.DisplayName,
|
||||
arg.Bio,
|
||||
arg.AvatarUrl,
|
||||
arg.ID,
|
||||
arg.TenantID,
|
||||
)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user