Private
Public Access
avance creando entidades
This commit is contained in:
1 parent
1d755376f6
commit
7cadb9c84b
25 files changed
+200
-47
No files matched your search
@@ -0,0 +1,13 @@
|
||||
package models_seguridad
|
||||
|
||||
type Empresa struct {
|
||||
ID string `gorm:"primaryKey;type:varchar(3)" json:"id"`
|
||||
Razon string `gorm:"uniqueIndex;not null;type:varchar(70)" json:"razon"`
|
||||
Direccion string `gorm:"type:text" json:"direccion,omitempty"`
|
||||
Telefono string `gorm:"type:varchar(20)" json:"telefono,omitempty"`
|
||||
Email string `gorm:"type:varchar(100)" json:"email,omitempty"`
|
||||
}
|
||||
|
||||
func (Empresa) TableName() string {
|
||||
return "empresa"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package models_seguridad
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Grupo struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Nombre string `gorm:"uniqueIndex;not null;type:varchar(100)" json:"nombre"`
|
||||
Descripcion string `gorm:"type:text" json:"descripcion"`
|
||||
Permisos []Permiso `gorm:"many2many:group_permissions;" json:"permisos,omitempty"`
|
||||
Grupos []Grupo `gorm:"many2many:group_groups;joinForeignKey:ParentGroupID;joinReferences:ChildGroupID" json:"grupos_hijos,omitempty"`
|
||||
Usuarios []Usuario `gorm:"many2many:user_groups;" json:"usuarios,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
func (Grupo) TableName() string {
|
||||
return "groups"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package models_seguridad
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Permiso struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Nombre string `gorm:"uniqueIndex;not null;type:varchar(100)" json:"nombre"`
|
||||
Alias string `gorm:"uniqueIndex;not null;type:varchar(100)" json:"alias"`
|
||||
Descripcion string `gorm:"type:text" json:"descripcion"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
func (Permiso) TableName() string {
|
||||
return "permissions"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package models_seguridad
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Usuario struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Email string `gorm:"uniqueIndex;not null;type:varchar(100)" json:"email"`
|
||||
Password string `gorm:"not null" json:"-"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Grupos []Grupo `gorm:"many2many:user_groups;" json:"grupos,omitempty"`
|
||||
Empresas []Empresa `gorm:"many2many:user_empresa;" json:"empresas,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
func (Usuario) TableName() string {
|
||||
return "users"
|
||||
}
|
||||
Reference in new issue
Block a user