8958cb44c0
- Removed ListQuestionVersions method and associated types from BrandService and Queries. - Updated PromptRuleGenerationService to change task naming and handling. - Enhanced ScheduleTaskService to support filtering by created date range and keyword. - Introduced InstantTaskService for managing instant tasks with appropriate filtering and response structures. - Added InstantTaskHandler for handling API requests related to instant tasks. - Created InstantTaskTab component for the admin web interface to display and manage instant tasks. - Updated database migrations to rename source types for articles and generation tasks. - Adjusted models and repository queries to reflect the removal of question version handling.
602 lines
17 KiB
Go
602 lines
17 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: brand.sql
|
|
|
|
package generated
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createBrand = `-- name: CreateBrand :one
|
|
INSERT INTO brands (tenant_id, name, description, status)
|
|
VALUES ($1, $2, $3, 'active')
|
|
RETURNING id, created_at
|
|
`
|
|
|
|
type CreateBrandParams struct {
|
|
TenantID int64 `json:"tenant_id"`
|
|
Name string `json:"name"`
|
|
Description pgtype.Text `json:"description"`
|
|
}
|
|
|
|
type CreateBrandRow struct {
|
|
ID int64 `json:"id"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
}
|
|
|
|
func (q *Queries) CreateBrand(ctx context.Context, arg CreateBrandParams) (CreateBrandRow, error) {
|
|
row := q.db.QueryRow(ctx, createBrand, arg.TenantID, arg.Name, arg.Description)
|
|
var i CreateBrandRow
|
|
err := row.Scan(&i.ID, &i.CreatedAt)
|
|
return i, err
|
|
}
|
|
|
|
const createCompetitor = `-- name: CreateCompetitor :one
|
|
INSERT INTO competitors (tenant_id, brand_id, name, website, description, product_lines_json)
|
|
VALUES ($1, $2, $3, $4, $5, $6)
|
|
RETURNING id, created_at
|
|
`
|
|
|
|
type CreateCompetitorParams struct {
|
|
TenantID int64 `json:"tenant_id"`
|
|
BrandID int64 `json:"brand_id"`
|
|
Name string `json:"name"`
|
|
Website pgtype.Text `json:"website"`
|
|
Description pgtype.Text `json:"description"`
|
|
ProductLinesJson []byte `json:"product_lines_json"`
|
|
}
|
|
|
|
type CreateCompetitorRow struct {
|
|
ID int64 `json:"id"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
}
|
|
|
|
func (q *Queries) CreateCompetitor(ctx context.Context, arg CreateCompetitorParams) (CreateCompetitorRow, error) {
|
|
row := q.db.QueryRow(ctx, createCompetitor,
|
|
arg.TenantID,
|
|
arg.BrandID,
|
|
arg.Name,
|
|
arg.Website,
|
|
arg.Description,
|
|
arg.ProductLinesJson,
|
|
)
|
|
var i CreateCompetitorRow
|
|
err := row.Scan(&i.ID, &i.CreatedAt)
|
|
return i, err
|
|
}
|
|
|
|
const createKeyword = `-- name: CreateKeyword :one
|
|
INSERT INTO brand_keywords (tenant_id, brand_id, name, status)
|
|
VALUES ($1, $2, $3, 'active')
|
|
RETURNING id, created_at
|
|
`
|
|
|
|
type CreateKeywordParams struct {
|
|
TenantID int64 `json:"tenant_id"`
|
|
BrandID int64 `json:"brand_id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
type CreateKeywordRow struct {
|
|
ID int64 `json:"id"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
}
|
|
|
|
func (q *Queries) CreateKeyword(ctx context.Context, arg CreateKeywordParams) (CreateKeywordRow, error) {
|
|
row := q.db.QueryRow(ctx, createKeyword, arg.TenantID, arg.BrandID, arg.Name)
|
|
var i CreateKeywordRow
|
|
err := row.Scan(&i.ID, &i.CreatedAt)
|
|
return i, err
|
|
}
|
|
|
|
const createQuestion = `-- name: CreateQuestion :one
|
|
INSERT INTO brand_questions (tenant_id, brand_id, keyword_id, status)
|
|
VALUES ($1, $2, $3, 'active')
|
|
RETURNING id
|
|
`
|
|
|
|
type CreateQuestionParams struct {
|
|
TenantID int64 `json:"tenant_id"`
|
|
BrandID int64 `json:"brand_id"`
|
|
KeywordID int64 `json:"keyword_id"`
|
|
}
|
|
|
|
func (q *Queries) CreateQuestion(ctx context.Context, arg CreateQuestionParams) (int64, error) {
|
|
row := q.db.QueryRow(ctx, createQuestion, arg.TenantID, arg.BrandID, arg.KeywordID)
|
|
var id int64
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const createQuestionVersion = `-- name: CreateQuestionVersion :one
|
|
INSERT INTO brand_question_versions (question_id, question_text, question_hash, version_no, is_active)
|
|
VALUES ($1, $2, $3, $4, true)
|
|
RETURNING id
|
|
`
|
|
|
|
type CreateQuestionVersionParams struct {
|
|
QuestionID int64 `json:"question_id"`
|
|
QuestionText string `json:"question_text"`
|
|
QuestionHash string `json:"question_hash"`
|
|
VersionNo int32 `json:"version_no"`
|
|
}
|
|
|
|
func (q *Queries) CreateQuestionVersion(ctx context.Context, arg CreateQuestionVersionParams) (int64, error) {
|
|
row := q.db.QueryRow(ctx, createQuestionVersion,
|
|
arg.QuestionID,
|
|
arg.QuestionText,
|
|
arg.QuestionHash,
|
|
arg.VersionNo,
|
|
)
|
|
var id int64
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const deactivateQuestionVersion = `-- name: DeactivateQuestionVersion :exec
|
|
UPDATE brand_question_versions SET is_active = false
|
|
WHERE question_id = $1 AND is_active = true
|
|
`
|
|
|
|
func (q *Queries) DeactivateQuestionVersion(ctx context.Context, questionID int64) error {
|
|
_, err := q.db.Exec(ctx, deactivateQuestionVersion, questionID)
|
|
return err
|
|
}
|
|
|
|
const getBrandByID = `-- name: GetBrandByID :one
|
|
SELECT id, tenant_id, name, description, status, created_at, updated_at
|
|
FROM brands
|
|
WHERE id = $1 AND tenant_id = $2 AND deleted_at IS NULL
|
|
`
|
|
|
|
type GetBrandByIDParams struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
type GetBrandByIDRow struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
Name string `json:"name"`
|
|
Description pgtype.Text `json:"description"`
|
|
Status string `json:"status"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) GetBrandByID(ctx context.Context, arg GetBrandByIDParams) (GetBrandByIDRow, error) {
|
|
row := q.db.QueryRow(ctx, getBrandByID, arg.ID, arg.TenantID)
|
|
var i GetBrandByIDRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.TenantID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getLatestQuestionVersionNo = `-- name: GetLatestQuestionVersionNo :one
|
|
SELECT COALESCE(MAX(version_no), 0)::INT AS max_version
|
|
FROM brand_question_versions
|
|
WHERE question_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetLatestQuestionVersionNo(ctx context.Context, questionID int64) (int32, error) {
|
|
row := q.db.QueryRow(ctx, getLatestQuestionVersionNo, questionID)
|
|
var max_version int32
|
|
err := row.Scan(&max_version)
|
|
return max_version, err
|
|
}
|
|
|
|
const listBrands = `-- name: ListBrands :many
|
|
SELECT id, tenant_id, name, description, status, created_at, updated_at
|
|
FROM brands
|
|
WHERE tenant_id = $1 AND deleted_at IS NULL
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
type ListBrandsRow struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
Name string `json:"name"`
|
|
Description pgtype.Text `json:"description"`
|
|
Status string `json:"status"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) ListBrands(ctx context.Context, tenantID int64) ([]ListBrandsRow, error) {
|
|
rows, err := q.db.Query(ctx, listBrands, tenantID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListBrandsRow
|
|
for rows.Next() {
|
|
var i ListBrandsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.TenantID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&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 listCompetitors = `-- name: ListCompetitors :many
|
|
SELECT id, tenant_id, brand_id, name, website, description, product_lines_json, created_at, updated_at
|
|
FROM competitors
|
|
WHERE brand_id = $1 AND tenant_id = $2 AND deleted_at IS NULL
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
type ListCompetitorsParams struct {
|
|
BrandID int64 `json:"brand_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
type ListCompetitorsRow struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
BrandID int64 `json:"brand_id"`
|
|
Name string `json:"name"`
|
|
Website pgtype.Text `json:"website"`
|
|
Description pgtype.Text `json:"description"`
|
|
ProductLinesJson []byte `json:"product_lines_json"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) ListCompetitors(ctx context.Context, arg ListCompetitorsParams) ([]ListCompetitorsRow, error) {
|
|
rows, err := q.db.Query(ctx, listCompetitors, arg.BrandID, arg.TenantID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListCompetitorsRow
|
|
for rows.Next() {
|
|
var i ListCompetitorsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.TenantID,
|
|
&i.BrandID,
|
|
&i.Name,
|
|
&i.Website,
|
|
&i.Description,
|
|
&i.ProductLinesJson,
|
|
&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 listKeywords = `-- name: ListKeywords :many
|
|
SELECT id, tenant_id, brand_id, name, status, created_at, updated_at
|
|
FROM brand_keywords
|
|
WHERE brand_id = $1 AND tenant_id = $2 AND deleted_at IS NULL
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
type ListKeywordsParams struct {
|
|
BrandID int64 `json:"brand_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
type ListKeywordsRow struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
BrandID int64 `json:"brand_id"`
|
|
Name string `json:"name"`
|
|
Status string `json:"status"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) ListKeywords(ctx context.Context, arg ListKeywordsParams) ([]ListKeywordsRow, error) {
|
|
rows, err := q.db.Query(ctx, listKeywords, arg.BrandID, arg.TenantID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListKeywordsRow
|
|
for rows.Next() {
|
|
var i ListKeywordsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.TenantID,
|
|
&i.BrandID,
|
|
&i.Name,
|
|
&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 listQuestions = `-- name: ListQuestions :many
|
|
SELECT q.id, q.tenant_id, q.brand_id, q.keyword_id, q.current_version_id, q.status, q.created_at,
|
|
v.question_text, v.version_no
|
|
FROM brand_questions q
|
|
LEFT JOIN brand_question_versions v ON v.id = q.current_version_id
|
|
WHERE q.brand_id = $1 AND q.tenant_id = $2 AND q.deleted_at IS NULL
|
|
AND ($3::bigint IS NULL OR q.keyword_id = $3)
|
|
ORDER BY q.created_at DESC
|
|
`
|
|
|
|
type ListQuestionsParams struct {
|
|
BrandID int64 `json:"brand_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
KeywordID pgtype.Int8 `json:"keyword_id"`
|
|
}
|
|
|
|
type ListQuestionsRow struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
BrandID int64 `json:"brand_id"`
|
|
KeywordID int64 `json:"keyword_id"`
|
|
CurrentVersionID pgtype.Int8 `json:"current_version_id"`
|
|
Status string `json:"status"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
QuestionText pgtype.Text `json:"question_text"`
|
|
VersionNo pgtype.Int4 `json:"version_no"`
|
|
}
|
|
|
|
func (q *Queries) ListQuestions(ctx context.Context, arg ListQuestionsParams) ([]ListQuestionsRow, error) {
|
|
rows, err := q.db.Query(ctx, listQuestions, arg.BrandID, arg.TenantID, arg.KeywordID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListQuestionsRow
|
|
for rows.Next() {
|
|
var i ListQuestionsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.TenantID,
|
|
&i.BrandID,
|
|
&i.KeywordID,
|
|
&i.CurrentVersionID,
|
|
&i.Status,
|
|
&i.CreatedAt,
|
|
&i.QuestionText,
|
|
&i.VersionNo,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const softDeleteBrand = `-- name: SoftDeleteBrand :exec
|
|
UPDATE brands SET deleted_at = NOW(), updated_at = NOW()
|
|
WHERE id = $1 AND tenant_id = $2 AND deleted_at IS NULL
|
|
`
|
|
|
|
type SoftDeleteBrandParams struct {
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) SoftDeleteBrand(ctx context.Context, arg SoftDeleteBrandParams) error {
|
|
_, err := q.db.Exec(ctx, softDeleteBrand, arg.ID, arg.TenantID)
|
|
return err
|
|
}
|
|
|
|
const softDeleteCompetitor = `-- name: SoftDeleteCompetitor :exec
|
|
UPDATE competitors SET deleted_at = NOW(), updated_at = NOW()
|
|
WHERE id = $1 AND brand_id = $2 AND tenant_id = $3 AND deleted_at IS NULL
|
|
`
|
|
|
|
type SoftDeleteCompetitorParams struct {
|
|
ID int64 `json:"id"`
|
|
BrandID int64 `json:"brand_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) SoftDeleteCompetitor(ctx context.Context, arg SoftDeleteCompetitorParams) error {
|
|
_, err := q.db.Exec(ctx, softDeleteCompetitor, arg.ID, arg.BrandID, arg.TenantID)
|
|
return err
|
|
}
|
|
|
|
const softDeleteCompetitorsByBrand = `-- name: SoftDeleteCompetitorsByBrand :exec
|
|
UPDATE competitors SET deleted_at = NOW(), updated_at = NOW()
|
|
WHERE brand_id = $1 AND tenant_id = $2 AND deleted_at IS NULL
|
|
`
|
|
|
|
type SoftDeleteCompetitorsByBrandParams struct {
|
|
BrandID int64 `json:"brand_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) SoftDeleteCompetitorsByBrand(ctx context.Context, arg SoftDeleteCompetitorsByBrandParams) error {
|
|
_, err := q.db.Exec(ctx, softDeleteCompetitorsByBrand, arg.BrandID, arg.TenantID)
|
|
return err
|
|
}
|
|
|
|
const softDeleteKeyword = `-- name: SoftDeleteKeyword :exec
|
|
UPDATE brand_keywords SET deleted_at = NOW(), updated_at = NOW()
|
|
WHERE id = $1 AND brand_id = $2 AND tenant_id = $3 AND deleted_at IS NULL
|
|
`
|
|
|
|
type SoftDeleteKeywordParams struct {
|
|
ID int64 `json:"id"`
|
|
BrandID int64 `json:"brand_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) SoftDeleteKeyword(ctx context.Context, arg SoftDeleteKeywordParams) error {
|
|
_, err := q.db.Exec(ctx, softDeleteKeyword, arg.ID, arg.BrandID, arg.TenantID)
|
|
return err
|
|
}
|
|
|
|
const softDeleteKeywordsByBrand = `-- name: SoftDeleteKeywordsByBrand :exec
|
|
UPDATE brand_keywords SET deleted_at = NOW(), updated_at = NOW()
|
|
WHERE brand_id = $1 AND tenant_id = $2 AND deleted_at IS NULL
|
|
`
|
|
|
|
type SoftDeleteKeywordsByBrandParams struct {
|
|
BrandID int64 `json:"brand_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) SoftDeleteKeywordsByBrand(ctx context.Context, arg SoftDeleteKeywordsByBrandParams) error {
|
|
_, err := q.db.Exec(ctx, softDeleteKeywordsByBrand, arg.BrandID, arg.TenantID)
|
|
return err
|
|
}
|
|
|
|
const softDeleteQuestion = `-- name: SoftDeleteQuestion :exec
|
|
UPDATE brand_questions SET deleted_at = NOW(), updated_at = NOW()
|
|
WHERE id = $1 AND brand_id = $2 AND tenant_id = $3 AND deleted_at IS NULL
|
|
`
|
|
|
|
type SoftDeleteQuestionParams struct {
|
|
ID int64 `json:"id"`
|
|
BrandID int64 `json:"brand_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) SoftDeleteQuestion(ctx context.Context, arg SoftDeleteQuestionParams) error {
|
|
_, err := q.db.Exec(ctx, softDeleteQuestion, arg.ID, arg.BrandID, arg.TenantID)
|
|
return err
|
|
}
|
|
|
|
const softDeleteQuestionsByBrand = `-- name: SoftDeleteQuestionsByBrand :exec
|
|
UPDATE brand_questions SET deleted_at = NOW(), updated_at = NOW()
|
|
WHERE brand_id = $1 AND tenant_id = $2 AND deleted_at IS NULL
|
|
`
|
|
|
|
type SoftDeleteQuestionsByBrandParams struct {
|
|
BrandID int64 `json:"brand_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) SoftDeleteQuestionsByBrand(ctx context.Context, arg SoftDeleteQuestionsByBrandParams) error {
|
|
_, err := q.db.Exec(ctx, softDeleteQuestionsByBrand, arg.BrandID, arg.TenantID)
|
|
return err
|
|
}
|
|
|
|
const updateBrand = `-- name: UpdateBrand :exec
|
|
UPDATE brands SET name = $1, description = $2, updated_at = NOW()
|
|
WHERE id = $3 AND tenant_id = $4 AND deleted_at IS NULL
|
|
`
|
|
|
|
type UpdateBrandParams struct {
|
|
Name string `json:"name"`
|
|
Description pgtype.Text `json:"description"`
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateBrand(ctx context.Context, arg UpdateBrandParams) error {
|
|
_, err := q.db.Exec(ctx, updateBrand,
|
|
arg.Name,
|
|
arg.Description,
|
|
arg.ID,
|
|
arg.TenantID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateCompetitor = `-- name: UpdateCompetitor :exec
|
|
UPDATE competitors SET name = $1, website = $2,
|
|
description = $3, product_lines_json = $4, updated_at = NOW()
|
|
WHERE id = $5 AND brand_id = $6 AND tenant_id = $7 AND deleted_at IS NULL
|
|
`
|
|
|
|
type UpdateCompetitorParams struct {
|
|
Name string `json:"name"`
|
|
Website pgtype.Text `json:"website"`
|
|
Description pgtype.Text `json:"description"`
|
|
ProductLinesJson []byte `json:"product_lines_json"`
|
|
ID int64 `json:"id"`
|
|
BrandID int64 `json:"brand_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateCompetitor(ctx context.Context, arg UpdateCompetitorParams) error {
|
|
_, err := q.db.Exec(ctx, updateCompetitor,
|
|
arg.Name,
|
|
arg.Website,
|
|
arg.Description,
|
|
arg.ProductLinesJson,
|
|
arg.ID,
|
|
arg.BrandID,
|
|
arg.TenantID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateKeyword = `-- name: UpdateKeyword :exec
|
|
UPDATE brand_keywords SET name = $1, updated_at = NOW()
|
|
WHERE id = $2 AND brand_id = $3 AND tenant_id = $4 AND deleted_at IS NULL
|
|
`
|
|
|
|
type UpdateKeywordParams struct {
|
|
Name string `json:"name"`
|
|
ID int64 `json:"id"`
|
|
BrandID int64 `json:"brand_id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateKeyword(ctx context.Context, arg UpdateKeywordParams) error {
|
|
_, err := q.db.Exec(ctx, updateKeyword,
|
|
arg.Name,
|
|
arg.ID,
|
|
arg.BrandID,
|
|
arg.TenantID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateQuestionCurrentVersion = `-- name: UpdateQuestionCurrentVersion :exec
|
|
UPDATE brand_questions SET current_version_id = $1, updated_at = NOW()
|
|
WHERE id = $2 AND tenant_id = $3
|
|
`
|
|
|
|
type UpdateQuestionCurrentVersionParams struct {
|
|
VersionID pgtype.Int8 `json:"version_id"`
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateQuestionCurrentVersion(ctx context.Context, arg UpdateQuestionCurrentVersionParams) error {
|
|
_, err := q.db.Exec(ctx, updateQuestionCurrentVersion, arg.VersionID, arg.ID, arg.TenantID)
|
|
return err
|
|
}
|