Private
Public Access
1174 lines
29 KiB
Markdown
1174 lines
29 KiB
Markdown
# Diagrama de Clases — Backend (Repuestera)
|
|
|
|
Diagrama de clases UML del backend Go (`/back`), limitado a los paquetes **main**, **routes**, **controllers**, **dto**, **models** y **repositorios**. Incluye el contenido de las clases y destaca el patrón **Composite** de `models/seguridad` y el patrón **Builder** de `dto/Builders`.
|
|
|
|
```plantuml
|
|
@startuml DiagramaClasesBackend
|
|
title Diagrama de Clases — Backend (Repuestera)
|
|
|
|
skinparam shadowing false
|
|
skinparam defaultFontName Arial
|
|
skinparam linetype ortho
|
|
skinparam packageStyle rectangle
|
|
skinparam classAttributeIconSize 0
|
|
skinparam nodesep 40
|
|
skinparam ranksep 60
|
|
|
|
' ===================== MAIN =====================
|
|
package "main" {
|
|
class Main <<utility>> {
|
|
+main()
|
|
}
|
|
}
|
|
|
|
' ===================== ROUTES =====================
|
|
package "routes" {
|
|
class AuthRoute <<utility>> {
|
|
+AuthRoute(r: *gin.Engine)
|
|
}
|
|
|
|
class EmpresaRoute <<utility>> {
|
|
+EmpresaRoute(r: *gin.Engine)
|
|
}
|
|
|
|
class GroupRoute <<utility>> {
|
|
+GroupRoute(r: *gin.Engine)
|
|
}
|
|
|
|
class LogsRoute <<utility>> {
|
|
+LogsRoute(r: *gin.Engine)
|
|
}
|
|
|
|
class MarcaRoute <<utility>> {
|
|
+MarcaRoute(r: *gin.Engine)
|
|
}
|
|
|
|
class PermisoRoute <<utility>> {
|
|
+PermisoRoute(r: *gin.Engine)
|
|
}
|
|
|
|
class PlataformaRoute <<utility>> {
|
|
+PlataformaRoute(r: *gin.Engine)
|
|
}
|
|
|
|
class RepuestoRoute <<utility>> {
|
|
+RepuestoRoute(r: *gin.Engine)
|
|
}
|
|
|
|
class UserRoute <<utility>> {
|
|
+UserRoute(r: *gin.Engine)
|
|
}
|
|
}
|
|
|
|
' ===================== CONTROLLERS =====================
|
|
package "controllers" {
|
|
class AuthController <<utility>> {
|
|
+Login(c: *gin.Context)
|
|
+Register(c: *gin.Context)
|
|
+Refresh(c: *gin.Context)
|
|
+Me(c: *gin.Context)
|
|
+ObtenerInvitacion(c: *gin.Context)
|
|
+AceptarInvitacion(c: *gin.Context)
|
|
+ObtenerMisEmpresas(c: *gin.Context)
|
|
+CambiarEmpresa(c: *gin.Context)
|
|
+CambiarContraseña(c: *gin.Context)
|
|
+ObtenerEmpresaActual(c: *gin.Context)
|
|
}
|
|
|
|
class EmpresaController <<utility>> {
|
|
+ObtenerMiembros(c: *gin.Context)
|
|
+ObtenerMiembro(c: *gin.Context)
|
|
+CrearMiembro(c: *gin.Context)
|
|
+ActualizarMiembro(c: *gin.Context)
|
|
+EliminarMiembro(c: *gin.Context)
|
|
+ListarInvitaciones(c: *gin.Context)
|
|
+CrearInvitacion(c: *gin.Context)
|
|
+EliminarInvitacion(c: *gin.Context)
|
|
+ActualizarEmpresa(c: *gin.Context)
|
|
}
|
|
|
|
class GrupoController <<utility>> {
|
|
+ObtenerGrupos(c: *gin.Context)
|
|
+ObtenerGrupo(c: *gin.Context)
|
|
+CrearGrupo(c: *gin.Context)
|
|
+ActualizarGrupo(c: *gin.Context)
|
|
+EliminarGrupo(c: *gin.Context)
|
|
+AgregarPermisoAGrupo(c: *gin.Context)
|
|
+QuitarPermisoAGrupo(c: *gin.Context)
|
|
+AgregarSubGrupo(c: *gin.Context)
|
|
+QuitarSubGrupo(c: *gin.Context)
|
|
+ObtenerGruposDeUsuario(c: *gin.Context)
|
|
+AgregarGrupoAUsuario(c: *gin.Context)
|
|
+QuitarGrupoAUsuario(c: *gin.Context)
|
|
+ObtenerGruposYPermisosPorEmail(c: *gin.Context)
|
|
}
|
|
|
|
class LogController <<utility>> {
|
|
+ObtenerLogs(c: *gin.Context)
|
|
+ObtenerLog(c: *gin.Context)
|
|
+BusquedaLogs(c: *gin.Context)
|
|
}
|
|
|
|
class MarcaController <<utility>> {
|
|
+ObtenerMarcas(c: *gin.Context)
|
|
+CrearMarca(c: *gin.Context)
|
|
+ActualizarMarca(c: *gin.Context)
|
|
+EliminarMarca(c: *gin.Context)
|
|
+AltaMarca(c: *gin.Context)
|
|
}
|
|
|
|
class PermisoController <<utility>> {
|
|
+ObtenerPermisos(c: *gin.Context)
|
|
+ObtenerPermisosUsuario(c: *gin.Context)
|
|
+CrearPermiso(c: *gin.Context)
|
|
+ActualizarPermiso(c: *gin.Context)
|
|
+EliminarPermiso(c: *gin.Context)
|
|
}
|
|
|
|
class PlataformaController <<utility>> {
|
|
+ListarEmpresas(c: *gin.Context)
|
|
+CrearEmpresa(c: *gin.Context)
|
|
+ActualizarEmpresa(c: *gin.Context)
|
|
+DesactivarEmpresa(c: *gin.Context)
|
|
+ListarAdmins(c: *gin.Context)
|
|
+AgregarAdmin(c: *gin.Context)
|
|
+QuitarAdmin(c: *gin.Context)
|
|
+ListarUsuarios(c: *gin.Context)
|
|
}
|
|
|
|
class RepuestoController <<utility>> {
|
|
+ObtenerRepuestos(c: *gin.Context)
|
|
+ObtenerRepuesto(c: *gin.Context)
|
|
+CrearRepuesto(c: *gin.Context)
|
|
+ActualizarRepuesto(c: *gin.Context)
|
|
+EliminarRepuesto(c: *gin.Context)
|
|
+AltaRepuestos(c: *gin.Context)
|
|
}
|
|
|
|
class UsuarioController <<utility>> {
|
|
+ObtenerUsuarios(c: *gin.Context)
|
|
+ObtenerUsuario(c: *gin.Context)
|
|
+CrearUsuario(c: *gin.Context)
|
|
+ActualizarUsuario(c: *gin.Context)
|
|
+EliminarUsuario(c: *gin.Context)
|
|
}
|
|
}
|
|
|
|
note bottom of AuthController
|
|
Cada clase controller agrupa los handlers
|
|
del paquete controllers/<dominio>.
|
|
end note
|
|
|
|
' ===================== DTO =====================
|
|
package "dto" {
|
|
class EmpresaResumen {
|
|
+ID: uint
|
|
+Nombre: string
|
|
+Slug: string
|
|
+Activa: bool
|
|
+Rol: string
|
|
}
|
|
|
|
class UsuarioResumen {
|
|
+ID: uint
|
|
+Email: string
|
|
+Name: string
|
|
+Activo: bool
|
|
+DebeCambiarPassword: bool
|
|
}
|
|
|
|
class AuthResponse {
|
|
+AccessToken: string
|
|
+RefreshToken: string
|
|
+TokenType: string
|
|
+ExpiresIn: int
|
|
+Permissions: []uint
|
|
+Empresa: *EmpresaResumen
|
|
+Empresas: []EmpresaResumen
|
|
+EmpresaRol: string
|
|
+EsPlataformaAdmin: bool
|
|
+Usuario: UsuarioResumen
|
|
+DebeCambiarPassword: bool
|
|
}
|
|
|
|
class TokenResponse {
|
|
+AccessToken: string
|
|
+RefreshToken: string
|
|
+TokenType: string
|
|
+ExpiresIn: int
|
|
+Permissions: []uint
|
|
}
|
|
|
|
class RegisterResponse {
|
|
+ID: uint
|
|
+Email: string
|
|
+Name: string
|
|
}
|
|
|
|
class MeResponse {
|
|
+ID: uint
|
|
+Email: string
|
|
+Name: string
|
|
+Permissions: []uint
|
|
+Empresa: *EmpresaResumen
|
|
+Empresas: []EmpresaResumen
|
|
+EmpresaRol: string
|
|
+EsPlataformaAdmin: bool
|
|
+Activo: bool
|
|
+DebeCambiarPassword: bool
|
|
}
|
|
|
|
class InvitacionInfo {
|
|
+Email: string
|
|
+Empresa: string
|
|
+EmpresaID: uint
|
|
+Rol: string
|
|
+ExpiraEn: time.Time
|
|
+Valida: bool
|
|
+Usada: bool
|
|
+Expirada: bool
|
|
+UsuarioExistente: bool
|
|
}
|
|
|
|
class MiembroResponse {
|
|
+ID: uint
|
|
+Email: string
|
|
+Name: string
|
|
+Activo: bool
|
|
+DebeCambiarPassword: bool
|
|
+Rol: string
|
|
+MembresiaActiva: bool
|
|
+CreatedAt: time.Time
|
|
+UpdatedAt: time.Time
|
|
}
|
|
|
|
class GrupoSimpleDTO {
|
|
+ID: uint
|
|
+Nombre: string
|
|
+Descripcion: string
|
|
+Imagen: string
|
|
+Permisos: []PermisoSimpleDTO
|
|
}
|
|
|
|
class PermisoSimpleDTO {
|
|
+Nombre: string
|
|
+Alias: string
|
|
+Imagen: string
|
|
}
|
|
|
|
class PermisosUsuarioResponse {
|
|
+Permisos: []string
|
|
}
|
|
|
|
class GruposYPermisosResponse {
|
|
+Email: string
|
|
+Groups: []GrupoSimpleDTO
|
|
}
|
|
}
|
|
|
|
package "dto/Logs" {
|
|
class BusquedaLogsDto {
|
|
+UsuarioID: uint
|
|
+Accion: string
|
|
+FechaInicio: time.Time
|
|
+FechaFin: time.Time
|
|
}
|
|
|
|
class LogTablaDto {
|
|
+ID: uint64
|
|
+UsuarioID: uint
|
|
+Accion: string
|
|
+Detalles: []LogDetalle
|
|
+CreatedAt: time.Time
|
|
}
|
|
}
|
|
|
|
package "dto/Repuestos" {
|
|
class CrearRepuestoDto {
|
|
+Nombre: string
|
|
+Descripcion: string
|
|
+Marca: uint
|
|
+Aliases: []string
|
|
+Precio: float64
|
|
+StockMinimo: int
|
|
}
|
|
|
|
class ActualizarRepuestoDto {
|
|
+ID: *uint64
|
|
+Nombre: string
|
|
+Descripcion: string
|
|
+Marca: uint
|
|
+Aliases: []string
|
|
+Precio: float64
|
|
+StockMinimo: int
|
|
}
|
|
}
|
|
|
|
' ===================== DTO / BUILDERS =====================
|
|
package "dto/Builders" {
|
|
interface "IBuilder<T>" as IBuilder {
|
|
+Build(): (*T, error)
|
|
}
|
|
|
|
class LogBuilder {
|
|
-log: Log
|
|
-error: error
|
|
--
|
|
+Uid(uid: uint)
|
|
+Accion(acc: string)
|
|
+AñadirDetalle(detalle: LogDetalle)
|
|
+AñadirDetalles(detalles: []LogDetalle)
|
|
+Build(): (*Log, error)
|
|
}
|
|
|
|
class LogDirector {
|
|
+Custom(uid: uint, accion: string, detalles: []LogDetalle): (*Log, error)
|
|
+Crear(uid: uint, tabla: string, entidad: any): (*Log, error)
|
|
+Modificar(uid: uint, tabla: string, anterior, nuevo: any): (*Log, error)
|
|
+Eliminar(uid: uint, tabla: string, id: any): (*Log, error)
|
|
+Baja(uid: uint, tabla: string, id: any): (*Log, error)
|
|
+Alta(uid: uint, tabla: string, id: any): (*Log, error)
|
|
}
|
|
|
|
class RepuestoBuilder {
|
|
-dto: *CrearRepuestoDto
|
|
-marcaID: uint
|
|
--
|
|
+ConDto(dto: CrearRepuestoDto): *RepuestoBuilder
|
|
+ConMarca(marcaID: uint): *RepuestoBuilder
|
|
+Build(): Repuesto
|
|
}
|
|
|
|
class ActualizarRepuestoBuilder {
|
|
-dto: *ActualizarRepuestoDto
|
|
-marcaID: uint
|
|
--
|
|
+ConDto(dto: ActualizarRepuestoDto): *ActualizarRepuestoBuilder
|
|
+ConMarca(marcaID: uint): *ActualizarRepuestoBuilder
|
|
+Build(): Repuesto
|
|
}
|
|
|
|
class GrupoSimpleBuilder {
|
|
-grupo: *Grupo
|
|
--
|
|
+Build(): GrupoSimpleDTO
|
|
}
|
|
|
|
class LogTablaBuilder {
|
|
-logs: []Log
|
|
--
|
|
+ConLogs(logs: []Log): *LogTablaBuilder
|
|
+Build(): []LogTablaDto
|
|
}
|
|
}
|
|
|
|
' ===================== MODELS =====================
|
|
package "models" {
|
|
class Comprobante {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+Estado: string
|
|
+Total: float64
|
|
+ResponsableID: uint
|
|
+Responsable: Usuario
|
|
}
|
|
|
|
class Almacen {
|
|
+ID: uint
|
|
+EmpresaID: uint
|
|
+Codigo: string
|
|
+Ubicacion: string
|
|
+Stocks: []Stock
|
|
}
|
|
|
|
class Marca {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+Nombre: string
|
|
+Repuestos: []Repuesto
|
|
}
|
|
|
|
class Repuesto {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+Nombre: string
|
|
+Precio: float64
|
|
+StockMinimo: int64
|
|
+Descripcion: string
|
|
+MarcaID: uint
|
|
+Marca: Marca
|
|
+Aliases: []string
|
|
+Stocks: []Stock
|
|
}
|
|
|
|
class Stock {
|
|
+ID: uint64
|
|
+EmpresaID: uint64
|
|
+Cantidad: uint
|
|
+CantidadReservada: uint
|
|
+RepuestoID: uint64
|
|
+Repuesto: Repuesto
|
|
+AlmacenID: uint
|
|
+Almacen: Almacen
|
|
+Observacion: string
|
|
+Movmientos: []MovimientoStock
|
|
}
|
|
|
|
class MovimientoStock {
|
|
+Fecha: time.Time
|
|
+Tipo: string
|
|
+Cantidad: float64
|
|
+UsuarioID: uint
|
|
}
|
|
|
|
class Cliente {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+Nombre: string
|
|
+Cuit: string
|
|
+Email: sql.NullString
|
|
+Facturas: []Factura
|
|
+Recibos: []Recibo
|
|
}
|
|
|
|
class Proveedor {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+Nombre: string
|
|
+Facturas: []Factura
|
|
}
|
|
|
|
class Factura {
|
|
+ClienteID: uint
|
|
+Cliente: Cliente
|
|
+ProveedorID: *uint
|
|
+Proveedor: *Proveedor
|
|
+SeAviso: bool
|
|
+Detalles: []FacturaDetalle
|
|
}
|
|
|
|
class FacturaDetalle {
|
|
+RepuestoID: uint64
|
|
+Cantidad: uint
|
|
+DescuentoID: uint
|
|
+Descuento: float64
|
|
+PrecioUnitario: float64
|
|
+Subtotal: float64
|
|
}
|
|
|
|
class OrdenCompra {
|
|
+Proveedor: Proveedor
|
|
+ProveedorID: uint
|
|
+Detalles: []OrdenCompraDetalle
|
|
}
|
|
|
|
class OrdenCompraDetalle {
|
|
+RepuestoID: uint64
|
|
+Cantidad: uint
|
|
+PrecioUnitario: float64
|
|
+Subtotal: float64
|
|
}
|
|
|
|
class Recibo {
|
|
+ClienteID: uint
|
|
+Cliente: Cliente
|
|
+Pagos: []Pago
|
|
}
|
|
|
|
class Pago {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+FormaDePagoID: uint
|
|
+FormaDePago: FormaDePago
|
|
+ReciboID: uint
|
|
+Recibo: Recibo
|
|
+Importe: float64
|
|
}
|
|
|
|
class FormaDePago {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+Descripcion: string
|
|
}
|
|
|
|
class Descuento {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+Nombre: string
|
|
+Descripcion: string
|
|
+Tipo: TipoDescuento
|
|
+Valor: float64
|
|
+Activo: bool
|
|
}
|
|
|
|
class TipoDescuento <<enumeration>> {
|
|
PORCENTAJE
|
|
FIJO
|
|
}
|
|
|
|
class Reserva {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+RepuestoID: uint
|
|
+Repuesto: Repuesto
|
|
+AlmacenID: uint
|
|
+Almacen: Almacen
|
|
+Cantidad: float64
|
|
+Estado: EstadoReserva
|
|
+ClienteID: *uint
|
|
+Cliente: *Cliente
|
|
+FechaVencimiento: time.Time
|
|
}
|
|
|
|
class EstadoReserva <<enumeration>> {
|
|
activa
|
|
vencida
|
|
liberada
|
|
consumida
|
|
}
|
|
|
|
class Remito {
|
|
+FechaEmision: time.Time
|
|
+TipoOperacion: TipoOperacion
|
|
+EmisorID: uint
|
|
+ReceptorID: uint
|
|
+AlmacenOrigenID: *uint
|
|
+AlmacenOrigen: *Almacen
|
|
+Detalles: []RemitoDetalle
|
|
}
|
|
|
|
class RemitoDetalle {
|
|
+ProductoID: uint
|
|
+CantidadEsperada: float64
|
|
+CantidadRecibida: float64
|
|
+UnidadMedida: string
|
|
+Observacion: string
|
|
}
|
|
|
|
class TipoOperacion <<enumeration>> {
|
|
COMPRA
|
|
VENTA
|
|
MOVIMIENTO
|
|
}
|
|
|
|
class Devolucion {
|
|
+Motivo: string
|
|
+FacturaOrigen: Factura
|
|
+FacturaOrigenID: uint
|
|
}
|
|
|
|
class NotaCredito {
|
|
+Motivo: string
|
|
+FacturaOrigen: Factura
|
|
+FacturaOrigenID: uint
|
|
}
|
|
|
|
class NotaDebito {
|
|
+Motivo: string
|
|
+FacturaOrigen: Factura
|
|
+FacturaOrigenID: uint
|
|
}
|
|
}
|
|
|
|
' ===================== MODELS / SEGURIDAD (COMPOSITE) =====================
|
|
package "models/seguridad" {
|
|
interface IPermisosComponent {
|
|
+Buscar(id: uint): bool
|
|
+ListarPermisos(permisos: map[uint]Permiso)
|
|
}
|
|
|
|
class Permiso {
|
|
+ID: uint
|
|
+Nombre: string
|
|
+Alias: string
|
|
+Descripcion: string
|
|
+Imagen: string
|
|
+CreatedAt: time.Time
|
|
+UpdatedAt: time.Time
|
|
+DeletedAt: gorm.DeletedAt
|
|
--
|
|
+Buscar(id: uint): bool
|
|
+ListarPermisos(permisos: map[uint]Permiso)
|
|
}
|
|
|
|
class Grupo {
|
|
+ID: uint
|
|
+EmpresaID: uint
|
|
+Nombre: string
|
|
+Descripcion: string
|
|
+Imagen: string
|
|
+Permisos: []Permiso
|
|
+Grupos: []Grupo
|
|
+Usuarios: []Usuario
|
|
+CreatedAt: time.Time
|
|
+UpdatedAt: time.Time
|
|
+DeletedAt: gorm.DeletedAt
|
|
--
|
|
+Buscar(id: uint): bool
|
|
+ListarPermisos(permisos: map[uint]Permiso)
|
|
}
|
|
|
|
class Usuario {
|
|
+ID: uint
|
|
+Email: string
|
|
+Password: string
|
|
+Name: string
|
|
+Activo: bool
|
|
+DebeCambiarPassword: bool
|
|
+Grupos: []Grupo
|
|
+Empresas: []Empresa
|
|
+CreatedAt: time.Time
|
|
+UpdatedAt: time.Time
|
|
+DeletedAt: gorm.DeletedAt
|
|
}
|
|
|
|
class Empresa {
|
|
+ID: uint
|
|
+Nombre: string
|
|
+Slug: string
|
|
+Cuit: *string
|
|
+Activa: bool
|
|
+CreatedAt: time.Time
|
|
+UpdatedAt: time.Time
|
|
+DeletedAt: gorm.DeletedAt
|
|
}
|
|
|
|
class EmpresaUsuario {
|
|
+EmpresaID: uint
|
|
+UsuarioID: uint
|
|
+Rol: RolEmpresa
|
|
+Activo: bool
|
|
+CreatedAt: time.Time
|
|
+UpdatedAt: time.Time
|
|
+Empresa: Empresa
|
|
+Usuario: Usuario
|
|
}
|
|
|
|
class PlataformaAdmin {
|
|
+UsuarioID: uint
|
|
+Rol: RolPlataforma
|
|
+Activo: bool
|
|
+CreatedAt: time.Time
|
|
+UpdatedAt: time.Time
|
|
+Usuario: Usuario
|
|
}
|
|
|
|
class InvitacionEmpresa {
|
|
+ID: uint
|
|
+EmpresaID: uint
|
|
+Email: string
|
|
+Rol: RolEmpresa
|
|
+GrupoID: uint
|
|
+TokenHash: string
|
|
+ExpiraEn: time.Time
|
|
+UsadaEn: *time.Time
|
|
+CreadaPor: uint
|
|
+CreatedAt: time.Time
|
|
+Empresa: Empresa
|
|
}
|
|
|
|
enum RolEmpresa {
|
|
OWNER
|
|
ADMIN
|
|
MEMBER
|
|
}
|
|
|
|
enum RolPlataforma {
|
|
SUPERADMIN
|
|
SOPORTE
|
|
}
|
|
}
|
|
|
|
' ===================== MODELS / CONTABILIDAD =====================
|
|
package "models/contabilidad" {
|
|
class AsientoContable {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+ComprobanteTipo: string
|
|
+ComprobanteID: uint
|
|
+Movimientos: []MovimientoContable
|
|
}
|
|
|
|
class CuentaContable {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+Nombre: string
|
|
+Tipo: string
|
|
+Movimientos: []MovimientoContable
|
|
}
|
|
|
|
class MovimientoContable {
|
|
+ID: uint (gorm.Model)
|
|
+EmpresaID: uint
|
|
+AsientoID: uint
|
|
+Asiento: AsientoContable
|
|
+CuentaID: uint
|
|
+Cuenta: CuentaContable
|
|
+Debe: float64
|
|
+Haber: float64
|
|
+Descripcion: string
|
|
}
|
|
}
|
|
|
|
' ===================== MODELS / LOGS =====================
|
|
package "models/logs" {
|
|
class Log {
|
|
+ID: uint64
|
|
+EmpresaID: uint
|
|
+UsuarioID: uint
|
|
+Accion: string
|
|
+Detalles: []LogDetalle
|
|
+CreatedAt: time.Time
|
|
+Usuario: Usuario
|
|
}
|
|
|
|
class LogDetalle {
|
|
+ID: uint
|
|
+NombreTabla: string
|
|
+Columna: string
|
|
+ValorAnterior: string
|
|
+ValorNuevo: string
|
|
}
|
|
}
|
|
|
|
' ===================== REPOSITORIOS =====================
|
|
package "repositorios" {
|
|
interface "IRepositorio<T>" as IRepositorio {
|
|
+Guardar(entidad: *T): error
|
|
+ObtenerTodos(): ([]T, error)
|
|
+ObtenerPorID(id: uint): (*T, error)
|
|
+Crear(entidad: T, usuarioID: uint): error
|
|
+Actualizar(entidad: *T, input: T, usuarioID: uint): error
|
|
+Eliminar(id: uint, usuarioID: uint): error
|
|
+Baja(id: uint, usuarioID: uint): error
|
|
+Alta(entidad: *T, input: T, usuarioID: uint): error
|
|
}
|
|
|
|
class "RepositorioBase<T>" as RepositorioBase {
|
|
-db: *gorm.DB
|
|
-empresaID: uint
|
|
--
|
|
+Guardar(entidad: *T): error
|
|
+ObtenerTodos(): ([]T, error)
|
|
+ObtenerPorID(id: uint): (*T, error)
|
|
+Crear(entidad: T, usuarioID: uint): error
|
|
+Actualizar(entidad: *T, input: T, usuarioID: uint): error
|
|
+Eliminar(id: uint, usuarioID: uint): error
|
|
+Baja(id: uint, usuarioID: uint): error
|
|
+Alta(entidad: *T, input: T, usuarioID: uint): error
|
|
}
|
|
|
|
interface RepositorioMarcas {
|
|
+IRepositorio[Marca]
|
|
+CrearFaltante(marca: Marca): error
|
|
+ObtenerPorNombre(nombre: string): (*Marca, error)
|
|
}
|
|
|
|
class repositorioMarcas {
|
|
-RepositorioBase[Marca]
|
|
-db: *gorm.DB
|
|
-empresaID: uint
|
|
}
|
|
|
|
interface RepositorioRepuesto {
|
|
+IRepositorio[*Repuesto]
|
|
+AltaRepuesto(id: uint, uid: uint): (*Repuesto, error)
|
|
+ObtenerTodosConMarca(): ([]*Repuesto, error)
|
|
}
|
|
|
|
class repositorioRepuesto {
|
|
-RepositorioBase[*Repuesto]
|
|
-db: *gorm.DB
|
|
-empresaID: uint
|
|
}
|
|
|
|
interface RepositorioLogs {
|
|
+IRepositorio[*Log]
|
|
+ObtenerPorPaginas(pag: uint): ([]Log, error)
|
|
+CantPaginas(): (int64, error)
|
|
+ObtenerConFiltros(p: int, f: BusquedaLogsDto): ([]Log, error)
|
|
+CantPaginasConFiltros(f: BusquedaLogsDto): (int64, error)
|
|
}
|
|
|
|
class repositorioLogs {
|
|
-RepositorioBase[*Log]
|
|
-db: *gorm.DB
|
|
-empresaID: uint
|
|
}
|
|
|
|
interface RepositorioGrupo {
|
|
+ObtenerTodosConRelaciones(): ([]Grupo, error)
|
|
+ObtenerPorIDConRelaciones(id: uint, simple: bool): (*Grupo, error)
|
|
+ObtenerPorID(id: uint): (*Grupo, error)
|
|
+Crear(grupo: *Grupo): error
|
|
+Actualizar(grupo: *Grupo, input: Grupo): error
|
|
+Eliminar(id: uint): error
|
|
+AgregarPermiso(grupoID, permisoID: uint): error
|
|
+QuitarPermiso(grupoID, permisoID: uint): error
|
|
+AgregarSubGrupo(padreID, hijoID: uint): error
|
|
+QuitarSubGrupo(padreID, hijoID: uint): error
|
|
}
|
|
|
|
class repositorioGrupo {
|
|
-db: *gorm.DB
|
|
-empresaID: uint
|
|
}
|
|
|
|
interface RepositorioPermiso {
|
|
+ObtenerTodos(): ([]Permiso, error)
|
|
+ObtenerPorID(id: uint): (*Permiso, error)
|
|
+Crear(permiso: *Permiso): error
|
|
+Actualizar(permiso: *Permiso, input: Permiso): error
|
|
+Eliminar(id: uint): error
|
|
}
|
|
|
|
class repositorioPermiso {
|
|
-db: *gorm.DB
|
|
}
|
|
|
|
interface RepositorioUsuario {
|
|
+ObtenerPorID(id: uint): (*Usuario, error)
|
|
+ObtenerPorEmail(email: string): (*Usuario, error)
|
|
+Crear(usuario: *Usuario): error
|
|
+ActualizarContraseña(id: uint, hashedPassword: string, debeCambiar: bool): error
|
|
+ObtenerTodosPaginado(pagina, tamaño: int): ([]Usuario, int64, error)
|
|
+ListarGlobales(pagina, tamaño: int): ([]Usuario, int64, error)
|
|
+Guardar(usuario: *Usuario): error
|
|
+Eliminar(id: uint): error
|
|
+ObtenerMembresia(usuarioID: uint): (*EmpresaUsuario, error)
|
|
+ObtenerEmpresasDeUsuario(usuarioID: uint): ([]Empresa, error)
|
|
+EsMiembro(usuarioID: uint): (bool, error)
|
|
+CantidadMiembros(): (int64, error)
|
|
+PrecargarGruposPermisosPorID(id: uint): (*Usuario, error)
|
|
+PrecargarGruposPermisosDeEmpresa(usuarioID, empresaID: uint): (*Usuario, error)
|
|
+ObtenerPorEmailConGrupos(email: string): (*Usuario, error)
|
|
+ObtenerGruposPorUsuarioID(usuarioID: uint): ([]Grupo, error)
|
|
+AgregarGrupoAUsuario(usuarioID, grupoID: uint): error
|
|
+QuitarGrupoDeUsuario(usuarioID, grupoID: uint): error
|
|
}
|
|
|
|
class repositorioUsuario {
|
|
-db: *gorm.DB
|
|
-empresaID: uint
|
|
}
|
|
|
|
interface RepositorioEmpresa {
|
|
+ObtenerPorID(id: uint): (*Empresa, error)
|
|
+ObtenerPorSlug(slug: string): (*Empresa, error)
|
|
+ListarTodas(): ([]Empresa, error)
|
|
+ListarDeUsuario(usuarioID: uint): ([]Empresa, error)
|
|
+Crear(empresa: *Empresa, ownerID: uint): error
|
|
+Actualizar(empresa: *Empresa, input: Empresa): error
|
|
+Guardar(empresa: *Empresa): error
|
|
+Desactivar(id: uint): error
|
|
+Membresia(empresaID, usuarioID: uint): (*EmpresaUsuario, error)
|
|
+ListarMiembros(empresaID: uint, pagina, tamano: int): ([]EmpresaUsuario, int64, error)
|
|
+AgregarMiembro(empresaID, usuarioID: uint, rol: RolEmpresa, grupoID: uint): error
|
|
+ActualizarRolMiembro(empresaID, usuarioID: uint, rol: RolEmpresa): error
|
|
+DesactivarMiembro(empresaID, usuarioID: uint): error
|
|
+EliminarMiembro(empresaID, usuarioID: uint): error
|
|
+ContarMiembros(empresaID: uint): (int64, error)
|
|
+ContarOwners(empresaID: uint): (int64, error)
|
|
+AsignarGrupoBase(empresaID, usuarioID: uint, rol: RolEmpresa): error
|
|
+CrearInvitacion(invitacion: *InvitacionEmpresa): (string, error)
|
|
+ListarInvitaciones(empresaID: uint): ([]InvitacionEmpresa, error)
|
|
+ObtenerInvitacionPorToken(token: string): (*InvitacionEmpresa, error)
|
|
+MarcarInvitacionUsada(id: uint): error
|
|
+EliminarInvitacion(empresaID, id: uint): error
|
|
+PlataformaAdminDe(usuarioID: uint): (*PlataformaAdmin, error)
|
|
+ListarPlataformaAdmins(): ([]PlataformaAdmin, error)
|
|
+ContarPlataformaAdmins(): (int64, error)
|
|
+AgregarPlataformaAdmin(usuarioID: uint, rol: RolPlataforma): error
|
|
+QuitarPlataformaAdmin(usuarioID: uint): error
|
|
}
|
|
|
|
class repositorioEmpresa {
|
|
-db: *gorm.DB
|
|
}
|
|
|
|
class Repositorios {
|
|
+Permiso: RepositorioPermiso
|
|
+Usuario: RepositorioUsuario
|
|
+Grupo: RepositorioGrupo
|
|
+Repuesto: RepositorioRepuesto
|
|
+Marca: RepositorioMarcas
|
|
+Logs: RepositorioLogs
|
|
+Empresa: RepositorioEmpresa
|
|
}
|
|
}
|
|
|
|
' ===================== RELACIONES: ROUTES / CONTROLLERS / MAIN =====================
|
|
AuthRoute ..> AuthController
|
|
AuthRoute ..> EmpresaController
|
|
EmpresaRoute ..> EmpresaController
|
|
GroupRoute ..> GrupoController
|
|
LogsRoute ..> LogController
|
|
MarcaRoute ..> MarcaController
|
|
PermisoRoute ..> PermisoController
|
|
PlataformaRoute ..> PlataformaController
|
|
RepuestoRoute ..> RepuestoController
|
|
UserRoute ..> EmpresaController
|
|
UserRoute ..> GrupoController
|
|
|
|
Main ..> AuthRoute
|
|
Main ..> EmpresaRoute
|
|
Main ..> GroupRoute
|
|
Main ..> LogsRoute
|
|
Main ..> MarcaRoute
|
|
Main ..> PermisoRoute
|
|
Main ..> PlataformaRoute
|
|
Main ..> RepuestoRoute
|
|
Main ..> UserRoute
|
|
Main ..> Repositorios
|
|
|
|
note bottom of Main
|
|
Inicializa la base, ejecuta AutoMigrate
|
|
de todos los models y registra las rutas.
|
|
end note
|
|
|
|
' ===================== RELACIONES: CONTROLLERS =====================
|
|
AuthController ..> RepositorioUsuario
|
|
AuthController ..> RepositorioEmpresa
|
|
AuthController ..> AuthResponse
|
|
AuthController ..> Usuario
|
|
AuthController ..> Empresa
|
|
|
|
EmpresaController ..> RepositorioEmpresa
|
|
EmpresaController ..> RepositorioUsuario
|
|
EmpresaController ..> RepositorioGrupo
|
|
EmpresaController ..> MiembroResponse
|
|
EmpresaController ..> EmpresaUsuario
|
|
EmpresaController ..> InvitacionEmpresa
|
|
|
|
GrupoController ..> RepositorioGrupo
|
|
GrupoController ..> RepositorioUsuario
|
|
GrupoController ..> RepositorioPermiso
|
|
GrupoController ..> GrupoSimpleDTO
|
|
GrupoController ..> Grupo
|
|
GrupoController ..> Permiso
|
|
GrupoController ..> Usuario
|
|
|
|
LogController ..> RepositorioLogs
|
|
LogController ..> LogTablaDto
|
|
LogController ..> BusquedaLogsDto
|
|
LogController ..> Log
|
|
|
|
MarcaController ..> RepositorioMarcas
|
|
MarcaController ..> Marca
|
|
|
|
PermisoController ..> RepositorioPermiso
|
|
PermisoController ..> Permiso
|
|
PermisoController ..> PermisosUsuarioResponse
|
|
|
|
PlataformaController ..> RepositorioEmpresa
|
|
PlataformaController ..> RepositorioUsuario
|
|
PlataformaController ..> Empresa
|
|
PlataformaController ..> PlataformaAdmin
|
|
PlataformaController ..> Usuario
|
|
|
|
RepuestoController ..> RepositorioRepuesto
|
|
RepuestoController ..> RepositorioMarcas
|
|
RepuestoController ..> RepuestoBuilder
|
|
RepuestoController ..> ActualizarRepuestoBuilder
|
|
RepuestoController ..> CrearRepuestoDto
|
|
RepuestoController ..> ActualizarRepuestoDto
|
|
RepuestoController ..> Repuesto
|
|
|
|
UsuarioController ..> RepositorioUsuario
|
|
UsuarioController ..> Usuario
|
|
|
|
' ===================== RELACIONES: DTO =====================
|
|
AuthResponse --> EmpresaResumen
|
|
AuthResponse --> UsuarioResumen
|
|
MeResponse --> EmpresaResumen
|
|
GruposYPermisosResponse --> GrupoSimpleDTO
|
|
GrupoSimpleDTO --> PermisoSimpleDTO
|
|
LogTablaDto --> LogDetalle
|
|
InvitacionInfo ..> InvitacionEmpresa : datos
|
|
InvitacionInfo ..> Empresa : datos
|
|
MiembroResponse ..> Usuario : datos
|
|
MiembroResponse ..> EmpresaUsuario : membresía
|
|
RegisterResponse ..> Usuario : datos
|
|
MeResponse ..> Usuario : datos
|
|
AuthResponse ..> Usuario : datos
|
|
|
|
EmpresaResumen ..> Empresa : resume
|
|
UsuarioResumen ..> Usuario : resume
|
|
GrupoSimpleDTO ..> Grupo : resume
|
|
PermisoSimpleDTO ..> Permiso : resume
|
|
LogTablaDto ..> Log : resume
|
|
|
|
' ===================== RELACIONES: BUILDERS =====================
|
|
LogBuilder ..|> IBuilder
|
|
|
|
LogBuilder ..> Log
|
|
LogBuilder ..> LogDetalle
|
|
LogDirector ..> LogBuilder : construye
|
|
LogDirector ..> Log
|
|
LogDirector ..> LogDetalle
|
|
|
|
RepuestoBuilder ..> CrearRepuestoDto : input
|
|
RepuestoBuilder ..> Repuesto : output
|
|
ActualizarRepuestoBuilder ..> ActualizarRepuestoDto : input
|
|
ActualizarRepuestoBuilder ..> Repuesto : output
|
|
|
|
GrupoSimpleBuilder ..> Grupo : input
|
|
GrupoSimpleBuilder ..> Permiso
|
|
GrupoSimpleBuilder ..> GrupoSimpleDTO : output
|
|
GrupoSimpleBuilder ..> PermisoSimpleDTO : output
|
|
|
|
LogTablaBuilder ..> Log : input
|
|
LogTablaBuilder ..> LogTablaDto : output
|
|
|
|
note right of IBuilder
|
|
Patrón Builder.
|
|
Solo LogBuilder implementa IBuilder<T>;
|
|
los demás builders exponen su propio Build().
|
|
end note
|
|
|
|
' ===================== RELACIONES: REPOSITORIOS =====================
|
|
RepositorioBase ..|> IRepositorio
|
|
repositorioMarcas ..|> RepositorioMarcas
|
|
repositorioRepuesto ..|> RepositorioRepuesto
|
|
repositorioLogs ..|> RepositorioLogs
|
|
repositorioGrupo ..|> RepositorioGrupo
|
|
repositorioPermiso ..|> RepositorioPermiso
|
|
repositorioUsuario ..|> RepositorioUsuario
|
|
repositorioEmpresa ..|> RepositorioEmpresa
|
|
|
|
repositorioMarcas *-- RepositorioBase : embebe
|
|
repositorioRepuesto *-- RepositorioBase : embebe
|
|
repositorioLogs *-- RepositorioBase : embebe
|
|
|
|
Repositorios *-- RepositorioPermiso
|
|
Repositorios *-- RepositorioUsuario
|
|
Repositorios *-- RepositorioGrupo
|
|
Repositorios *-- RepositorioRepuesto
|
|
Repositorios *-- RepositorioMarcas
|
|
Repositorios *-- RepositorioLogs
|
|
Repositorios *-- RepositorioEmpresa
|
|
|
|
RepositorioBase ..> LogDirector : audita
|
|
RepositorioBase ..> Log
|
|
RepositorioMarcas ..> Marca
|
|
RepositorioRepuesto ..> Repuesto
|
|
RepositorioRepuesto ..> LogDirector : auditoría de alta
|
|
RepositorioLogs ..> Log
|
|
RepositorioLogs ..> BusquedaLogsDto : filtros
|
|
RepositorioGrupo ..> Grupo
|
|
RepositorioGrupo ..> Permiso
|
|
RepositorioPermiso ..> Permiso
|
|
RepositorioUsuario ..> Usuario
|
|
RepositorioUsuario ..> Grupo
|
|
RepositorioUsuario ..> Empresa
|
|
RepositorioUsuario ..> EmpresaUsuario
|
|
RepositorioEmpresa ..> Empresa
|
|
RepositorioEmpresa ..> EmpresaUsuario
|
|
RepositorioEmpresa ..> InvitacionEmpresa
|
|
RepositorioEmpresa ..> PlataformaAdmin
|
|
RepositorioEmpresa ..> RolEmpresa
|
|
RepositorioEmpresa ..> RolPlataforma
|
|
|
|
' ===================== RELACIONES: MODELS =====================
|
|
Permiso ..|> IPermisosComponent
|
|
Grupo ..|> IPermisosComponent
|
|
|
|
Grupo "1" o-- "0..*" Permiso : permisos
|
|
Grupo "1" o-- "0..*" Grupo : subgrupos
|
|
Grupo "0..*" -- "0..*" Usuario : usuarios_grupos
|
|
Usuario "0..*" -- "0..*" Empresa : empresa_usuarios
|
|
Empresa "1" -- "0..*" EmpresaUsuario
|
|
Empresa "1" -- "0..*" InvitacionEmpresa
|
|
Usuario "1" -- "0..*" PlataformaAdmin
|
|
Usuario "1" -- "0..*" Log
|
|
Grupo --> Empresa : empresaID
|
|
EmpresaUsuario --> Empresa
|
|
EmpresaUsuario --> Usuario
|
|
PlataformaAdmin --> Usuario
|
|
InvitacionEmpresa ..> Grupo : grupoID
|
|
|
|
note right of Grupo
|
|
Composite: contiene permisos (hojas)
|
|
y otros grupos (subgrupos).
|
|
end note
|
|
|
|
note right of Permiso
|
|
Leaf del patrón Composite.
|
|
end note
|
|
|
|
Comprobante <|-- Factura
|
|
Comprobante <|-- Devolucion
|
|
Comprobante <|-- NotaCredito
|
|
Comprobante <|-- NotaDebito
|
|
Comprobante <|-- OrdenCompra
|
|
Comprobante <|-- Recibo
|
|
Comprobante <|-- Remito
|
|
|
|
Marca "1" -- "0..*" Repuesto
|
|
Repuesto "1" -- "0..*" Stock
|
|
Almacen "1" -- "0..*" Stock
|
|
Repuesto "1" -- "0..*" FacturaDetalle : json
|
|
Repuesto "1" -- "0..*" OrdenCompraDetalle : json
|
|
Stock "1" -- "0..*" MovimientoStock : json
|
|
Remito "1" -- "0..*" RemitoDetalle : json
|
|
|
|
Cliente "1" -- "0..*" Factura
|
|
Cliente "1" -- "0..*" Recibo
|
|
Proveedor "0..1" -- "0..*" Factura
|
|
Proveedor "1" -- "0..*" OrdenCompra
|
|
Factura "1" -- "0..*" FacturaDetalle
|
|
OrdenCompra "1" -- "0..*" OrdenCompraDetalle
|
|
Recibo "1" -- "0..*" Pago
|
|
FormaDePago "1" -- "0..*" Pago
|
|
|
|
Reserva "0..*" -- "1" Repuesto
|
|
Reserva "0..*" -- "1" Almacen
|
|
Reserva "0..*" -- "0..1" Cliente
|
|
Remito "0..*" -- "0..1" Almacen : almacen origen
|
|
|
|
AsientoContable "1" -- "0..*" MovimientoContable
|
|
CuentaContable "1" -- "0..*" MovimientoContable
|
|
MovimientoContable "0..*" -- "1" AsientoContable
|
|
MovimientoContable "0..*" -- "1" CuentaContable
|
|
|
|
Log "1" -- "0..*" LogDetalle : json
|
|
|
|
Comprobante --> Usuario : responsable
|
|
Devolucion --> Factura : factura origen
|
|
NotaCredito --> Factura : factura origen
|
|
NotaDebito --> Factura : factura origen
|
|
FacturaDetalle ..> Descuento : descuentoID
|
|
RemitoDetalle ..> Repuesto : productoID
|
|
MovimientoStock ..> Usuario : usuarioID
|
|
Remito ..> Usuario : emisor / receptor
|
|
|
|
AsientoContable ..> Comprobante : ComprobanteTipo + ComprobanteID
|
|
AsientoContable ..> Factura
|
|
AsientoContable ..> Recibo
|
|
AsientoContable ..> OrdenCompra
|
|
AsientoContable ..> Remito
|
|
AsientoContable ..> NotaCredito
|
|
AsientoContable ..> NotaDebito
|
|
AsientoContable ..> Devolucion
|
|
|
|
Descuento --> TipoDescuento
|
|
Reserva --> EstadoReserva
|
|
Remito --> TipoOperacion
|
|
EmpresaUsuario --> RolEmpresa
|
|
InvitacionEmpresa --> RolEmpresa
|
|
PlataformaAdmin --> RolPlataforma
|
|
|
|
note bottom of AsientoContable
|
|
Relación polimórfica sin FK en GORM:
|
|
ComprobanteTipo indica el subtipo y
|
|
ComprobanteID el registro concreto.
|
|
end note
|
|
|
|
note bottom of Empresa
|
|
Todos los modelos de negocio usan EmpresaID
|
|
como discriminador del tenant.
|
|
end note
|
|
|
|
@enduml
|
|
```
|