Files
backend_v2/internal/dto/auth.go
toom1996 30c9f21da4 update
2026-08-26 10:45:21 +08:00

31 lines
880 B
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 dto
// ---------- 请求 ----------
// AuthRequest 注册 / 登录的统一请求体。
//
// 沿用原项目的单结构设计:注册用 username + email + password,
// 登录用 account(可填邮箱或用户名)+ password。
type AuthRequest struct {
Username string `json:"username"`
Email string `json:"email"`
Password string `json:"password"`
Account string `json:"account"`
}
// ---------- 响应 ----------
// UserPayload 对外返回的用户信息,绝不包含密码哈希。
type UserPayload struct {
ID uint32 `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
}
// AuthResult 注册 / 登录成功后的返回:令牌 + 用户信息。
// 前端 src/lib/auth.ts 依赖 token 与 user 两个顶层字段。
type AuthResult struct {
Token string `json:"token"`
User UserPayload `json:"user"`
}