Files
nl-blogs/server/models/user.go
2026-01-15 13:51:44 +08:00

44 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package models
import (
"time"
)
// User 用户模型
type User struct {
ID uint `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
PasswordHash string `json:"-"`
RoleID uint `json:"roleId"`
Role string `json:"role"` // 保持兼容或者作为Role Name
IsActive int `json:"isActive"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// UserResponse 用户响应模型
type UserResponse struct {
ID uint `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
RoleID uint `json:"roleId"`
Role string `json:"role"`
IsActive int `json:"isActive"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
// LoginRequest 登录请求模型
type LoginRequest struct {
Username string `json:"username" binding:"required"`
Password string `json:"password" binding:"required"`
}
// LoginResponse 登录响应模型
type LoginResponse struct {
Token string `json:"token"`
User UserResponse `json:"user"`
Expire int64 `json:"expire"`
}