Private
Public Access
añadida entidad de log
This commit is contained in:
1 parent
7cadb9c84b
commit
5fa3fd7cc5
2 files changed
+31
No files matched your search
@@ -0,0 +1,29 @@
|
|||||||
|
package logs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
models_seguridad "repuestera_back/models/seguridad"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LogDetalle struct {
|
||||||
|
NombreTabla string `json:"nombreTabla"`
|
||||||
|
Columna string `json:"columna"`
|
||||||
|
ValorAnterior string `json:"valorAnterior,omitempty"`
|
||||||
|
ValorNuevo string `json:"valorNuevo,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Log struct {
|
||||||
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||||
|
EmpresaID string `gorm:"type:varchar(3);index;not null" json:"empresaId"`
|
||||||
|
UsuarioID uint `gorm:"index;not null" json:"usuarioId"`
|
||||||
|
Accion string `gorm:"type:varchar(50);not null" json:"accion"`
|
||||||
|
Detalles []LogDetalle `gorm:"type:json" json:"detalles,omitempty"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
Empresa models_seguridad.Empresa `gorm:"foreignKey:EmpresaID" json:"empresa,omitempty"`
|
||||||
|
Usuario models_seguridad.Usuario `gorm:"foreignKey:UsuarioID" json:"usuario,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Log) TableName() string {
|
||||||
|
return "logs"
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"repuestera_back/config"
|
"repuestera_back/config"
|
||||||
"repuestera_back/models"
|
"repuestera_back/models"
|
||||||
models_seguridad "repuestera_back/models/seguridad"
|
models_seguridad "repuestera_back/models/seguridad"
|
||||||
|
"repuestera_back/models/logs"
|
||||||
"repuestera_back/routes"
|
"repuestera_back/routes"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -31,6 +32,7 @@ func main() {
|
|||||||
&models.Stock{},
|
&models.Stock{},
|
||||||
&models.Factura{},
|
&models.Factura{},
|
||||||
&models.OrdenCompra{},
|
&models.OrdenCompra{},
|
||||||
|
&logs.Log{},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
log.Fatalf("failed to migrate database: %v", err)
|
log.Fatalf("failed to migrate database: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user