Compare commits

..
2 Commits
8 changed files with 444 additions and 37 deletions
+2
View File
@@ -23,3 +23,5 @@ APP_PREFORK=false
SESSION_DATABASE=./session.db
HERMES_API_KEY=hk_live_usite_2026_S3cur3K3yH3rm3s
+9 -10
View File
@@ -61,8 +61,10 @@ func (Transaccion) TableName() string { return "contab_transacciones" }
type CuentaCobro struct {
gorm.Model
EntidadID uint `json:"entidad_id" gorm:"column:entidad_id;index;not null"`
Entidad Entidad `json:"entidad" gorm:"foreignKey:EntidadID"`
ClienteID uint `json:"cliente_id" gorm:"column:cliente_id;index;not null"`
Cliente Cliente `json:"cliente" gorm:"foreignKey:ClienteID"`
EntidadID *uint `json:"entidad_id" gorm:"column:entidad_id;index"`
Entidad *Entidad `json:"entidad" gorm:"foreignKey:EntidadID"`
Fecha time.Time `json:"fecha" gorm:"column:fecha;not null"`
Descripcion string `json:"descripcion" gorm:"column:descripcion;type:text"`
Valor float64 `json:"valor" gorm:"column:valor;not null"`
@@ -260,11 +262,11 @@ func DeleteTransaccion(id uint) error {
func GetAllCuentasCobro(limit, offset int, search string, estado string) ([]CuentaCobro, int64, error) {
var items []CuentaCobro
var total int64
db := app.Http.Database.DB.Model(&CuentaCobro{}).Preload("Entidad").Preload("Transaccion")
db := app.Http.Database.DB.Model(&CuentaCobro{}).Preload("Cliente").Preload("Entidad").Preload("Transaccion")
if search != "" {
db = db.Joins("JOIN contab_entidades ON contab_entidades.id = contab_cuentas_cobro.entidad_id").
Where("contab_entidades.nombre ILIKE ? OR contab_cuentas_cobro.descripcion ILIKE ?",
"%"+search+"%", "%"+search+"%")
db = db.Joins("JOIN clientes ON clientes.id = contab_cuentas_cobro.cliente_id").
Where("clientes.nombre ILIKE ? OR clientes.empresa ILIKE ? OR contab_cuentas_cobro.descripcion ILIKE ?",
"%"+search+"%", "%"+search+"%", "%"+search+"%")
}
if estado != "" {
db = db.Where("contab_cuentas_cobro.estado = ?", estado)
@@ -463,10 +465,7 @@ func CreateCuentaCobro(cc *CuentaCobro) error {
func UpdateCuentaCobro(cc *CuentaCobro) error {
return app.Http.Database.DB.Model(&CuentaCobro{}).Where("id = ?", cc.ID).Updates(map[string]interface{}{
"entidad_id": cc.EntidadID,
"fecha": cc.Fecha,
"descripcion": cc.Descripcion,
"valor": cc.Valor,
"cliente_id": cc.ClienteID,
"estado": cc.Estado,
"fecha_vencimiento": cc.FechaVencimiento,
"fecha_pago": cc.FechaPago,
+11 -11
View File
@@ -26,7 +26,7 @@
<thead class="bg-slate-50 text-slate-500 text-xs uppercase tracking-wide">
<tr>
<th class="px-4 py-3 text-left">Fecha</th>
<th class="px-4 py-3 text-left">Entidad</th>
<th class="px-4 py-3 text-left">Cliente</th>
<th class="px-4 py-3 text-left">Descripción</th>
<th class="px-4 py-3 text-right">Valor</th>
<th class="px-4 py-3 text-left">Vence</th>
@@ -41,7 +41,7 @@
<template x-for="c in items" :key="c.ID">
<tr class="hover:bg-slate-50">
<td class="px-4 py-3 text-xs text-slate-500" x-text="formatDate(c.fecha)"></td>
<td class="px-4 py-3 text-slate-700 font-medium" x-text="c.entidad?.nombre||'-'"></td>
<td class="px-4 py-3 text-slate-700 font-medium" x-text="c.cliente?.nombre||'-'"></td>
<td class="px-4 py-3 text-slate-600" x-text="c.descripcion"></td>
<td class="px-4 py-3 text-right font-semibold text-amber-600" x-text="formatoCOP(c.valor)"></td>
<td class="px-4 py-3 text-xs text-slate-500" x-text="formatDate(c.fecha_vencimiento)"></td>
@@ -80,11 +80,11 @@
<form @submit.prevent="save()">
<div class="grid grid-cols-2 gap-4">
<div class="col-span-2">
<label class="label">Entidad (quien debe)</label>
<select x-model.number="form.entidad_id" class="input-field w-full" required>
<label class="label">Cliente (quien debe)</label>
<select x-model.number="form.cliente_id" class="input-field w-full" required>
<option value="">Seleccionar...</option>
<template x-for="e in entidades" :key="e.ID">
<option :value="e.ID" x-text="e.nombre"></option>
<template x-for="cl in clientes" :key="cl.ID">
<option :value="cl.ID" x-text="cl.nombre + (cl.empresa ? ' — ' + cl.empresa : '')"></option>
</template>
</select>
</div>
@@ -149,10 +149,10 @@
<script>
function cobroApp() {
return {
items:[], entidades:[], total:0, totalPages:1, page:1, search:'', filtroEstado:'',
items:[], clientes:[], total:0, totalPages:1, page:1, search:'', filtroEstado:'',
loading:false, saving:false, showModal:false, showDelete:false, showPagarModal:false,
deleteId:null, pagarId:null, pagoFecha:'', error:'',
form:{ entidad_id:'', descripcion:'', valor:0, fecha:'', fecha_vencimiento:'', notas:'' },
form:{ cliente_id:'', descripcion:'', valor:0, fecha:'', fecha_vencimiento:'', notas:'' },
async init(){ await this.load(); },
@@ -163,12 +163,12 @@ function cobroApp() {
if(this.filtroEstado) params.set('estado',this.filtroEstado);
const r=await axios.get('/app/contabilidad/cuentas-cobro/list?'+params.toString());
this.items=r.data.items; this.total=r.data.total; this.totalPages=r.data.totalPages;
const er=await axios.get('/app/contabilidad/entidades/select');
this.entidades=er.data;
const er=await axios.get('/app/api/clientes/select');
this.clientes=er.data;
} finally{ this.loading=false; }
},
openCreate(){ this.editId=null; this.error=''; this.form={entidad_id:'',descripcion:'',valor:0,fecha:'',fecha_vencimiento:'',notas:''}; this.showModal=true; },
openCreate(){ this.editId=null; this.error=''; this.form={cliente_id:'',descripcion:'',valor:0,fecha:'',fecha_vencimiento:'',notas:''}; this.showModal=true; },
async save(){
this.saving=true; this.error='';
try {
+11 -11
View File
@@ -23,7 +23,7 @@
<thead class="bg-slate-50 text-slate-500 text-xs uppercase tracking-wide">
<tr>
<th class="px-4 py-3 text-left">Fecha</th>
<th class="px-4 py-3 text-left">Entidad</th>
<th class="px-4 py-3 text-left">Cliente</th>
<th class="px-4 py-3 text-left">Descripción</th>
<th class="px-4 py-3 text-right">Valor</th>
<th class="px-4 py-3 text-left">Vence</th>
@@ -38,7 +38,7 @@
<template x-for="c in items" :key="c.ID">
<tr class="hover:bg-slate-50">
<td class="px-4 py-3 text-xs text-slate-500" x-text="formatDate(c.fecha)"></td>
<td class="px-4 py-3 text-slate-700 font-medium" x-text="c.entidad?.nombre||'-'"></td>
<td class="px-4 py-3 text-slate-700 font-medium" x-text="c.cliente?.nombre||'-'"></td>
<td class="px-4 py-3 text-slate-600" x-text="c.descripcion"></td>
<td class="px-4 py-3 text-right font-semibold text-amber-600" x-text="formatoCOP(c.valor)"></td>
<td class="px-4 py-3 text-xs text-slate-500" x-text="formatDate(c.fecha_vencimiento)"></td>
@@ -73,11 +73,11 @@
<form @submit.prevent="save()">
<div class="grid grid-cols-2 gap-3">
<div class="col-span-2">
<label class="label">Entidad (quien debe)</label>
<select x-model.number="form.entidad_id" class="input-field w-full" required>
<label class="label">Cliente (quien debe)</label>
<select x-model.number="form.cliente_id" class="input-field w-full" required>
<option value="">Seleccionar...</option>
<template x-for="e in entidades" :key="e.ID">
<option :value="e.ID" x-text="e.nombre"></option>
<template x-for="cl in clientes" :key="cl.ID">
<option :value="cl.ID" x-text="cl.nombre + (cl.empresa ? ' — ' + cl.empresa : '')"></option>
</template>
</select>
</div>
@@ -141,10 +141,10 @@
<script>
function cobroApp() {
return {
items:[], entidades:[], total:0, totalPages:1, page:1, search:'', filtroEstado:'',
items:[], clientes:[], total:0, totalPages:1, page:1, search:'', filtroEstado:'',
loading:false, saving:false, showModal:false, showDelete:false, showPagarModal:false,
deleteId:null, pagarId:null, pagoFecha:'', error:'',
form:{ entidad_id:'', descripcion:'', valor:0, fecha:'', fecha_vencimiento:'', notas:'' },
form:{ cliente_id:'', descripcion:'', valor:0, fecha:'', fecha_vencimiento:'', notas:'' },
async init(){ await this.load(); },
@@ -155,12 +155,12 @@ function cobroApp() {
if(this.filtroEstado) params.set('estado',this.filtroEstado);
const r=await axios.get('/app/contabilidad/cuentas-cobro/list?'+params.toString());
this.items=r.data.items; this.total=r.data.total; this.totalPages=r.data.totalPages;
const er=await axios.get('/app/contabilidad/entidades/select');
this.entidades=er.data;
const er=await axios.get('/app/api/clientes/select');
this.clientes=er.data;
} finally{ this.loading=false; }
},
openCreate(){ this.editId=null; this.error=''; this.form={entidad_id:'',descripcion:'',valor:0,fecha:'',fecha_vencimiento:'',notas:''}; this.showModal=true; },
openCreate(){ this.editId=null; this.error=''; this.form={cliente_id:'',descripcion:'',valor:0,fecha:'',fecha_vencimiento:'',notas:''}; this.showModal=true; },
async save(){
this.saving=true; this.error='';
try {
+4 -4
View File
@@ -408,7 +408,7 @@ func GetCuentasCobro(c *fiber.Ctx) error {
func CreateCuentaCobro(c *fiber.Ctx) error {
type Req struct {
EntidadID uint `json:"entidad_id"`
ClienteID uint `json:"cliente_id"`
Fecha string `json:"fecha"`
Descripcion string `json:"descripcion"`
Valor float64 `json:"valor"`
@@ -419,11 +419,11 @@ func CreateCuentaCobro(c *fiber.Ctx) error {
if err := c.BodyParser(&req); err != nil {
return c.Status(400).JSON(fiber.Map{"error": err.Error()})
}
if req.EntidadID == 0 {
return c.Status(400).JSON(fiber.Map{"error": "entidad_id es requerido"})
if req.ClienteID == 0 {
return c.Status(400).JSON(fiber.Map{"error": "cliente_id es requerido"})
}
cc := &models.CuentaCobro{
EntidadID: req.EntidadID,
ClienteID: req.ClienteID,
Descripcion: req.Descripcion,
Valor: req.Valor,
Estado: "pendiente",
+32
View File
@@ -0,0 +1,32 @@
package middlewares
import (
"os"
"strings"
"github.com/gofiber/fiber/v2"
)
func HermesAuth() fiber.Handler {
return func(c *fiber.Ctx) error {
apiKey := os.Getenv("HERMES_API_KEY")
if apiKey == "" {
return c.Status(503).JSON(fiber.Map{"error": "HERMES_API_KEY not configured"})
}
token := ""
auth := c.Get("Authorization")
if strings.HasPrefix(auth, "Bearer ") {
token = auth[7:]
}
if token == "" {
token = c.Get("X-API-Key")
}
if token == "" || token != apiKey {
return c.Status(401).JSON(fiber.Map{"error": "unauthorized"})
}
return c.Next()
}
}
+372
View File
@@ -0,0 +1,372 @@
package routes
import (
"github.com/gofiber/fiber/v2"
"github.com/sujit-baniya/fiber-boilerplate/rest/controllers"
"github.com/sujit-baniya/fiber-boilerplate/rest/middlewares"
)
func HermesRoutes(app *fiber.App) {
h := app.Group("/hermes", middlewares.HermesAuth())
// ─── Usuarios ────────────────────────────────────────────────────────────
h.Get("/users", controllers.GetUsers)
h.Get("/users/:id", controllers.GetUser)
h.Post("/users", controllers.CreateUser)
h.Put("/users/:id", controllers.UpdateUser)
h.Delete("/users/:id", controllers.DeleteUser)
// ─── Roles ───────────────────────────────────────────────────────────────
h.Get("/roles", controllers.GetRoles)
h.Post("/roles", controllers.CreateRole)
h.Put("/roles/:id", controllers.UpdateRole)
h.Delete("/roles/:id", controllers.DeleteRole)
// ─── Módulos ─────────────────────────────────────────────────────────────
h.Get("/modules", controllers.GetModules)
h.Post("/modules", controllers.CreateModule)
h.Put("/modules/:id", controllers.UpdateModule)
h.Delete("/modules/:id", controllers.DeleteModule)
// ─── Submódulos ──────────────────────────────────────────────────────────
h.Get("/submodules", controllers.GetSubmodules)
h.Post("/submodules", controllers.CreateSubmodule)
h.Put("/submodules/:id", controllers.UpdateSubmodule)
h.Delete("/submodules/:id", controllers.DeleteSubmodule)
// ─── Servidores ──────────────────────────────────────────────────────────
h.Get("/servidores", controllers.GetServidor)
h.Post("/servidores", controllers.CreateServidor)
h.Put("/servidores/:id", controllers.UpdateServidor)
h.Delete("/servidores/:id", controllers.DeleteServidor)
h.Get("/servidores/:id/dashboard", controllers.GetServidorDashboard)
h.Get("/servidores/:id/metricas-history", controllers.GetMetricasHistory)
// ─── Proveedores de servidor ─────────────────────────────────────────────
h.Get("/prov-servidores", controllers.GetProvServidor)
h.Post("/prov-servidores", controllers.CreateProvServidor)
h.Put("/prov-servidores/:id", controllers.UpdateProvServidor)
h.Delete("/prov-servidores/:id", controllers.DeleteProvServidor)
// ─── Tipos de servidor ───────────────────────────────────────────────────
h.Get("/tipos-servidor", controllers.GetTipoServidor)
h.Post("/tipos-servidor", controllers.CreateTipoServidor)
h.Put("/tipos-servidor/:id", controllers.UpdateTipoServidor)
h.Delete("/tipos-servidor/:id", controllers.DeleteTipoServidor)
// ─── Tipos de DB ─────────────────────────────────────────────────────────
h.Get("/tipos-db", controllers.GetTipoDb)
h.Post("/tipos-db", controllers.CreateTipoDb)
h.Put("/tipos-db/:id", controllers.UpdateTipoDb)
h.Delete("/tipos-db/:id", controllers.DeleteTipoDb)
// ─── Conexiones SSH ──────────────────────────────────────────────────────
h.Get("/conexiones-ssh", controllers.GetConxSsh)
h.Post("/conexiones-ssh", controllers.CreateConxSsh)
h.Put("/conexiones-ssh/:id", controllers.UpdateConxSsh)
h.Delete("/conexiones-ssh/:id", controllers.DeleteConxSsh)
// ─── Conexiones DB ───────────────────────────────────────────────────────
h.Get("/conexiones-db", controllers.GetConxDb)
h.Get("/conexiones-db/select", controllers.GetConxDbSelect)
h.Post("/conexiones-db", controllers.CreateConxDb)
h.Put("/conexiones-db/:id", controllers.UpdateConxDb)
h.Delete("/conexiones-db/:id", controllers.DeleteConxDb)
// ─── Clientes ────────────────────────────────────────────────────────────
h.Get("/clientes", controllers.GetClientes)
h.Get("/clientes/select", controllers.GetClientesSelect)
h.Post("/clientes", controllers.CreateCliente)
h.Put("/clientes/:id", controllers.UpdateCliente)
h.Delete("/clientes/:id", controllers.DeleteCliente)
h.Get("/clientes/:clienteID/documentos", controllers.GetClienteDocumentos)
h.Post("/clientes/:clienteID/documentos", controllers.UploadClienteDocumentos)
h.Delete("/clientes/:clienteID/documentos/:docID", controllers.DeleteClienteDocumento)
h.Get("/clientes/:clienteID/documentos/:docID/download", controllers.DownloadClienteDocumento)
// ─── Servicios ───────────────────────────────────────────────────────────
h.Get("/servicios", controllers.GetServicios)
h.Get("/servicios/select", controllers.GetServiciosSelect)
h.Post("/servicios", controllers.CreateServicio)
h.Put("/servicios/:id", controllers.UpdateServicio)
h.Delete("/servicios/:id", controllers.DeleteServicio)
// ─── Contratos ───────────────────────────────────────────────────────────
h.Get("/contratos", controllers.GetContratos)
h.Post("/contratos", controllers.CreateContrato)
h.Put("/contratos/:id", controllers.UpdateContrato)
h.Delete("/contratos/:id", controllers.DeleteContrato)
h.Post("/contratos/:id/renovar", controllers.RenovarContrato)
h.Post("/contratos/:id/enviar-correo", controllers.EnviarCorreoContrato)
h.Get("/contratos/:id/historial", controllers.GetHistorialContrato)
h.Post("/contratos/:id/verificar-pago", controllers.VerificarPagoBold)
h.Post("/contratos/:id/marcar-pagado", controllers.MarcarPagoManual)
// ─── Plantillas de correo ────────────────────────────────────────────────
h.Get("/plantillas-correo", controllers.GetPlantillas)
h.Post("/plantillas-correo", controllers.CreatePlantilla)
h.Put("/plantillas-correo/:id", controllers.UpdatePlantilla)
h.Delete("/plantillas-correo/:id", controllers.DeletePlantilla)
h.Get("/plantillas-correo/:id/preview", controllers.PreviewPlantilla)
// ─── Reglas de notificación ──────────────────────────────────────────────
h.Get("/reglas-notificacion", controllers.GetReglas)
h.Post("/reglas-notificacion", controllers.CreateRegla)
h.Put("/reglas-notificacion/:id", controllers.UpdateRegla)
h.Delete("/reglas-notificacion/:id", controllers.DeleteRegla)
// ─── Historial de notificaciones ─────────────────────────────────────────
h.Get("/historial-notificaciones", controllers.GetHistorial)
h.Post("/historial-notificaciones/:id/reenviar", controllers.ReenviarNotificacion)
// ─── SMTP Config ─────────────────────────────────────────────────────────
h.Get("/smtp-config", controllers.GetSmtpConfig)
h.Post("/smtp-config", controllers.SaveSmtpConfig)
// ─── Tareas (kanban) ─────────────────────────────────────────────────────
h.Get("/tareas", controllers.GetTareas)
h.Get("/tareas/usuarios", controllers.GetUsuariosSistema)
h.Post("/tareas", controllers.CreateTarea)
h.Get("/tareas/:id", controllers.GetTareaDetalle)
h.Put("/tareas/:id", controllers.UpdateTarea)
h.Put("/tareas/:id/estado", controllers.CambiarEstadoTarea)
h.Delete("/tareas/:id", controllers.DeleteTareaHandler)
h.Post("/tareas/:id/comentario", controllers.AddComentario)
// ─── Monitor de URLs ─────────────────────────────────────────────────────
h.Get("/url-monitors", controllers.GetUrlMonitors)
h.Post("/url-monitors", controllers.CreateUrlMonitor)
h.Put("/url-monitors/:id", controllers.UpdateUrlMonitor)
h.Delete("/url-monitors/:id", controllers.DeleteUrlMonitorHandler)
h.Post("/url-monitors/:id/check", controllers.CheckUrlMonitorNow)
h.Get("/url-monitors/:id/logs", controllers.GetUrlMonitorLogsHandler)
// ─── Proyectos ───────────────────────────────────────────────────────────
h.Get("/proyectos", controllers.LoadProyectos)
h.Post("/proyectos", controllers.CreateProyecto)
h.Put("/proyectos/:id", controllers.UpdateProyecto)
h.Delete("/proyectos/:id", controllers.DeleteProyecto)
h.Get("/proyectos/:id/fases", controllers.GetFases)
h.Post("/proyectos/:id/fases", controllers.CreateFase)
h.Put("/proyectos/:id/fases/:faseID", controllers.UpdateFase)
h.Delete("/proyectos/:id/fases/:faseID", controllers.DeleteFase)
h.Get("/proyectos/:id/avances", controllers.GetAvances)
h.Post("/proyectos/:id/avances", controllers.CreateAvance)
h.Put("/proyectos/:id/avances/:avID", controllers.UpdateAvance)
h.Delete("/proyectos/:id/avances/:avID", controllers.DeleteAvance)
h.Get("/proyectos/:id/entregables", controllers.GetEntregables)
h.Post("/proyectos/:id/entregables", controllers.UploadEntregable)
h.Delete("/proyectos/:id/entregables/:entID", controllers.DeleteEntregable)
h.Get("/proyectos/:id/entregables/:entID/download", controllers.DownloadEntregable)
h.Get("/proyectos/:id/tickets", controllers.GetTickets)
h.Put("/proyectos/:id/tickets/:ticketID/estado", controllers.UpdateTicketEstadoAdmin)
h.Post("/proyectos/:id/tickets/:ticketID/mensaje", controllers.AdminResponderTicket)
h.Get("/proyectos/:id/documentos", controllers.GetDocumentos)
h.Post("/proyectos/:id/documentos", controllers.UploadDocumento)
h.Delete("/proyectos/:id/documentos/:docID", controllers.DeleteDocumento)
h.Get("/proyectos/:id/documentos/:docID/download", controllers.DownloadDocumento)
// ─── Portal de Usuarios ──────────────────────────────────────────────────
h.Get("/portal-usuarios", controllers.LoadPortalUsuarios)
h.Get("/portal-usuarios/:id", controllers.GetPortalUsuarioDetail)
h.Post("/portal-usuarios", controllers.CreatePortalUsuario)
h.Put("/portal-usuarios/:id", controllers.UpdatePortalUsuario)
h.Delete("/portal-usuarios/:id", controllers.DeletePortalUsuario)
h.Post("/portal-usuarios/:id/acceso", controllers.AddPortalAcceso)
h.Delete("/portal-usuarios/:id/acceso/:clienteID", controllers.RemovePortalAcceso)
h.Post("/portal-usuarios/:id/send-credentials", controllers.SendPortalCredentials)
// ─── Facturas ────────────────────────────────────────────────────────────
h.Get("/facturas", controllers.LoadFacturas)
h.Post("/facturas", controllers.CreateFactura)
h.Put("/facturas/:id", controllers.UpdateFactura)
h.Delete("/facturas/:id", controllers.DeleteFactura)
h.Post("/facturas/:id/upload-pdf", controllers.UploadFacturaPDF)
h.Get("/facturas/:id/download", controllers.DownloadFacturaPDF)
// ─── Tickets (global) ────────────────────────────────────────────────────
h.Get("/tickets", controllers.GetAllTicketsAdmin)
h.Put("/tickets/:ticketID/estado", controllers.UpdateTicketEstadoAdmin)
h.Post("/tickets/:ticketID/mensaje", controllers.AdminResponderTicket)
// ─── Contabilidad ────────────────────────────────────────────────────────
h.Get("/contabilidad/dashboard", controllers.ContabilidadDashboard)
h.Get("/contabilidad/consolidado", controllers.ContabilidadConsolidado)
h.Get("/contabilidad/consolidados", controllers.ContabilidadListConsolidados)
// Transacciones
h.Get("/contabilidad/transacciones", controllers.GetTransacciones)
h.Post("/contabilidad/transacciones", controllers.CreateTransaccion)
h.Put("/contabilidad/transacciones/:id", controllers.UpdateTransaccion)
h.Delete("/contabilidad/transacciones/:id", controllers.DeleteTransaccion)
// Cuentas contables
h.Get("/contabilidad/cuentas", controllers.GetCuentas)
h.Get("/contabilidad/cuentas/select", controllers.GetCuentasSelect)
h.Post("/contabilidad/cuentas", controllers.CreateCuenta)
h.Put("/contabilidad/cuentas/:id", controllers.UpdateCuenta)
h.Delete("/contabilidad/cuentas/:id", controllers.DeleteCuenta)
// Entidades
h.Get("/contabilidad/entidades", controllers.GetEntidades)
h.Get("/contabilidad/entidades/select", controllers.GetEntidadesSelect)
h.Post("/contabilidad/entidades", controllers.CreateEntidad)
h.Put("/contabilidad/entidades/:id", controllers.UpdateEntidad)
h.Delete("/contabilidad/entidades/:id", controllers.DeleteEntidad)
// Cuentas por cobrar
h.Get("/contabilidad/cuentas-cobro", controllers.GetCuentasCobro)
h.Post("/contabilidad/cuentas-cobro", controllers.CreateCuentaCobro)
h.Put("/contabilidad/cuentas-cobro/:id", controllers.UpdateCuentaCobro)
h.Delete("/contabilidad/cuentas-cobro/:id", controllers.DeleteCuentaCobro)
// Cuentas por pagar
h.Get("/contabilidad/cuentas-pagar", controllers.GetCuentasPagar)
h.Post("/contabilidad/cuentas-pagar", controllers.CreateCuentaPagar)
h.Put("/contabilidad/cuentas-pagar/:id", controllers.UpdateCuentaPagar)
h.Post("/contabilidad/cuentas-pagar/:id/pagar", controllers.MarcarCuentaPagarPagada)
h.Delete("/contabilidad/cuentas-pagar/:id", controllers.DeleteCuentaPagar)
// ─── Productos SaaS ──────────────────────────────────────────────────────
h.Get("/saas", controllers.GetSaasProductos)
h.Post("/saas", controllers.CreateSaasProducto)
h.Put("/saas/:id", controllers.UpdateSaasProducto)
h.Delete("/saas/:id", controllers.DeleteSaasProducto)
h.Get("/saas/:id/health", controllers.HealthCheckSaas)
// ─── Integraciones SaaS (dispatcher) ─────────────────────────────────────
h.Get("/saas-api", controllers.GetSaasApiConfigs)
h.Post("/saas-api", controllers.CreateSaasApiConfig)
h.Put("/saas-api/:id", controllers.UpdateSaasApiConfig)
h.Delete("/saas-api/:id", controllers.DeleteSaasApiConfig)
h.Get("/saas-api/logs", controllers.GetSaasDispatchLogs)
// ─── Documentación ───────────────────────────────────────────────────────
h.Get("/doc/categorias", controllers.GetDocCategorias)
h.Post("/doc/categorias", controllers.CreateDocCategoria)
h.Put("/doc/categorias/:id", controllers.UpdateDocCategoria)
h.Delete("/doc/categorias/:id", controllers.DeleteDocCategoria)
h.Get("/doc/paginas", controllers.GetDocPaginas)
h.Get("/doc/paginas/:id", controllers.GetDocPaginaDetalle)
h.Post("/doc/paginas", controllers.CreateDocPagina)
h.Put("/doc/paginas/:id", controllers.UpdateDocPagina)
h.Delete("/doc/paginas/:id", controllers.DeleteDocPagina)
// ─── Configuraciones de IA ───────────────────────────────────────────────
h.Get("/ai-config", controllers.GetAiConfigs)
h.Get("/ai-config/select", controllers.GetAiConfigSelect)
h.Post("/ai-config", controllers.CreateAiConfigHandler)
h.Put("/ai-config/:id", controllers.UpdateAiConfigHandler)
h.Delete("/ai-config/:id", controllers.DeleteAiConfigHandler)
h.Get("/ai-config/:id/test", controllers.TestAiConfigHandler)
// ─── OSS API (almacenamiento) ────────────────────────────────────────────
h.Get("/oss-api", controllers.GetOssApiConfigs)
h.Get("/oss-api/active", controllers.GetActiveOssApiList)
h.Post("/oss-api", controllers.CreateOssApiConfig)
h.Put("/oss-api/:id", controllers.UpdateOssApiConfig)
h.Delete("/oss-api/:id", controllers.DeleteOssApiConfig)
h.Get("/oss-api/browser", controllers.OssBrowserList)
h.Get("/oss-api/browser/url", controllers.OssBrowserSignedURL)
h.Delete("/oss-api/browser/object", controllers.OssBrowserDelete)
h.Post("/oss-api/browser/upload", controllers.OssBrowserUpload)
// ─── Telegram ────────────────────────────────────────────────────────────
h.Get("/telegram", controllers.GetTelegramConfigs)
h.Post("/telegram", controllers.CreateTelegramConfig)
h.Put("/telegram/:id", controllers.UpdateTelegramConfig)
h.Delete("/telegram/:id", controllers.DeleteTelegramConfig)
h.Post("/telegram/:id/test", controllers.TestTelegramConfig)
h.Post("/telegram/send", controllers.SendTelegramNotification)
h.Get("/telegram/logs", controllers.GetTelegramLogs)
// ─── Notificaciones config ───────────────────────────────────────────────
h.Get("/notif-config", controllers.GetNotifConfigs)
h.Post("/notif-config", controllers.SaveNotifConfig)
h.Get("/servidor-alerta-config", controllers.GetServidorAlertaConfig)
h.Post("/servidor-alerta-config", controllers.SaveServidorAlertaConfig)
// ─── Partner Recursos / Comunicados ──────────────────────────────────────
h.Get("/partner-recursos", controllers.LoadPartnerRecursos)
h.Post("/partner-recursos", controllers.CreatePartnerRecurso)
h.Put("/partner-recursos/:id", controllers.UpdatePartnerRecurso)
h.Delete("/partner-recursos/:id", controllers.DeletePartnerRecurso)
h.Get("/partner-comunicados", controllers.LoadPartnerComunicados)
h.Post("/partner-comunicados", controllers.CreatePartnerComunicado)
h.Put("/partner-comunicados/:id", controllers.UpdatePartnerComunicado)
h.Delete("/partner-comunicados/:id", controllers.DeletePartnerComunicado)
// ─── Shield ──────────────────────────────────────────────────────────────
h.Get("/shield", controllers.LoadShieldConfig)
h.Post("/shield", controllers.SaveShieldConfig)
h.Get("/shield/health", controllers.ShieldHealth)
h.Get("/shield/logs", controllers.ShieldLogs)
h.Get("/shield/logs/stats", controllers.ShieldLogStats)
h.Get("/shield/review-requests", controllers.ShieldReviewRequests)
h.Put("/shield/review-requests/:id/approve", controllers.ShieldApproveRequest)
h.Put("/shield/review-requests/:id/reject", controllers.ShieldRejectRequest)
h.Get("/shield/whitelist", controllers.ShieldWhitelist)
h.Post("/shield/whitelist", controllers.ShieldAddWhitelist)
h.Delete("/shield/whitelist/:domain", controllers.ShieldDeleteWhitelist)
h.Get("/shield/blacklist", controllers.ShieldBlacklist)
h.Post("/shield/blacklist", controllers.ShieldAddBlacklist)
h.Delete("/shield/blacklist/:domain", controllers.ShieldDeleteBlacklist)
// ─── WebSMS ──────────────────────────────────────────────────────────────
h.Get("/websms/config", controllers.GetWebSmsConfig)
h.Post("/websms/save", controllers.SaveWebSmsConfig)
h.Post("/websms/test", controllers.TestWebSms)
h.Get("/websms/logs", controllers.GetWebSmsLogs)
// ─── Pasarelas de pago ───────────────────────────────────────────────────
h.Get("/pasarelas/bold/config", controllers.GetBoldConfigAPI)
h.Post("/pasarelas/bold/save", controllers.SaveBoldConfig)
h.Get("/pasarelas/bold/logs", controllers.BoldWebhookLogs)
h.Get("/pasarelas/dlocal/config", controllers.GetDlocalConfigAPI)
h.Post("/pasarelas/dlocal/save", controllers.SaveDlocalConfigWeb)
h.Get("/pasarelas/dlocal/logs", controllers.DlocalPaymentLogsPaginated)
h.Get("/pasarelas/paypal/config", controllers.GetPaypalConfigAPI)
h.Post("/pasarelas/paypal/save", controllers.SavePaypalConfigWeb)
// ─── Query Runner ────────────────────────────────────────────────────────
h.Get("/query-runner/connections", controllers.GetConxDbList)
h.Get("/query-runner/databases", controllers.GetDatabases)
h.Get("/query-runner/tables", controllers.GetTables)
h.Get("/query-runner/test", controllers.TestConnection)
h.Post("/query-runner/run", controllers.RunQuery)
h.Get("/query-runner/history", controllers.GetHistory)
h.Get("/query-runner/columns", controllers.GetTableColumnsHandler)
// ─── Hostinger ───────────────────────────────────────────────────────────
h.Get("/hostinger/vps", controllers.GetHostingerVPS)
h.Get("/hostinger/domains", controllers.GetHostingerDomains)
h.Get("/hostinger/dns/:domain", controllers.GetHostingerDNS)
h.Get("/hostinger/orders", controllers.GetHostingerOrders)
h.Get("/hostinger/hosting", controllers.GetHostingerHosting)
// ─── Cloudflare ──────────────────────────────────────────────────────────
h.Get("/cloudflare/zones", controllers.GetCloudflareZones)
h.Get("/cloudflare/zones/:zone_id/dns", controllers.GetCloudflareDNS)
h.Post("/cloudflare/zones/:zone_id/dns", controllers.CreateCloudflareDNS)
h.Put("/cloudflare/zones/:zone_id/dns/:record_id", controllers.UpdateCloudflareDNS)
h.Delete("/cloudflare/zones/:zone_id/dns/:record_id", controllers.DeleteCloudflareDNS)
// ─── Coolify ─────────────────────────────────────────────────────────────
h.Get("/coolify/apps", controllers.CoolifyListApplications)
h.Get("/coolify/apps/:uuid", controllers.CoolifyGetApplication)
h.Get("/coolify/apps/:uuid/start", controllers.CoolifyApplicationStart)
h.Get("/coolify/apps/:uuid/stop", controllers.CoolifyApplicationStop)
h.Get("/coolify/apps/:uuid/restart", controllers.CoolifyApplicationRestart)
h.Post("/coolify/apps/:uuid/deploy", controllers.CoolifyApplicationDeploy)
h.Get("/coolify/servers", controllers.CoolifyListServers)
h.Get("/coolify/servers/:uuid", controllers.CoolifyGetServer)
h.Get("/coolify/servers/:uuid/resources", controllers.CoolifyServerResources)
h.Get("/coolify/services", controllers.CoolifyListServices)
h.Get("/coolify/databases", controllers.CoolifyListDatabases)
h.Get("/coolify/projects", controllers.CoolifyListProjects)
h.Get("/coolify/deployments", controllers.CoolifyListDeployments)
// ─── VCard API ───────────────────────────────────────────────────────────
h.Get("/vcard-api/config", controllers.VcardApiGetConfig)
h.Get("/vcard-api/usuarios", controllers.VcardApiUsuarios)
h.Get("/vcard-api/usuarios/:id", controllers.VcardApiUsuario)
h.Get("/vcard-api/vcards", controllers.VcardApiVcards)
h.Get("/vcard-api/planes", controllers.VcardApiPlanes)
h.Get("/vcard-api/pagos", controllers.VcardApiPagos)
h.Get("/vcard-api/miniwebs", controllers.VcardApiMiniwebs)
}
+3 -1
View File
@@ -10,10 +10,12 @@ func LoadRoutes(app *fiber.App) {
api := app.Group("/api").Use(middlewares.AuthApi())
ApiRoutes(api)
// API Hermes (acceso externo con API Key)
HermesRoutes(app)
// Grupo de rutas web (sin autenticación)
web := app.Group("")
// Rutas del backend (web)
WebRoutes(web)
}