Private
Public Access
fix: cambiados nombres de tablas y añadido requerimiento de implementar la interfaz
This commit is contained in:
1 parent
cd817dcc7b
commit
59dd842d33
3 files changed
+15
-11
No files matched your search
@@ -10,16 +10,18 @@ type Grupo struct {
|
|||||||
ID uint `gorm:"primaryKey" json:"id"`
|
ID uint `gorm:"primaryKey" json:"id"`
|
||||||
Nombre string `gorm:"uniqueIndex;not null;type:varchar(100)" json:"nombre"`
|
Nombre string `gorm:"uniqueIndex;not null;type:varchar(100)" json:"nombre"`
|
||||||
Descripcion string `gorm:"type:text" json:"descripcion"`
|
Descripcion string `gorm:"type:text" json:"descripcion"`
|
||||||
Permisos []Permiso `gorm:"many2many:group_permissions;" json:"permisos,omitempty"`
|
Permisos []Permiso `gorm:"many2many:grupo_permisos;" json:"permisos,omitempty"`
|
||||||
Grupos []Grupo `gorm:"many2many:group_groups;joinForeignKey:ParentGroupID;joinReferences:ChildGroupID" json:"grupos_hijos,omitempty"`
|
Grupos []Grupo `gorm:"many2many:grupo_grupos;joinForeignKey:ParentGroupID;joinReferences:ChildGroupID" json:"grupos_hijos,omitempty"`
|
||||||
Usuarios []Usuario `gorm:"many2many:user_groups;" json:"usuarios,omitempty"`
|
Usuarios []Usuario `gorm:"many2many:usuario_grupos;" json:"usuarios,omitempty"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||||
|
|
||||||
|
IPermisosComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Grupo) TableName() string {
|
func (Grupo) TableName() string {
|
||||||
return "groups"
|
return "groupos"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Grupo) Buscar(id uint) bool {
|
func (g *Grupo) Buscar(id uint) bool {
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ type Permiso struct {
|
|||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||||
|
|
||||||
|
IPermisosComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Permiso) TableName() string {
|
func (Permiso) TableName() string {
|
||||||
return "permissions"
|
return "permisos"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Permiso) Buscar(id uint) bool {
|
func (p *Permiso) Buscar(id uint) bool {
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Usuario struct {
|
type Usuario struct {
|
||||||
ID uint `gorm:"primaryKey" json:"id"`
|
ID uint `gorm:"primaryKey" json:"id"`
|
||||||
Email string `gorm:"uniqueIndex;not null;type:varchar(100)" json:"email"`
|
Email string `gorm:"uniqueIndex;not null;type:varchar(100)" json:"email"`
|
||||||
Password string `gorm:"not null" json:"-"`
|
Password string `gorm:"not null" json:"-"`
|
||||||
Name string `gorm:"not null" json:"name"`
|
Name string `gorm:"not null" json:"name"`
|
||||||
Grupos []Grupo `gorm:"many2many:user_groups;" json:"grupos,omitempty"`
|
Grupos []Grupo `gorm:"many2many:usuarios_grupos;" json:"grupos,omitempty"`
|
||||||
// Empresas []Empresa `gorm:"many2many:user_empresa;" json:"empresas,omitempty"`
|
// Empresas []Empresa `gorm:"many2many:user_empresa;" json:"empresas,omitempty"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
@@ -19,5 +19,5 @@ type Usuario struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (Usuario) TableName() string {
|
func (Usuario) TableName() string {
|
||||||
return "users"
|
return "usuarios"
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user