This commit is contained in:
Lizandro Guarnizo
2026-05-19 13:33:39 -05:00
parent 762ebc2afc
commit b5e6a9285f
4 changed files with 74 additions and 50 deletions
+30 -30
View File
@@ -14,27 +14,27 @@ import (
// - Rol "partner": accede a los proyectos de todos sus ClienteIDs via PortalAccesos.
type PortalUser struct {
gorm.Model
Nombre string `json:"nombre" gorm:"column:nombre;not null"`
Email string `json:"email" gorm:"column:email;uniqueIndex;not null"`
Password string `json:"-" gorm:"column:password;type:text"`
ClienteID *uint `json:"cliente_id" gorm:"column:cliente_id;index"` // nil si es partner
Cliente *Cliente `json:"cliente" gorm:"foreignKey:ClienteID"`
Rol string `json:"rol" gorm:"column:rol;default:'cliente'"` // cliente|partner
RoleID *uint `json:"role_id" gorm:"column:role_id;index"`
Role *Roles `json:"role" gorm:"foreignKey:RoleID"`
Activo bool `json:"activo" gorm:"column:activo;default:true"`
Notas string `json:"notas" gorm:"column:notas;type:text"`
TelegramChatID string `json:"telegram_chat_id" gorm:"column:telegram_chat_id"`
Telefono string `json:"telefono" gorm:"column:telefono"`
Indicativo string `json:"indicativo" gorm:"column:indicativo"` // ej: +57, +1
Pais string `json:"pais" gorm:"column:pais"`
Ciudad string `json:"ciudad" gorm:"column:ciudad"`
Documento string `json:"documento" gorm:"column:documento"` // RUT, NIT, CC, etc.
Empresa string `json:"empresa" gorm:"column:empresa"` // empresa que representa
SitioWeb string `json:"sitio_web" gorm:"column:sitio_web"` // sitio web del partner/cliente
DocumentoRutFile string `json:"documento_rut_file" gorm:"column:documento_rut_file"` // ruta del archivo RUT
Nombre string `json:"nombre" gorm:"column:nombre;not null"`
Email string `json:"email" gorm:"column:email;uniqueIndex;not null"`
Password string `json:"-" gorm:"column:password;type:text"`
ClienteID *uint `json:"cliente_id" gorm:"column:cliente_id;index"` // nil si es partner
Cliente *Cliente `json:"cliente" gorm:"foreignKey:ClienteID"`
Rol string `json:"rol" gorm:"column:rol;default:'cliente'"` // cliente|partner
RoleID *uint `json:"role_id" gorm:"column:role_id;index"`
Role *Roles `json:"role" gorm:"foreignKey:RoleID"`
Activo bool `json:"activo" gorm:"column:activo;default:true"`
Notas string `json:"notas" gorm:"column:notas;type:text"`
TelegramChatID string `json:"telegram_chat_id" gorm:"column:telegram_chat_id"`
Telefono string `json:"telefono" gorm:"column:telefono"`
Indicativo string `json:"indicativo" gorm:"column:indicativo"` // ej: +57, +1
Pais string `json:"pais" gorm:"column:pais"`
Ciudad string `json:"ciudad" gorm:"column:ciudad"`
Documento string `json:"documento" gorm:"column:documento"` // RUT, NIT, CC, etc.
Empresa string `json:"empresa" gorm:"column:empresa"` // empresa que representa
SitioWeb string `json:"sitio_web" gorm:"column:sitio_web"` // sitio web del partner/cliente
DocumentoRutFile string `json:"documento_rut_file" gorm:"column:documento_rut_file"` // ruta del archivo RUT
DocumentoRutNombre string `json:"documento_rut_nombre" gorm:"column:documento_rut_nombre"` // nombre original
PortalAccesos []PortalAcceso `json:"portal_accesos" gorm:"foreignKey:PortalUserID"`
PortalAccesos []PortalAcceso `json:"portal_accesos" gorm:"foreignKey:PortalUserID"`
}
func (PortalUser) TableName() string { return "portal_users" }
@@ -87,17 +87,17 @@ func UpdatePortalUser(u *PortalUser) error {
"email": u.Email,
"cliente_id": u.ClienteID,
"rol": u.Rol,
"role_id": u.RoleID,
"activo": u.Activo,
"notas": u.Notas,
"role_id": u.RoleID,
"activo": u.Activo,
"notas": u.Notas,
"telegram_chat_id": u.TelegramChatID,
"telefono": u.Telefono,
"indicativo": u.Indicativo,
"pais": u.Pais,
"ciudad": u.Ciudad,
"documento": u.Documento,
"empresa": u.Empresa,
"sitio_web": u.SitioWeb,
"telefono": u.Telefono,
"indicativo": u.Indicativo,
"pais": u.Pais,
"ciudad": u.Ciudad,
"documento": u.Documento,
"empresa": u.Empresa,
"sitio_web": u.SitioWeb,
}).Error
}