初始化
This commit is contained in:
31
server/dto/auth_dto.go
Normal file
31
server/dto/auth_dto.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Package dto 定义请求和响应的数据传输对象
|
||||
package dto
|
||||
|
||||
// LoginRequest 登录请求
|
||||
type LoginRequest struct {
|
||||
Username string `json:"username" binding:"required"` // 用户名, 必填
|
||||
Password string `json:"password" binding:"required"` // 密码, 必填
|
||||
}
|
||||
|
||||
// RegisterRequest 注册请求
|
||||
type RegisterRequest struct {
|
||||
Username string `json:"username" binding:"required,min=3,max=64"` // 用户名, 3-64字符
|
||||
Password string `json:"password" binding:"required,min=6,max=128"` // 密码, 6-128字符
|
||||
Email string `json:"email" binding:"omitempty,email"` // 邮箱, 可选
|
||||
Nickname string `json:"nickname" binding:"omitempty,max=64"` // 昵称, 可选
|
||||
}
|
||||
|
||||
// LoginResponse 登录响应
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
Username string `json:"username"`
|
||||
Nickname string `json:"nickname"`
|
||||
Role string `json:"role"`
|
||||
MustChangePwd bool `json:"must_change_pwd"` // 首次登录需改密码
|
||||
}
|
||||
|
||||
// ChangePasswordRequest 修改密码请求
|
||||
type ChangePasswordRequest struct {
|
||||
OldPassword string `json:"old_password" binding:"required"` // 当前密码
|
||||
NewPassword string `json:"new_password" binding:"required,min=6"` // 新密码
|
||||
}
|
||||
Reference in New Issue
Block a user