update
This commit is contained in:
30
internal/dto/auth.go
Normal file
30
internal/dto/auth.go
Normal file
@ -0,0 +1,30 @@
|
||||
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"`
|
||||
}
|
||||
Reference in New Issue
Block a user