All checks were successful
continuous-integration/drone/push Build is passing
297 lines
7.2 KiB
Go
297 lines
7.2 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 (
|
|
"description", "short_description", "urgency", "impact", "state", "external_id", "assignment_group", "assigned_to", "category", "subcategory", "created_at", "sys_id"
|
|
) VALUES(
|
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
)
|
|
RETURNING id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, subcategory, sys_id
|
|
`
|
|
|
|
type CreateIncidentParams struct {
|
|
Description sql.NullString
|
|
ShortDescription sql.NullString
|
|
Urgency sql.NullInt64
|
|
Impact sql.NullInt64
|
|
State sql.NullInt64
|
|
ExternalID string
|
|
AssignmentGroup sql.NullString
|
|
AssignedTo sql.NullString
|
|
Category sql.NullString
|
|
Subcategory sql.NullString
|
|
CreatedAt sql.NullTime
|
|
SysID sql.NullString
|
|
}
|
|
|
|
func (q *Queries) CreateIncident(ctx context.Context, arg CreateIncidentParams) (Incident, error) {
|
|
row := q.db.QueryRowContext(ctx, createIncident,
|
|
arg.Description,
|
|
arg.ShortDescription,
|
|
arg.Urgency,
|
|
arg.Impact,
|
|
arg.State,
|
|
arg.ExternalID,
|
|
arg.AssignmentGroup,
|
|
arg.AssignedTo,
|
|
arg.Category,
|
|
arg.Subcategory,
|
|
arg.CreatedAt,
|
|
arg.SysID,
|
|
)
|
|
var i Incident
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ExternalID,
|
|
&i.CreatedAt,
|
|
&i.IncidentNumber,
|
|
&i.Description,
|
|
&i.ShortDescription,
|
|
&i.Urgency,
|
|
&i.Impact,
|
|
&i.State,
|
|
&i.AssignmentGroup,
|
|
&i.AssignedTo,
|
|
&i.Category,
|
|
&i.Subcategory,
|
|
&i.SysID,
|
|
)
|
|
return i, 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 createWorkNote = `-- name: CreateWorkNote :one
|
|
INSERT into worknotes (
|
|
"incident_number", "note"
|
|
) VALUES(
|
|
?, ?
|
|
)
|
|
RETURNING id, incident_number, note
|
|
`
|
|
|
|
type CreateWorkNoteParams struct {
|
|
IncidentNumber string
|
|
Note sql.NullString
|
|
}
|
|
|
|
func (q *Queries) CreateWorkNote(ctx context.Context, arg CreateWorkNoteParams) (Worknote, error) {
|
|
row := q.db.QueryRowContext(ctx, createWorkNote, arg.IncidentNumber, arg.Note)
|
|
var i Worknote
|
|
err := row.Scan(&i.ID, &i.IncidentNumber, &i.Note)
|
|
return i, err
|
|
}
|
|
|
|
const getIncident = `-- name: GetIncident :one
|
|
SELECT id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, subcategory, sys_id from incidents
|
|
WHERE incident_number = ?1
|
|
`
|
|
|
|
func (q *Queries) GetIncident(ctx context.Context, incidentnumber sql.NullString) (Incident, error) {
|
|
row := q.db.QueryRowContext(ctx, getIncident, incidentnumber)
|
|
var i Incident
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ExternalID,
|
|
&i.CreatedAt,
|
|
&i.IncidentNumber,
|
|
&i.Description,
|
|
&i.ShortDescription,
|
|
&i.Urgency,
|
|
&i.Impact,
|
|
&i.State,
|
|
&i.AssignmentGroup,
|
|
&i.AssignedTo,
|
|
&i.Category,
|
|
&i.Subcategory,
|
|
&i.SysID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listIncidents = `-- name: ListIncidents :many
|
|
SELECT id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, subcategory, sys_id FROM incidents
|
|
`
|
|
|
|
func (q *Queries) ListIncidents(ctx context.Context) ([]Incident, error) {
|
|
rows, err := q.db.QueryContext(ctx, listIncidents)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Incident
|
|
for rows.Next() {
|
|
var i Incident
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ExternalID,
|
|
&i.CreatedAt,
|
|
&i.IncidentNumber,
|
|
&i.Description,
|
|
&i.ShortDescription,
|
|
&i.Urgency,
|
|
&i.Impact,
|
|
&i.State,
|
|
&i.AssignmentGroup,
|
|
&i.AssignedTo,
|
|
&i.Category,
|
|
&i.Subcategory,
|
|
&i.SysID,
|
|
); 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 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
|
|
}
|
|
|
|
const updateIncidentNumber = `-- name: UpdateIncidentNumber :exec
|
|
UPDATE incidents
|
|
SET incident_number = ?1
|
|
WHERE external_id = ?2
|
|
`
|
|
|
|
type UpdateIncidentNumberParams struct {
|
|
IncidentNumber sql.NullString
|
|
ExternalId string
|
|
}
|
|
|
|
func (q *Queries) UpdateIncidentNumber(ctx context.Context, arg UpdateIncidentNumberParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateIncidentNumber, arg.IncidentNumber, arg.ExternalId)
|
|
return err
|
|
}
|
|
|
|
const updateIncidentState = `-- name: UpdateIncidentState :exec
|
|
UPDATE incidents
|
|
SET state = ?1
|
|
WHERE incident_number = ?2
|
|
`
|
|
|
|
type UpdateIncidentStateParams struct {
|
|
State sql.NullInt64
|
|
IncidentNumber sql.NullString
|
|
}
|
|
|
|
func (q *Queries) UpdateIncidentState(ctx context.Context, arg UpdateIncidentStateParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateIncidentState, arg.State, arg.IncidentNumber)
|
|
return err
|
|
}
|