sqlc gen
This commit is contained in:
parent
802ffdfd07
commit
0d79399015
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
// sqlc v1.28.0
|
||||
|
||||
package sqlcgen
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
// sqlc v1.28.0
|
||||
|
||||
package sqlcgen
|
||||
|
||||
@ -114,6 +114,7 @@ type Question struct {
|
||||
ParentIds []int32 `db:"parent_ids" json:"parent_ids"`
|
||||
CreatedAt sql.NullTime `db:"created_at" json:"created_at"`
|
||||
UpdatedAt sql.NullTime `db:"updated_at" json:"updated_at"`
|
||||
Session string `db:"session" json:"session"`
|
||||
}
|
||||
|
||||
type Quiz struct {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
// sqlc v1.28.0
|
||||
// source: queries.sql
|
||||
|
||||
package sqlcgen
|
||||
@ -813,7 +813,7 @@ func (q *Queries) DeletePrivilegeByID(ctx context.Context, id int32) error {
|
||||
}
|
||||
|
||||
const deleteQuestion = `-- name: DeleteQuestion :one
|
||||
UPDATE question SET deleted=true WHERE id=$1 RETURNING question.id, question.quiz_id, question.title, question.description, question.questiontype, question.required, question.deleted, question.page, question.content, question.version, question.parent_ids, question.created_at, question.updated_at
|
||||
UPDATE question SET deleted=true WHERE id=$1 RETURNING question.id, question.quiz_id, question.title, question.description, question.questiontype, question.required, question.deleted, question.page, question.content, question.version, question.parent_ids, question.created_at, question.updated_at, question.session
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteQuestion(ctx context.Context, id int64) (Question, error) {
|
||||
@ -833,6 +833,7 @@ func (q *Queries) DeleteQuestion(ctx context.Context, id int64) (Question, error
|
||||
pq.Array(&i.ParentIds),
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Session,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@ -1934,7 +1935,7 @@ func (q *Queries) GetQidOwner(ctx context.Context, qid uuid.NullUUID) (string, e
|
||||
}
|
||||
|
||||
const getQuestionHistory = `-- name: GetQuestionHistory :many
|
||||
SELECT id, quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at FROM question WHERE question.id = $1 OR question.id = ANY(
|
||||
SELECT id, quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at, session FROM question WHERE question.id = $1 OR question.id = ANY(
|
||||
SELECT unnest(parent_ids) FROM question WHERE id = $1
|
||||
) ORDER BY question.id DESC LIMIT $2 OFFSET $3
|
||||
`
|
||||
@ -1968,6 +1969,7 @@ func (q *Queries) GetQuestionHistory(ctx context.Context, arg GetQuestionHistory
|
||||
pq.Array(&i.ParentIds),
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Session,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1983,7 +1985,7 @@ func (q *Queries) GetQuestionHistory(ctx context.Context, arg GetQuestionHistory
|
||||
}
|
||||
|
||||
const getQuestionListByIDs = `-- name: GetQuestionListByIDs :many
|
||||
SELECT id, quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at FROM question WHERE id = ANY($1::int[]) AND deleted = FALSE
|
||||
SELECT id, quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at, session FROM question WHERE id = ANY($1::int[]) AND deleted = FALSE
|
||||
`
|
||||
|
||||
func (q *Queries) GetQuestionListByIDs(ctx context.Context, dollar_1 []int32) ([]Question, error) {
|
||||
@ -2009,6 +2011,7 @@ func (q *Queries) GetQuestionListByIDs(ctx context.Context, dollar_1 []int32) ([
|
||||
pq.Array(&i.ParentIds),
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Session,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -2044,15 +2047,31 @@ const getQuestions = `-- name: GetQuestions :many
|
||||
SELECT id, quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at FROM question WHERE quiz_id = $1 AND deleted = FALSE ORDER BY page ASC
|
||||
`
|
||||
|
||||
func (q *Queries) GetQuestions(ctx context.Context, quizID int64) ([]Question, error) {
|
||||
type GetQuestionsRow struct {
|
||||
ID int64 `db:"id" json:"id"`
|
||||
QuizID int64 `db:"quiz_id" json:"quiz_id"`
|
||||
Title string `db:"title" json:"title"`
|
||||
Description sql.NullString `db:"description" json:"description"`
|
||||
Questiontype interface{} `db:"questiontype" json:"questiontype"`
|
||||
Required sql.NullBool `db:"required" json:"required"`
|
||||
Deleted sql.NullBool `db:"deleted" json:"deleted"`
|
||||
Page sql.NullInt16 `db:"page" json:"page"`
|
||||
Content sql.NullString `db:"content" json:"content"`
|
||||
Version sql.NullInt16 `db:"version" json:"version"`
|
||||
ParentIds []int32 `db:"parent_ids" json:"parent_ids"`
|
||||
CreatedAt sql.NullTime `db:"created_at" json:"created_at"`
|
||||
UpdatedAt sql.NullTime `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetQuestions(ctx context.Context, quizID int64) ([]GetQuestionsRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getQuestions, quizID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Question
|
||||
var items []GetQuestionsRow
|
||||
for rows.Next() {
|
||||
var i Question
|
||||
var i GetQuestionsRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.QuizID,
|
||||
@ -2081,6 +2100,84 @@ func (q *Queries) GetQuestions(ctx context.Context, quizID int64) ([]Question, e
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getQuestionsAI = `-- name: GetQuestionsAI :many
|
||||
WITH total_count AS (SELECT COUNT(*) AS count
|
||||
FROM question WHERE quiz_id = $1 AND (session = $2 OR session = '') AND deleted = FALSE)
|
||||
SELECT q.id, q.quiz_id, q.title, q.description, q.questiontype, q.required, q.deleted, q.page, q.content, q.version, q.parent_ids, q.created_at, q.updated_at, q.session, t.count FROM question q
|
||||
CROSS JOIN total_count t
|
||||
WHERE q.quiz_id = $1 AND (q.session = $2 OR q.session = '') AND q.deleted = FALSE
|
||||
ORDER BY q.page, q.created_at ASC LIMIT $3 OFFSET $4
|
||||
`
|
||||
|
||||
type GetQuestionsAIParams struct {
|
||||
QuizID int64 `db:"quiz_id" json:"quiz_id"`
|
||||
Session string `db:"session" json:"session"`
|
||||
Limit int32 `db:"limit" json:"limit"`
|
||||
Offset int32 `db:"offset" json:"offset"`
|
||||
}
|
||||
|
||||
type GetQuestionsAIRow struct {
|
||||
ID int64 `db:"id" json:"id"`
|
||||
QuizID int64 `db:"quiz_id" json:"quiz_id"`
|
||||
Title string `db:"title" json:"title"`
|
||||
Description sql.NullString `db:"description" json:"description"`
|
||||
Questiontype interface{} `db:"questiontype" json:"questiontype"`
|
||||
Required sql.NullBool `db:"required" json:"required"`
|
||||
Deleted sql.NullBool `db:"deleted" json:"deleted"`
|
||||
Page sql.NullInt16 `db:"page" json:"page"`
|
||||
Content sql.NullString `db:"content" json:"content"`
|
||||
Version sql.NullInt16 `db:"version" json:"version"`
|
||||
ParentIds []int32 `db:"parent_ids" json:"parent_ids"`
|
||||
CreatedAt sql.NullTime `db:"created_at" json:"created_at"`
|
||||
UpdatedAt sql.NullTime `db:"updated_at" json:"updated_at"`
|
||||
Session string `db:"session" json:"session"`
|
||||
Count int64 `db:"count" json:"count"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetQuestionsAI(ctx context.Context, arg GetQuestionsAIParams) ([]GetQuestionsAIRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getQuestionsAI,
|
||||
arg.QuizID,
|
||||
arg.Session,
|
||||
arg.Limit,
|
||||
arg.Offset,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetQuestionsAIRow
|
||||
for rows.Next() {
|
||||
var i GetQuestionsAIRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.QuizID,
|
||||
&i.Title,
|
||||
&i.Description,
|
||||
&i.Questiontype,
|
||||
&i.Required,
|
||||
&i.Deleted,
|
||||
&i.Page,
|
||||
&i.Content,
|
||||
&i.Version,
|
||||
pq.Array(&i.ParentIds),
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Session,
|
||||
&i.Count,
|
||||
); 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
|
||||
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
|
||||
`
|
||||
@ -2988,9 +3085,10 @@ INSERT INTO question (
|
||||
page,
|
||||
content,
|
||||
parent_ids,
|
||||
updated_at
|
||||
updated_at,
|
||||
session
|
||||
)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)
|
||||
RETURNING id, created_at, updated_at
|
||||
`
|
||||
|
||||
@ -3004,6 +3102,7 @@ type InsertQuestionParams struct {
|
||||
Content sql.NullString `db:"content" json:"content"`
|
||||
ParentIds []int32 `db:"parent_ids" json:"parent_ids"`
|
||||
UpdatedAt sql.NullTime `db:"updated_at" json:"updated_at"`
|
||||
Session string `db:"session" json:"session"`
|
||||
}
|
||||
|
||||
type InsertQuestionRow struct {
|
||||
@ -3023,6 +3122,7 @@ func (q *Queries) InsertQuestion(ctx context.Context, arg InsertQuestionParams)
|
||||
arg.Content,
|
||||
pq.Array(arg.ParentIds),
|
||||
arg.UpdatedAt,
|
||||
arg.Session,
|
||||
)
|
||||
var i InsertQuestionRow
|
||||
err := row.Scan(&i.ID, &i.CreatedAt, &i.UpdatedAt)
|
||||
|
Loading…
Reference in New Issue
Block a user