298 lines
8.1 KiB
Go
298 lines
8.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: kol_package.sql
|
|
|
|
package generated
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createKolPackage = `-- name: CreateKolPackage :one
|
|
INSERT INTO kol_packages (tenant_id, kol_profile_id, name, description, cover_url, industry, tags, price_note, status)
|
|
VALUES ($1::bigint, $2, $3,
|
|
$4, $5, $6,
|
|
$7::jsonb, $8, 'draft')
|
|
RETURNING id, tenant_id, kol_profile_id, name, description, cover_url,
|
|
industry, tags, price_note, status, created_at, updated_at
|
|
`
|
|
|
|
type CreateKolPackageParams struct {
|
|
TenantID int64 `json:"tenant_id"`
|
|
KolProfileID int64 `json:"kol_profile_id"`
|
|
Name string `json:"name"`
|
|
Description pgtype.Text `json:"description"`
|
|
CoverUrl pgtype.Text `json:"cover_url"`
|
|
Industry pgtype.Text `json:"industry"`
|
|
Tags []byte `json:"tags"`
|
|
PriceNote pgtype.Text `json:"price_note"`
|
|
}
|
|
|
|
type CreateKolPackageRow struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
KolProfileID int64 `json:"kol_profile_id"`
|
|
Name string `json:"name"`
|
|
Description pgtype.Text `json:"description"`
|
|
CoverUrl pgtype.Text `json:"cover_url"`
|
|
Industry pgtype.Text `json:"industry"`
|
|
Tags []byte `json:"tags"`
|
|
PriceNote pgtype.Text `json:"price_note"`
|
|
Status string `json:"status"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) CreateKolPackage(ctx context.Context, arg CreateKolPackageParams) (CreateKolPackageRow, error) {
|
|
row := q.db.QueryRow(ctx, createKolPackage,
|
|
arg.TenantID,
|
|
arg.KolProfileID,
|
|
arg.Name,
|
|
arg.Description,
|
|
arg.CoverUrl,
|
|
arg.Industry,
|
|
arg.Tags,
|
|
arg.PriceNote,
|
|
)
|
|
var i CreateKolPackageRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.TenantID,
|
|
&i.KolProfileID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.CoverUrl,
|
|
&i.Industry,
|
|
&i.Tags,
|
|
&i.PriceNote,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getKolPackageByID = `-- name: GetKolPackageByID :one
|
|
SELECT id, tenant_id, kol_profile_id, name, description, cover_url,
|
|
industry, tags, price_note, status, created_at, updated_at
|
|
FROM kol_packages
|
|
WHERE id = $1
|
|
AND tenant_id = $2::bigint
|
|
AND deleted_at IS NULL
|
|
`
|
|
|
|
type GetKolPackageByIDParams struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
type GetKolPackageByIDRow struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
KolProfileID int64 `json:"kol_profile_id"`
|
|
Name string `json:"name"`
|
|
Description pgtype.Text `json:"description"`
|
|
CoverUrl pgtype.Text `json:"cover_url"`
|
|
Industry pgtype.Text `json:"industry"`
|
|
Tags []byte `json:"tags"`
|
|
PriceNote pgtype.Text `json:"price_note"`
|
|
Status string `json:"status"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) GetKolPackageByID(ctx context.Context, arg GetKolPackageByIDParams) (GetKolPackageByIDRow, error) {
|
|
row := q.db.QueryRow(ctx, getKolPackageByID, arg.ID, arg.TenantID)
|
|
var i GetKolPackageByIDRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.TenantID,
|
|
&i.KolProfileID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.CoverUrl,
|
|
&i.Industry,
|
|
&i.Tags,
|
|
&i.PriceNote,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listKolPackageIDsByProfile = `-- name: ListKolPackageIDsByProfile :many
|
|
SELECT id
|
|
FROM kol_packages
|
|
WHERE kol_profile_id = $1
|
|
AND tenant_id = $2::bigint
|
|
AND deleted_at IS NULL
|
|
`
|
|
|
|
type ListKolPackageIDsByProfileParams struct {
|
|
KolProfileID int64 `json:"kol_profile_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) ListKolPackageIDsByProfile(ctx context.Context, arg ListKolPackageIDsByProfileParams) ([]int64, error) {
|
|
rows, err := q.db.Query(ctx, listKolPackageIDsByProfile, arg.KolProfileID, arg.TenantID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []int64
|
|
for rows.Next() {
|
|
var id int64
|
|
if err := rows.Scan(&id); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, id)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listKolPackagesByProfile = `-- name: ListKolPackagesByProfile :many
|
|
SELECT id, tenant_id, kol_profile_id, name, description, cover_url,
|
|
industry, tags, price_note, status, created_at, updated_at
|
|
FROM kol_packages
|
|
WHERE kol_profile_id = $1
|
|
AND tenant_id = $2::bigint
|
|
AND deleted_at IS NULL
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
type ListKolPackagesByProfileParams struct {
|
|
KolProfileID int64 `json:"kol_profile_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
type ListKolPackagesByProfileRow struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
KolProfileID int64 `json:"kol_profile_id"`
|
|
Name string `json:"name"`
|
|
Description pgtype.Text `json:"description"`
|
|
CoverUrl pgtype.Text `json:"cover_url"`
|
|
Industry pgtype.Text `json:"industry"`
|
|
Tags []byte `json:"tags"`
|
|
PriceNote pgtype.Text `json:"price_note"`
|
|
Status string `json:"status"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) ListKolPackagesByProfile(ctx context.Context, arg ListKolPackagesByProfileParams) ([]ListKolPackagesByProfileRow, error) {
|
|
rows, err := q.db.Query(ctx, listKolPackagesByProfile, arg.KolProfileID, arg.TenantID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListKolPackagesByProfileRow
|
|
for rows.Next() {
|
|
var i ListKolPackagesByProfileRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.TenantID,
|
|
&i.KolProfileID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.CoverUrl,
|
|
&i.Industry,
|
|
&i.Tags,
|
|
&i.PriceNote,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const softDeleteKolPackage = `-- name: SoftDeleteKolPackage :exec
|
|
UPDATE kol_packages SET deleted_at = NOW()
|
|
WHERE id = $1
|
|
AND tenant_id = $2::bigint
|
|
AND deleted_at IS NULL
|
|
`
|
|
|
|
type SoftDeleteKolPackageParams struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) SoftDeleteKolPackage(ctx context.Context, arg SoftDeleteKolPackageParams) error {
|
|
_, err := q.db.Exec(ctx, softDeleteKolPackage, arg.ID, arg.TenantID)
|
|
return err
|
|
}
|
|
|
|
const updateKolPackage = `-- name: UpdateKolPackage :exec
|
|
UPDATE kol_packages
|
|
SET name = $1,
|
|
description = $2,
|
|
cover_url = $3,
|
|
industry = $4,
|
|
tags = $5::jsonb,
|
|
price_note = $6,
|
|
updated_at = NOW()
|
|
WHERE id = $7
|
|
AND tenant_id = $8::bigint
|
|
AND deleted_at IS NULL
|
|
`
|
|
|
|
type UpdateKolPackageParams struct {
|
|
Name string `json:"name"`
|
|
Description pgtype.Text `json:"description"`
|
|
CoverUrl pgtype.Text `json:"cover_url"`
|
|
Industry pgtype.Text `json:"industry"`
|
|
Tags []byte `json:"tags"`
|
|
PriceNote pgtype.Text `json:"price_note"`
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateKolPackage(ctx context.Context, arg UpdateKolPackageParams) error {
|
|
_, err := q.db.Exec(ctx, updateKolPackage,
|
|
arg.Name,
|
|
arg.Description,
|
|
arg.CoverUrl,
|
|
arg.Industry,
|
|
arg.Tags,
|
|
arg.PriceNote,
|
|
arg.ID,
|
|
arg.TenantID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateKolPackageStatus = `-- name: UpdateKolPackageStatus :exec
|
|
UPDATE kol_packages
|
|
SET status = $1,
|
|
updated_at = NOW()
|
|
WHERE id = $2
|
|
AND tenant_id = $3::bigint
|
|
AND deleted_at IS NULL
|
|
`
|
|
|
|
type UpdateKolPackageStatusParams struct {
|
|
Status string `json:"status"`
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateKolPackageStatus(ctx context.Context, arg UpdateKolPackageStatusParams) error {
|
|
_, err := q.db.Exec(ctx, updateKolPackageStatus, arg.Status, arg.ID, arg.TenantID)
|
|
return err
|
|
}
|