sqlc gen
This commit is contained in:
parent
8161c7fddb
commit
3db6e9ead6
@ -81,6 +81,15 @@ type Field struct {
|
|||||||
Createdat sql.NullTime `db:"createdat" json:"createdat"`
|
Createdat sql.NullTime `db:"createdat" json:"createdat"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Gigachataudience struct {
|
||||||
|
ID int64 `db:"id" json:"id"`
|
||||||
|
Quizid int64 `db:"quizid" json:"quizid"`
|
||||||
|
Sex bool `db:"sex" json:"sex"`
|
||||||
|
Age string `db:"age" json:"age"`
|
||||||
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
|
Createdat sql.NullTime `db:"createdat" json:"createdat"`
|
||||||
|
}
|
||||||
|
|
||||||
type Pipeline struct {
|
type Pipeline struct {
|
||||||
ID int64 `db:"id" json:"id"`
|
ID int64 `db:"id" json:"id"`
|
||||||
Amoid int32 `db:"amoid" json:"amoid"`
|
Amoid int32 `db:"amoid" json:"amoid"`
|
||||||
|
@ -716,6 +716,23 @@ func (q *Queries) CreateAmoAccount(ctx context.Context, arg CreateAmoAccountPara
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const createQuizAudience = `-- name: CreateQuizAudience :one
|
||||||
|
INSERT INTO gigachatAudience (QuizID, Sex, Age) VALUES ($1, $2, $3) RETURNING ID
|
||||||
|
`
|
||||||
|
|
||||||
|
type CreateQuizAudienceParams struct {
|
||||||
|
Quizid int64 `db:"quizid" json:"quizid"`
|
||||||
|
Sex bool `db:"sex" json:"sex"`
|
||||||
|
Age string `db:"age" json:"age"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) CreateQuizAudience(ctx context.Context, arg CreateQuizAudienceParams) (int64, error) {
|
||||||
|
row := q.db.QueryRowContext(ctx, createQuizAudience, arg.Quizid, arg.Sex, arg.Age)
|
||||||
|
var id int64
|
||||||
|
err := row.Scan(&id)
|
||||||
|
return id, err
|
||||||
|
}
|
||||||
|
|
||||||
const createWebHook = `-- name: CreateWebHook :exec
|
const createWebHook = `-- name: CreateWebHook :exec
|
||||||
INSERT INTO tokens (AccountID, RefreshToken, AccessToken, AuthCode, Expiration, CreatedAt)
|
INSERT INTO tokens (AccountID, RefreshToken, AccessToken, AuthCode, Expiration, CreatedAt)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6)
|
VALUES ($1, $2, $3, $4, $5, $6)
|
||||||
@ -838,6 +855,15 @@ func (q *Queries) DeleteQuestion(ctx context.Context, id int64) (Question, error
|
|||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const deleteQuizAudience = `-- name: DeleteQuizAudience :exec
|
||||||
|
UPDATE gigachatAudience set Deleted = TRUE WHERE QuizID = $1
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) DeleteQuizAudience(ctx context.Context, quizid int64) error {
|
||||||
|
_, err := q.db.ExecContext(ctx, deleteQuizAudience, quizid)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
const deleteQuizByID = `-- name: DeleteQuizByID :one
|
const deleteQuizByID = `-- name: DeleteQuizByID :one
|
||||||
UPDATE quiz SET deleted=true WHERE quiz.id=$1 AND accountid=$2 RETURNING quiz.id, quiz.qid, quiz.accountid, quiz.deleted, quiz.archived, quiz.fingerprinting, quiz.repeatable, quiz.note_prevented, quiz.mail_notifications, quiz.unique_answers, quiz.super, quiz.group_id, quiz.name, quiz.description, quiz.config, quiz.status, quiz.limit_answers, quiz.due_to, quiz.time_of_passing, quiz.pausable, quiz.version, quiz.version_comment, quiz.parent_ids, quiz.created_at, quiz.updated_at, quiz.questions_count, quiz.answers_count, quiz.average_time_passing, quiz.sessions_count
|
UPDATE quiz SET deleted=true WHERE quiz.id=$1 AND accountid=$2 RETURNING quiz.id, quiz.qid, quiz.accountid, quiz.deleted, quiz.archived, quiz.fingerprinting, quiz.repeatable, quiz.note_prevented, quiz.mail_notifications, quiz.unique_answers, quiz.super, quiz.group_id, quiz.name, quiz.description, quiz.config, quiz.status, quiz.limit_answers, quiz.due_to, quiz.time_of_passing, quiz.pausable, quiz.version, quiz.version_comment, quiz.parent_ids, quiz.created_at, quiz.updated_at, quiz.questions_count, quiz.answers_count, quiz.average_time_passing, quiz.sessions_count
|
||||||
`
|
`
|
||||||
@ -2177,6 +2203,40 @@ func (q *Queries) GetQuestionsAICount(ctx context.Context, arg GetQuestionsAICou
|
|||||||
return count, err
|
return count, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getQuizAudience = `-- name: GetQuizAudience :many
|
||||||
|
SELECT id, quizid, sex, age, deleted, createdat FROM gigachatAudience WHERE QuizID = $1 AND Deleted = FALSE
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetQuizAudience(ctx context.Context, quizid int64) ([]Gigachataudience, error) {
|
||||||
|
rows, err := q.db.QueryContext(ctx, getQuizAudience, quizid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []Gigachataudience
|
||||||
|
for rows.Next() {
|
||||||
|
var i Gigachataudience
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.Quizid,
|
||||||
|
&i.Sex,
|
||||||
|
&i.Age,
|
||||||
|
&i.Deleted,
|
||||||
|
&i.Createdat,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Close(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
const getQuizById = `-- name: GetQuizById :one
|
const getQuizById = `-- name: GetQuizById :one
|
||||||
SELECT id, qid, accountid, deleted, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, super, group_id, name, description, config, status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, created_at, updated_at, questions_count, answers_count, average_time_passing, sessions_count FROM quiz WHERE id=$1 AND accountId=$2
|
SELECT id, qid, accountid, deleted, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, super, group_id, name, description, config, status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, created_at, updated_at, questions_count, answers_count, average_time_passing, sessions_count FROM quiz WHERE id=$1 AND accountId=$2
|
||||||
`
|
`
|
||||||
|
Loading…
Reference in New Issue
Block a user