- Implementado CRUDs para: cursos, empresas, anos_formaturas, tipos_servicos, tipos_eventos - Implementado lógica de precificação de eventos (precos_tipos_eventos) - Refatorado a autenticação: Simplificar o payload de cadastro/login (somente e-mail/senha), função padrão 'profissional' - Corrigido o middleware de autenticação: Resolvido a incompatibilidade de tipo UUID vs String (corrigir erro 500) - Aprimorado o Swagger: Adicionado structs nomeados, validação de duplicatas (409 Conflict) e segurança BearerAuth - Atualizar o esquema do banco de dados: Adicionar tabelas e restrições
83 lines
2.3 KiB
Go
83 lines
2.3 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: anos_formaturas.sql
|
|
|
|
package generated
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createAnoFormatura = `-- name: CreateAnoFormatura :one
|
|
INSERT INTO anos_formaturas (ano_semestre) VALUES ($1) RETURNING id, ano_semestre, criado_em
|
|
`
|
|
|
|
func (q *Queries) CreateAnoFormatura(ctx context.Context, anoSemestre string) (AnosFormatura, error) {
|
|
row := q.db.QueryRow(ctx, createAnoFormatura, anoSemestre)
|
|
var i AnosFormatura
|
|
err := row.Scan(&i.ID, &i.AnoSemestre, &i.CriadoEm)
|
|
return i, err
|
|
}
|
|
|
|
const deleteAnoFormatura = `-- name: DeleteAnoFormatura :exec
|
|
DELETE FROM anos_formaturas WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteAnoFormatura(ctx context.Context, id pgtype.UUID) error {
|
|
_, err := q.db.Exec(ctx, deleteAnoFormatura, id)
|
|
return err
|
|
}
|
|
|
|
const getAnoFormaturaByID = `-- name: GetAnoFormaturaByID :one
|
|
SELECT id, ano_semestre, criado_em FROM anos_formaturas WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetAnoFormaturaByID(ctx context.Context, id pgtype.UUID) (AnosFormatura, error) {
|
|
row := q.db.QueryRow(ctx, getAnoFormaturaByID, id)
|
|
var i AnosFormatura
|
|
err := row.Scan(&i.ID, &i.AnoSemestre, &i.CriadoEm)
|
|
return i, err
|
|
}
|
|
|
|
const listAnosFormaturas = `-- name: ListAnosFormaturas :many
|
|
SELECT id, ano_semestre, criado_em FROM anos_formaturas ORDER BY ano_semestre
|
|
`
|
|
|
|
func (q *Queries) ListAnosFormaturas(ctx context.Context) ([]AnosFormatura, error) {
|
|
rows, err := q.db.Query(ctx, listAnosFormaturas)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []AnosFormatura
|
|
for rows.Next() {
|
|
var i AnosFormatura
|
|
if err := rows.Scan(&i.ID, &i.AnoSemestre, &i.CriadoEm); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateAnoFormatura = `-- name: UpdateAnoFormatura :one
|
|
UPDATE anos_formaturas SET ano_semestre = $2 WHERE id = $1 RETURNING id, ano_semestre, criado_em
|
|
`
|
|
|
|
type UpdateAnoFormaturaParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
AnoSemestre string `json:"ano_semestre"`
|
|
}
|
|
|
|
func (q *Queries) UpdateAnoFormatura(ctx context.Context, arg UpdateAnoFormaturaParams) (AnosFormatura, error) {
|
|
row := q.db.QueryRow(ctx, updateAnoFormatura, arg.ID, arg.AnoSemestre)
|
|
var i AnosFormatura
|
|
err := row.Scan(&i.ID, &i.AnoSemestre, &i.CriadoEm)
|
|
return i, err
|
|
}
|