- Backend: Migrations para tabelas 'escalas' e 'logistica' (transporte) - Backend: Handlers e Services completos para gestão de escalas e logística - Backend: Suporte a auth vinculado a perfil profissional - Frontend: Nova página de Detalhes Operacionais (/agenda/:id) - Frontend: Componente EventScheduler com verificação robusta de conflitos - Frontend: Componente EventLogistics para gestão de motoristas e caronas - Frontend: Modal de Detalhes de Profissional unificado (Admin + Self-view) - Frontend: Dashboard com modal de gestão de equipe e filtros avançados - Fix: Correção crítica de timezone (UTC) em horários de agendamento - Fix: Tratamento de URLs no campo de local do evento - Fix: Filtros de profissional com carro na logística
237 lines
6.6 KiB
Go
237 lines
6.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: logistica.sql
|
|
|
|
package generated
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const addPassageiro = `-- name: AddPassageiro :one
|
|
INSERT INTO logistica_passageiros (carro_id, profissional_id)
|
|
VALUES ($1, $2)
|
|
RETURNING id, carro_id, profissional_id, criado_em
|
|
`
|
|
|
|
type AddPassageiroParams struct {
|
|
CarroID pgtype.UUID `json:"carro_id"`
|
|
ProfissionalID pgtype.UUID `json:"profissional_id"`
|
|
}
|
|
|
|
func (q *Queries) AddPassageiro(ctx context.Context, arg AddPassageiroParams) (LogisticaPassageiro, error) {
|
|
row := q.db.QueryRow(ctx, addPassageiro, arg.CarroID, arg.ProfissionalID)
|
|
var i LogisticaPassageiro
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CarroID,
|
|
&i.ProfissionalID,
|
|
&i.CriadoEm,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createCarro = `-- name: CreateCarro :one
|
|
INSERT INTO logistica_carros (
|
|
agenda_id, motorista_id, nome_motorista, horario_chegada, observacoes
|
|
) VALUES (
|
|
$1, $2, $3, $4, $5
|
|
)
|
|
RETURNING id, agenda_id, motorista_id, nome_motorista, horario_chegada, observacoes, criado_em, atualizado_em
|
|
`
|
|
|
|
type CreateCarroParams struct {
|
|
AgendaID pgtype.UUID `json:"agenda_id"`
|
|
MotoristaID pgtype.UUID `json:"motorista_id"`
|
|
NomeMotorista pgtype.Text `json:"nome_motorista"`
|
|
HorarioChegada pgtype.Text `json:"horario_chegada"`
|
|
Observacoes pgtype.Text `json:"observacoes"`
|
|
}
|
|
|
|
func (q *Queries) CreateCarro(ctx context.Context, arg CreateCarroParams) (LogisticaCarro, error) {
|
|
row := q.db.QueryRow(ctx, createCarro,
|
|
arg.AgendaID,
|
|
arg.MotoristaID,
|
|
arg.NomeMotorista,
|
|
arg.HorarioChegada,
|
|
arg.Observacoes,
|
|
)
|
|
var i LogisticaCarro
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AgendaID,
|
|
&i.MotoristaID,
|
|
&i.NomeMotorista,
|
|
&i.HorarioChegada,
|
|
&i.Observacoes,
|
|
&i.CriadoEm,
|
|
&i.AtualizadoEm,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteCarro = `-- name: DeleteCarro :exec
|
|
DELETE FROM logistica_carros WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteCarro(ctx context.Context, id pgtype.UUID) error {
|
|
_, err := q.db.Exec(ctx, deleteCarro, id)
|
|
return err
|
|
}
|
|
|
|
const listCarrosByAgendaID = `-- name: ListCarrosByAgendaID :many
|
|
SELECT c.id, c.agenda_id, c.motorista_id, c.nome_motorista, c.horario_chegada, c.observacoes, c.criado_em, c.atualizado_em, p.nome as motorista_nome_sistema, p.avatar_url as motorista_avatar
|
|
FROM logistica_carros c
|
|
LEFT JOIN cadastro_profissionais p ON c.motorista_id = p.id
|
|
WHERE c.agenda_id = $1
|
|
ORDER BY c.criado_em
|
|
`
|
|
|
|
type ListCarrosByAgendaIDRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
AgendaID pgtype.UUID `json:"agenda_id"`
|
|
MotoristaID pgtype.UUID `json:"motorista_id"`
|
|
NomeMotorista pgtype.Text `json:"nome_motorista"`
|
|
HorarioChegada pgtype.Text `json:"horario_chegada"`
|
|
Observacoes pgtype.Text `json:"observacoes"`
|
|
CriadoEm pgtype.Timestamptz `json:"criado_em"`
|
|
AtualizadoEm pgtype.Timestamptz `json:"atualizado_em"`
|
|
MotoristaNomeSistema pgtype.Text `json:"motorista_nome_sistema"`
|
|
MotoristaAvatar pgtype.Text `json:"motorista_avatar"`
|
|
}
|
|
|
|
func (q *Queries) ListCarrosByAgendaID(ctx context.Context, agendaID pgtype.UUID) ([]ListCarrosByAgendaIDRow, error) {
|
|
rows, err := q.db.Query(ctx, listCarrosByAgendaID, agendaID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListCarrosByAgendaIDRow
|
|
for rows.Next() {
|
|
var i ListCarrosByAgendaIDRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.AgendaID,
|
|
&i.MotoristaID,
|
|
&i.NomeMotorista,
|
|
&i.HorarioChegada,
|
|
&i.Observacoes,
|
|
&i.CriadoEm,
|
|
&i.AtualizadoEm,
|
|
&i.MotoristaNomeSistema,
|
|
&i.MotoristaAvatar,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listPassageirosByCarroID = `-- name: ListPassageirosByCarroID :many
|
|
SELECT lp.id, lp.carro_id, lp.profissional_id, lp.criado_em, p.nome, p.avatar_url, f.nome as funcao_nome
|
|
FROM logistica_passageiros lp
|
|
JOIN cadastro_profissionais p ON lp.profissional_id = p.id
|
|
LEFT JOIN funcoes_profissionais f ON p.funcao_profissional_id = f.id
|
|
WHERE lp.carro_id = $1
|
|
`
|
|
|
|
type ListPassageirosByCarroIDRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
CarroID pgtype.UUID `json:"carro_id"`
|
|
ProfissionalID pgtype.UUID `json:"profissional_id"`
|
|
CriadoEm pgtype.Timestamptz `json:"criado_em"`
|
|
Nome string `json:"nome"`
|
|
AvatarUrl pgtype.Text `json:"avatar_url"`
|
|
FuncaoNome pgtype.Text `json:"funcao_nome"`
|
|
}
|
|
|
|
func (q *Queries) ListPassageirosByCarroID(ctx context.Context, carroID pgtype.UUID) ([]ListPassageirosByCarroIDRow, error) {
|
|
rows, err := q.db.Query(ctx, listPassageirosByCarroID, carroID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListPassageirosByCarroIDRow
|
|
for rows.Next() {
|
|
var i ListPassageirosByCarroIDRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CarroID,
|
|
&i.ProfissionalID,
|
|
&i.CriadoEm,
|
|
&i.Nome,
|
|
&i.AvatarUrl,
|
|
&i.FuncaoNome,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const removePassageiro = `-- name: RemovePassageiro :exec
|
|
DELETE FROM logistica_passageiros
|
|
WHERE carro_id = $1 AND profissional_id = $2
|
|
`
|
|
|
|
type RemovePassageiroParams struct {
|
|
CarroID pgtype.UUID `json:"carro_id"`
|
|
ProfissionalID pgtype.UUID `json:"profissional_id"`
|
|
}
|
|
|
|
func (q *Queries) RemovePassageiro(ctx context.Context, arg RemovePassageiroParams) error {
|
|
_, err := q.db.Exec(ctx, removePassageiro, arg.CarroID, arg.ProfissionalID)
|
|
return err
|
|
}
|
|
|
|
const updateCarro = `-- name: UpdateCarro :one
|
|
UPDATE logistica_carros
|
|
SET motorista_id = COALESCE($2, motorista_id),
|
|
nome_motorista = COALESCE($3, nome_motorista),
|
|
horario_chegada = COALESCE($4, horario_chegada),
|
|
observacoes = COALESCE($5, observacoes),
|
|
atualizado_em = NOW()
|
|
WHERE id = $1
|
|
RETURNING id, agenda_id, motorista_id, nome_motorista, horario_chegada, observacoes, criado_em, atualizado_em
|
|
`
|
|
|
|
type UpdateCarroParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
MotoristaID pgtype.UUID `json:"motorista_id"`
|
|
NomeMotorista pgtype.Text `json:"nome_motorista"`
|
|
HorarioChegada pgtype.Text `json:"horario_chegada"`
|
|
Observacoes pgtype.Text `json:"observacoes"`
|
|
}
|
|
|
|
func (q *Queries) UpdateCarro(ctx context.Context, arg UpdateCarroParams) (LogisticaCarro, error) {
|
|
row := q.db.QueryRow(ctx, updateCarro,
|
|
arg.ID,
|
|
arg.MotoristaID,
|
|
arg.NomeMotorista,
|
|
arg.HorarioChegada,
|
|
arg.Observacoes,
|
|
)
|
|
var i LogisticaCarro
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AgendaID,
|
|
&i.MotoristaID,
|
|
&i.NomeMotorista,
|
|
&i.HorarioChegada,
|
|
&i.Observacoes,
|
|
&i.CriadoEm,
|
|
&i.AtualizadoEm,
|
|
)
|
|
return i, err
|
|
}
|