75 lines
1.1 KiB
Go
75 lines
1.1 KiB
Go
package types
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Rol uint8
|
|
|
|
const (
|
|
Admin Rol = iota + 1
|
|
Operador
|
|
JefeTurno
|
|
)
|
|
|
|
type Usuario struct {
|
|
Email string `gorm:"primaryKey"`
|
|
Password string
|
|
Enabled bool
|
|
Rol Rol
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
|
}
|
|
|
|
func (u *Usuario) TableName() string {
|
|
return "usuarios"
|
|
}
|
|
|
|
type GetUsuarioReq struct {
|
|
Sender string
|
|
Email string
|
|
TimeStamp string
|
|
}
|
|
|
|
type GetUsuarioRes struct {
|
|
Usuario *Usuario
|
|
TimeStamp string
|
|
}
|
|
|
|
type CreateUsuarioReq struct {
|
|
Sender string
|
|
Usuario *Usuario
|
|
TimeStamp string
|
|
}
|
|
|
|
type CreateUsuarioRes struct {
|
|
Message string
|
|
TimeStamp string
|
|
}
|
|
|
|
type ValidarUsuarioReq struct {
|
|
Sender string
|
|
Email string
|
|
Pass string
|
|
TimeStamp string
|
|
}
|
|
|
|
type ValidarUsuarioRes struct {
|
|
Message string
|
|
TimeStamp string
|
|
}
|
|
|
|
func (u *Usuario) BeforeCreate(tx *gorm.DB) (err error) {
|
|
u.CreatedAt = time.Now()
|
|
u.UpdatedAt = time.Now()
|
|
return
|
|
}
|
|
|
|
func (u *Usuario) BeforeUpdate(tx *gorm.DB) (err error) {
|
|
u.UpdatedAt = time.Now()
|
|
return
|
|
}
|