129 lines
3.0 KiB
Go
129 lines
3.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
// source: query.sql
|
|
|
|
package queries
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const createIncident = `-- name: CreateIncident :one
|
|
INSERT INTO incidents (external_id)
|
|
VALUES (?)
|
|
RETURNING id
|
|
`
|
|
|
|
func (q *Queries) CreateIncident(ctx context.Context, externalID string) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, createIncident, externalID)
|
|
var id int64
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const createIncoming = `-- name: CreateIncoming :one
|
|
INSERT INTO "Incoming" (
|
|
"incident_number", "description", "short_description", "urgency", "impact", "state", "external_id", "work_notes", "assignment_group", "assigned_to", "category", "subcategory", "created_at"
|
|
) VALUES(
|
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
)
|
|
RETURNING id, incident_number, description, short_description, urgency, impact, state, external_id, work_notes, assignment_group, assigned_to, category, subcategory, created_at
|
|
`
|
|
|
|
type CreateIncomingParams struct {
|
|
IncidentNumber sql.NullString
|
|
Description sql.NullString
|
|
ShortDescription sql.NullString
|
|
Urgency sql.NullString
|
|
Impact sql.NullString
|
|
State sql.NullString
|
|
ExternalID sql.NullString
|
|
WorkNotes sql.NullString
|
|
AssignmentGroup sql.NullString
|
|
AssignedTo sql.NullString
|
|
Category sql.NullString
|
|
Subcategory sql.NullString
|
|
CreatedAt sql.NullTime
|
|
}
|
|
|
|
func (q *Queries) CreateIncoming(ctx context.Context, arg CreateIncomingParams) (Incoming, error) {
|
|
row := q.db.QueryRowContext(ctx, createIncoming,
|
|
arg.IncidentNumber,
|
|
arg.Description,
|
|
arg.ShortDescription,
|
|
arg.Urgency,
|
|
arg.Impact,
|
|
arg.State,
|
|
arg.ExternalID,
|
|
arg.WorkNotes,
|
|
arg.AssignmentGroup,
|
|
arg.AssignedTo,
|
|
arg.Category,
|
|
arg.Subcategory,
|
|
arg.CreatedAt,
|
|
)
|
|
var i Incoming
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.IncidentNumber,
|
|
&i.Description,
|
|
&i.ShortDescription,
|
|
&i.Urgency,
|
|
&i.Impact,
|
|
&i.State,
|
|
&i.ExternalID,
|
|
&i.WorkNotes,
|
|
&i.AssignmentGroup,
|
|
&i.AssignedTo,
|
|
&i.Category,
|
|
&i.Subcategory,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listIncoming = `-- name: ListIncoming :many
|
|
SELECT id, incident_number, description, short_description, urgency, impact, state, external_id, work_notes, assignment_group, assigned_to, category, subcategory, created_at FROM "Incoming"
|
|
ORDER BY "id"
|
|
`
|
|
|
|
func (q *Queries) ListIncoming(ctx context.Context) ([]Incoming, error) {
|
|
rows, err := q.db.QueryContext(ctx, listIncoming)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Incoming
|
|
for rows.Next() {
|
|
var i Incoming
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.IncidentNumber,
|
|
&i.Description,
|
|
&i.ShortDescription,
|
|
&i.Urgency,
|
|
&i.Impact,
|
|
&i.State,
|
|
&i.ExternalID,
|
|
&i.WorkNotes,
|
|
&i.AssignmentGroup,
|
|
&i.AssignedTo,
|
|
&i.Category,
|
|
&i.Subcategory,
|
|
&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
|
|
}
|