Backend: - Implementa rota e serviço de importação em lote (`/api/import/fot`). - Adiciona suporte a "Upsert" para atualizar registros existentes sem duplicar. - Corrige e migra schema do banco: ajuste na precisão de valores monetários e correções de sintaxe. Frontend: - Cria página de Importação de Dados com visualização de log e tratamento de erros. - Implementa melhorias de UX nas tabelas (Importação e Gestão de FOT): - Contadores de total de registros. - Funcionalidade "Drag-to-Scroll" (arrastar para rolar). - Barra de rolagem superior sincronizada na tabela de gestão. - Corrige bug de "tela branca" ao filtrar dados vazios na gestão.
514 lines
16 KiB
Go
514 lines
16 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: cadastro_fot.sql
|
|
|
|
package generated
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createCadastroFot = `-- name: CreateCadastroFot :one
|
|
INSERT INTO cadastro_fot (
|
|
fot, empresa_id, curso_id, ano_formatura_id, instituicao, cidade, estado, observacoes, gastos_captacao, pre_venda
|
|
) VALUES (
|
|
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10
|
|
)
|
|
ON CONFLICT (fot) DO UPDATE SET
|
|
empresa_id = EXCLUDED.empresa_id,
|
|
curso_id = EXCLUDED.curso_id,
|
|
ano_formatura_id = EXCLUDED.ano_formatura_id,
|
|
instituicao = EXCLUDED.instituicao,
|
|
cidade = EXCLUDED.cidade,
|
|
estado = EXCLUDED.estado,
|
|
observacoes = EXCLUDED.observacoes,
|
|
gastos_captacao = EXCLUDED.gastos_captacao,
|
|
pre_venda = EXCLUDED.pre_venda,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
RETURNING id, fot, empresa_id, curso_id, ano_formatura_id, instituicao, cidade, estado, observacoes, gastos_captacao, pre_venda, created_at, updated_at
|
|
`
|
|
|
|
type CreateCadastroFotParams struct {
|
|
Fot string `json:"fot"`
|
|
EmpresaID pgtype.UUID `json:"empresa_id"`
|
|
CursoID pgtype.UUID `json:"curso_id"`
|
|
AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"`
|
|
Instituicao pgtype.Text `json:"instituicao"`
|
|
Cidade pgtype.Text `json:"cidade"`
|
|
Estado pgtype.Text `json:"estado"`
|
|
Observacoes pgtype.Text `json:"observacoes"`
|
|
GastosCaptacao pgtype.Numeric `json:"gastos_captacao"`
|
|
PreVenda pgtype.Bool `json:"pre_venda"`
|
|
}
|
|
|
|
func (q *Queries) CreateCadastroFot(ctx context.Context, arg CreateCadastroFotParams) (CadastroFot, error) {
|
|
row := q.db.QueryRow(ctx, createCadastroFot,
|
|
arg.Fot,
|
|
arg.EmpresaID,
|
|
arg.CursoID,
|
|
arg.AnoFormaturaID,
|
|
arg.Instituicao,
|
|
arg.Cidade,
|
|
arg.Estado,
|
|
arg.Observacoes,
|
|
arg.GastosCaptacao,
|
|
arg.PreVenda,
|
|
)
|
|
var i CadastroFot
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Fot,
|
|
&i.EmpresaID,
|
|
&i.CursoID,
|
|
&i.AnoFormaturaID,
|
|
&i.Instituicao,
|
|
&i.Cidade,
|
|
&i.Estado,
|
|
&i.Observacoes,
|
|
&i.GastosCaptacao,
|
|
&i.PreVenda,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteCadastroFot = `-- name: DeleteCadastroFot :exec
|
|
DELETE FROM cadastro_fot WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteCadastroFot(ctx context.Context, id pgtype.UUID) error {
|
|
_, err := q.db.Exec(ctx, deleteCadastroFot, id)
|
|
return err
|
|
}
|
|
|
|
const getCadastroFotByFOT = `-- name: GetCadastroFotByFOT :one
|
|
SELECT id, fot, empresa_id, curso_id, ano_formatura_id, instituicao, cidade, estado, observacoes, gastos_captacao, pre_venda, created_at, updated_at FROM cadastro_fot WHERE fot = $1
|
|
`
|
|
|
|
func (q *Queries) GetCadastroFotByFOT(ctx context.Context, fot string) (CadastroFot, error) {
|
|
row := q.db.QueryRow(ctx, getCadastroFotByFOT, fot)
|
|
var i CadastroFot
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Fot,
|
|
&i.EmpresaID,
|
|
&i.CursoID,
|
|
&i.AnoFormaturaID,
|
|
&i.Instituicao,
|
|
&i.Cidade,
|
|
&i.Estado,
|
|
&i.Observacoes,
|
|
&i.GastosCaptacao,
|
|
&i.PreVenda,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getCadastroFotByFotJoin = `-- name: GetCadastroFotByFotJoin :one
|
|
SELECT
|
|
c.id, c.fot, c.empresa_id, c.curso_id, c.ano_formatura_id, c.instituicao, c.cidade, c.estado, c.observacoes, c.gastos_captacao, c.pre_venda, c.created_at, c.updated_at,
|
|
e.nome as empresa_nome,
|
|
cur.nome as curso_nome,
|
|
a.ano_semestre as ano_formatura_label
|
|
FROM cadastro_fot c
|
|
JOIN empresas e ON c.empresa_id = e.id
|
|
JOIN cursos cur ON c.curso_id = cur.id
|
|
JOIN anos_formaturas a ON c.ano_formatura_id = a.id
|
|
WHERE c.fot = $1
|
|
`
|
|
|
|
type GetCadastroFotByFotJoinRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Fot string `json:"fot"`
|
|
EmpresaID pgtype.UUID `json:"empresa_id"`
|
|
CursoID pgtype.UUID `json:"curso_id"`
|
|
AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"`
|
|
Instituicao pgtype.Text `json:"instituicao"`
|
|
Cidade pgtype.Text `json:"cidade"`
|
|
Estado pgtype.Text `json:"estado"`
|
|
Observacoes pgtype.Text `json:"observacoes"`
|
|
GastosCaptacao pgtype.Numeric `json:"gastos_captacao"`
|
|
PreVenda pgtype.Bool `json:"pre_venda"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
EmpresaNome string `json:"empresa_nome"`
|
|
CursoNome string `json:"curso_nome"`
|
|
AnoFormaturaLabel string `json:"ano_formatura_label"`
|
|
}
|
|
|
|
func (q *Queries) GetCadastroFotByFotJoin(ctx context.Context, fot string) (GetCadastroFotByFotJoinRow, error) {
|
|
row := q.db.QueryRow(ctx, getCadastroFotByFotJoin, fot)
|
|
var i GetCadastroFotByFotJoinRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Fot,
|
|
&i.EmpresaID,
|
|
&i.CursoID,
|
|
&i.AnoFormaturaID,
|
|
&i.Instituicao,
|
|
&i.Cidade,
|
|
&i.Estado,
|
|
&i.Observacoes,
|
|
&i.GastosCaptacao,
|
|
&i.PreVenda,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EmpresaNome,
|
|
&i.CursoNome,
|
|
&i.AnoFormaturaLabel,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getCadastroFotByID = `-- name: GetCadastroFotByID :one
|
|
SELECT
|
|
c.id, c.fot, c.empresa_id, c.curso_id, c.ano_formatura_id, c.instituicao, c.cidade, c.estado, c.observacoes, c.gastos_captacao, c.pre_venda, c.created_at, c.updated_at,
|
|
e.nome as empresa_nome,
|
|
cur.nome as curso_nome,
|
|
a.ano_semestre as ano_formatura_label
|
|
FROM cadastro_fot c
|
|
JOIN empresas e ON c.empresa_id = e.id
|
|
JOIN cursos cur ON c.curso_id = cur.id
|
|
JOIN anos_formaturas a ON c.ano_formatura_id = a.id
|
|
WHERE c.id = $1
|
|
`
|
|
|
|
type GetCadastroFotByIDRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Fot string `json:"fot"`
|
|
EmpresaID pgtype.UUID `json:"empresa_id"`
|
|
CursoID pgtype.UUID `json:"curso_id"`
|
|
AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"`
|
|
Instituicao pgtype.Text `json:"instituicao"`
|
|
Cidade pgtype.Text `json:"cidade"`
|
|
Estado pgtype.Text `json:"estado"`
|
|
Observacoes pgtype.Text `json:"observacoes"`
|
|
GastosCaptacao pgtype.Numeric `json:"gastos_captacao"`
|
|
PreVenda pgtype.Bool `json:"pre_venda"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
EmpresaNome string `json:"empresa_nome"`
|
|
CursoNome string `json:"curso_nome"`
|
|
AnoFormaturaLabel string `json:"ano_formatura_label"`
|
|
}
|
|
|
|
func (q *Queries) GetCadastroFotByID(ctx context.Context, id pgtype.UUID) (GetCadastroFotByIDRow, error) {
|
|
row := q.db.QueryRow(ctx, getCadastroFotByID, id)
|
|
var i GetCadastroFotByIDRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Fot,
|
|
&i.EmpresaID,
|
|
&i.CursoID,
|
|
&i.AnoFormaturaID,
|
|
&i.Instituicao,
|
|
&i.Cidade,
|
|
&i.Estado,
|
|
&i.Observacoes,
|
|
&i.GastosCaptacao,
|
|
&i.PreVenda,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EmpresaNome,
|
|
&i.CursoNome,
|
|
&i.AnoFormaturaLabel,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listCadastroFot = `-- name: ListCadastroFot :many
|
|
SELECT
|
|
c.id, c.fot, c.empresa_id, c.curso_id, c.ano_formatura_id, c.instituicao, c.cidade, c.estado, c.observacoes, c.gastos_captacao, c.pre_venda, c.created_at, c.updated_at,
|
|
e.nome as empresa_nome,
|
|
cur.nome as curso_nome,
|
|
a.ano_semestre as ano_formatura_label
|
|
FROM cadastro_fot c
|
|
JOIN empresas e ON c.empresa_id = e.id
|
|
JOIN cursos cur ON c.curso_id = cur.id
|
|
JOIN anos_formaturas a ON c.ano_formatura_id = a.id
|
|
ORDER BY c.fot DESC
|
|
`
|
|
|
|
type ListCadastroFotRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Fot string `json:"fot"`
|
|
EmpresaID pgtype.UUID `json:"empresa_id"`
|
|
CursoID pgtype.UUID `json:"curso_id"`
|
|
AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"`
|
|
Instituicao pgtype.Text `json:"instituicao"`
|
|
Cidade pgtype.Text `json:"cidade"`
|
|
Estado pgtype.Text `json:"estado"`
|
|
Observacoes pgtype.Text `json:"observacoes"`
|
|
GastosCaptacao pgtype.Numeric `json:"gastos_captacao"`
|
|
PreVenda pgtype.Bool `json:"pre_venda"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
EmpresaNome string `json:"empresa_nome"`
|
|
CursoNome string `json:"curso_nome"`
|
|
AnoFormaturaLabel string `json:"ano_formatura_label"`
|
|
}
|
|
|
|
func (q *Queries) ListCadastroFot(ctx context.Context) ([]ListCadastroFotRow, error) {
|
|
rows, err := q.db.Query(ctx, listCadastroFot)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListCadastroFotRow
|
|
for rows.Next() {
|
|
var i ListCadastroFotRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Fot,
|
|
&i.EmpresaID,
|
|
&i.CursoID,
|
|
&i.AnoFormaturaID,
|
|
&i.Instituicao,
|
|
&i.Cidade,
|
|
&i.Estado,
|
|
&i.Observacoes,
|
|
&i.GastosCaptacao,
|
|
&i.PreVenda,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EmpresaNome,
|
|
&i.CursoNome,
|
|
&i.AnoFormaturaLabel,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listCadastroFotByEmpresa = `-- name: ListCadastroFotByEmpresa :many
|
|
SELECT
|
|
c.id, c.fot, c.empresa_id, c.curso_id, c.ano_formatura_id, c.instituicao, c.cidade, c.estado, c.observacoes, c.gastos_captacao, c.pre_venda, c.created_at, c.updated_at,
|
|
e.nome as empresa_nome,
|
|
cur.nome as curso_nome,
|
|
a.ano_semestre as ano_formatura_label
|
|
FROM cadastro_fot c
|
|
JOIN empresas e ON c.empresa_id = e.id
|
|
JOIN cursos cur ON c.curso_id = cur.id
|
|
JOIN anos_formaturas a ON c.ano_formatura_id = a.id
|
|
WHERE c.empresa_id = $1
|
|
ORDER BY c.fot DESC
|
|
`
|
|
|
|
type ListCadastroFotByEmpresaRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Fot string `json:"fot"`
|
|
EmpresaID pgtype.UUID `json:"empresa_id"`
|
|
CursoID pgtype.UUID `json:"curso_id"`
|
|
AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"`
|
|
Instituicao pgtype.Text `json:"instituicao"`
|
|
Cidade pgtype.Text `json:"cidade"`
|
|
Estado pgtype.Text `json:"estado"`
|
|
Observacoes pgtype.Text `json:"observacoes"`
|
|
GastosCaptacao pgtype.Numeric `json:"gastos_captacao"`
|
|
PreVenda pgtype.Bool `json:"pre_venda"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
EmpresaNome string `json:"empresa_nome"`
|
|
CursoNome string `json:"curso_nome"`
|
|
AnoFormaturaLabel string `json:"ano_formatura_label"`
|
|
}
|
|
|
|
func (q *Queries) ListCadastroFotByEmpresa(ctx context.Context, empresaID pgtype.UUID) ([]ListCadastroFotByEmpresaRow, error) {
|
|
rows, err := q.db.Query(ctx, listCadastroFotByEmpresa, empresaID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListCadastroFotByEmpresaRow
|
|
for rows.Next() {
|
|
var i ListCadastroFotByEmpresaRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Fot,
|
|
&i.EmpresaID,
|
|
&i.CursoID,
|
|
&i.AnoFormaturaID,
|
|
&i.Instituicao,
|
|
&i.Cidade,
|
|
&i.Estado,
|
|
&i.Observacoes,
|
|
&i.GastosCaptacao,
|
|
&i.PreVenda,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EmpresaNome,
|
|
&i.CursoNome,
|
|
&i.AnoFormaturaLabel,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const searchFot = `-- name: SearchFot :many
|
|
SELECT
|
|
c.id, c.fot, c.empresa_id, c.curso_id, c.ano_formatura_id, c.instituicao, c.cidade, c.estado, c.observacoes, c.gastos_captacao, c.pre_venda, c.created_at, c.updated_at,
|
|
e.nome as empresa_nome,
|
|
cur.nome as curso_nome,
|
|
a.ano_semestre as ano_formatura_label
|
|
FROM cadastro_fot c
|
|
JOIN empresas e ON c.empresa_id = e.id
|
|
JOIN cursos cur ON c.curso_id = cur.id
|
|
JOIN anos_formaturas a ON c.ano_formatura_id = a.id
|
|
WHERE CAST(c.fot AS TEXT) ILIKE '%' || $1 || '%'
|
|
ORDER BY c.fot ASC
|
|
LIMIT 10
|
|
`
|
|
|
|
type SearchFotRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Fot string `json:"fot"`
|
|
EmpresaID pgtype.UUID `json:"empresa_id"`
|
|
CursoID pgtype.UUID `json:"curso_id"`
|
|
AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"`
|
|
Instituicao pgtype.Text `json:"instituicao"`
|
|
Cidade pgtype.Text `json:"cidade"`
|
|
Estado pgtype.Text `json:"estado"`
|
|
Observacoes pgtype.Text `json:"observacoes"`
|
|
GastosCaptacao pgtype.Numeric `json:"gastos_captacao"`
|
|
PreVenda pgtype.Bool `json:"pre_venda"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
EmpresaNome string `json:"empresa_nome"`
|
|
CursoNome string `json:"curso_nome"`
|
|
AnoFormaturaLabel string `json:"ano_formatura_label"`
|
|
}
|
|
|
|
func (q *Queries) SearchFot(ctx context.Context, dollar_1 pgtype.Text) ([]SearchFotRow, error) {
|
|
rows, err := q.db.Query(ctx, searchFot, dollar_1)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []SearchFotRow
|
|
for rows.Next() {
|
|
var i SearchFotRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Fot,
|
|
&i.EmpresaID,
|
|
&i.CursoID,
|
|
&i.AnoFormaturaID,
|
|
&i.Instituicao,
|
|
&i.Cidade,
|
|
&i.Estado,
|
|
&i.Observacoes,
|
|
&i.GastosCaptacao,
|
|
&i.PreVenda,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EmpresaNome,
|
|
&i.CursoNome,
|
|
&i.AnoFormaturaLabel,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateCadastroFot = `-- name: UpdateCadastroFot :one
|
|
UPDATE cadastro_fot SET
|
|
fot = $2,
|
|
empresa_id = $3,
|
|
curso_id = $4,
|
|
ano_formatura_id = $5,
|
|
instituicao = $6,
|
|
cidade = $7,
|
|
estado = $8,
|
|
observacoes = $9,
|
|
gastos_captacao = $10,
|
|
pre_venda = $11,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = $1
|
|
RETURNING id, fot, empresa_id, curso_id, ano_formatura_id, instituicao, cidade, estado, observacoes, gastos_captacao, pre_venda, created_at, updated_at
|
|
`
|
|
|
|
type UpdateCadastroFotParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Fot string `json:"fot"`
|
|
EmpresaID pgtype.UUID `json:"empresa_id"`
|
|
CursoID pgtype.UUID `json:"curso_id"`
|
|
AnoFormaturaID pgtype.UUID `json:"ano_formatura_id"`
|
|
Instituicao pgtype.Text `json:"instituicao"`
|
|
Cidade pgtype.Text `json:"cidade"`
|
|
Estado pgtype.Text `json:"estado"`
|
|
Observacoes pgtype.Text `json:"observacoes"`
|
|
GastosCaptacao pgtype.Numeric `json:"gastos_captacao"`
|
|
PreVenda pgtype.Bool `json:"pre_venda"`
|
|
}
|
|
|
|
func (q *Queries) UpdateCadastroFot(ctx context.Context, arg UpdateCadastroFotParams) (CadastroFot, error) {
|
|
row := q.db.QueryRow(ctx, updateCadastroFot,
|
|
arg.ID,
|
|
arg.Fot,
|
|
arg.EmpresaID,
|
|
arg.CursoID,
|
|
arg.AnoFormaturaID,
|
|
arg.Instituicao,
|
|
arg.Cidade,
|
|
arg.Estado,
|
|
arg.Observacoes,
|
|
arg.GastosCaptacao,
|
|
arg.PreVenda,
|
|
)
|
|
var i CadastroFot
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Fot,
|
|
&i.EmpresaID,
|
|
&i.CursoID,
|
|
&i.AnoFormaturaID,
|
|
&i.Instituicao,
|
|
&i.Cidade,
|
|
&i.Estado,
|
|
&i.Observacoes,
|
|
&i.GastosCaptacao,
|
|
&i.PreVenda,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateCadastroFotGastos = `-- name: UpdateCadastroFotGastos :exec
|
|
UPDATE cadastro_fot SET
|
|
gastos_captacao = $2,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = $1
|
|
`
|
|
|
|
type UpdateCadastroFotGastosParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
GastosCaptacao pgtype.Numeric `json:"gastos_captacao"`
|
|
}
|
|
|
|
func (q *Queries) UpdateCadastroFotGastos(ctx context.Context, arg UpdateCadastroFotGastosParams) error {
|
|
_, err := q.db.Exec(ctx, updateCadastroFotGastos, arg.ID, arg.GastosCaptacao)
|
|
return err
|
|
}
|