Features: - React 18 + TypeScript frontend with Vite - Go + Gin backend API - PostgreSQL database - JWT authentication with refresh tokens - User management (admin panel) - Docker containerization - Progress tracking system - 4 economic modules structure Fixed: - Login with username or email - User creation without required email - Database nullable timestamps - API response field naming
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Usuario struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Email string `json:"email"`
|
|
Username string `json:"username"`
|
|
PasswordHash string `json:"-"`
|
|
Nombre string `json:"nombre"`
|
|
Rol string `json:"rol"` // admin, estudiante
|
|
CreadoEn time.Time `json:"creado_en"`
|
|
UltimoLogin *time.Time `json:"ultimo_login"`
|
|
Activo bool `json:"activo"`
|
|
}
|
|
|
|
type UsuarioCreate struct {
|
|
Username string `json:"username" binding:"required"`
|
|
Email string `json:"email"`
|
|
Password string `json:"password"`
|
|
Nombre string `json:"nombre" binding:"required"`
|
|
Rol string `json:"rol"`
|
|
}
|
|
|
|
type UsuarioUpdate struct {
|
|
Email string `json:"email"`
|
|
Nombre string `json:"nombre"`
|
|
Activo *bool `json:"activo"`
|
|
}
|
|
|
|
type LoginRequest struct {
|
|
Email string `json:"email"`
|
|
Username string `json:"username"`
|
|
Password string `json:"password" binding:"required"`
|
|
}
|
|
|
|
type LoginResponse struct {
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
ExpiresIn int `json:"expires_in"` // seconds
|
|
User *Usuario `json:"user"`
|
|
}
|
|
|
|
type RefreshRequest struct {
|
|
RefreshToken string `json:"refresh_token" binding:"required"`
|
|
}
|