44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
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"`
|
||
}
|