首次提交:初始化项目代码
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
package auth
|
||||
|
||||
// RegisterRequest represents the request body for user registration.
|
||||
// RegisterRequest 表示用户注册的请求体。
|
||||
//
|
||||
// Fields:
|
||||
// - Username: The desired username (3-50 characters).
|
||||
// - Password: The desired password (minimum 6 characters).
|
||||
//
|
||||
// Validation:
|
||||
// - Username is required and must be 3-50 characters.
|
||||
// - Password is required and must be at least 6 characters.
|
||||
//
|
||||
// 字段:
|
||||
// - Username: 期望的用户名(3-50 个字符)。
|
||||
// - Password: 期望的密码(最少 6 个字符)。
|
||||
//
|
||||
// 验证规则:
|
||||
// - Username 是必填项,必须是 3-50 个字符。
|
||||
// - Password 是必填项,必须至少 6 个字符。
|
||||
type RegisterRequest struct {
|
||||
Username string `json:"username" binding:"required,min=3,max=50"`
|
||||
Password string `json:"password" binding:"required,min=6"`
|
||||
Email string `json:"email"`
|
||||
Nickname string `json:"nickname"`
|
||||
CaptchaID string `json:"captcha_id" binding:"required"`
|
||||
CaptchaAnswer string `json:"captcha_answer" binding:"required"`
|
||||
EmailCode string `json:"email_code"` // 邮箱注册时必填
|
||||
}
|
||||
|
||||
// LoginRequest represents the request body for user login.
|
||||
// LoginRequest 表示用户登录的请求体。
|
||||
//
|
||||
// Fields:
|
||||
// - Username: The user's username.
|
||||
// - Password: The user's password.
|
||||
//
|
||||
// Validation:
|
||||
// - Both fields are required.
|
||||
//
|
||||
// 字段:
|
||||
// - Username: 用户的用户名。
|
||||
// - Password: 用户的密码。
|
||||
//
|
||||
// 验证规则:
|
||||
// - 两个字段都是必填项。
|
||||
type LoginRequest struct {
|
||||
Username string `json:"username" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
CaptchaID string `json:"captcha_id" binding:"required"`
|
||||
CaptchaAnswer string `json:"captcha_answer" binding:"required"`
|
||||
}
|
||||
|
||||
// TokenResponse represents the response body for successful login.
|
||||
// TokenResponse 表示成功登录的响应体。
|
||||
//
|
||||
// Fields:
|
||||
// - Token: The JWT access token.
|
||||
//
|
||||
// 字段:
|
||||
// - Token: JWT 访问令牌。
|
||||
type TokenResponse struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
// UpdateProfileRequest represents the request body for updating user profile.
|
||||
// UpdateProfileRequest 表示更新用户个人信息的请求体。
|
||||
//
|
||||
// Fields:
|
||||
// - Email: The user's email address.
|
||||
// - Phone: The user's phone number.
|
||||
//
|
||||
// 字段:
|
||||
// - Email: 用户的邮箱地址。
|
||||
// - Phone: 用户的手机号码。
|
||||
type UpdateProfileRequest struct {
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
Nickname string `json:"nickname"`
|
||||
}
|
||||
|
||||
// ChangePasswordRequest represents the request body for changing password.
|
||||
// ChangePasswordRequest 表示修改密码的请求体。
|
||||
//
|
||||
// Fields:
|
||||
// - CurrentPassword: The user's current password.
|
||||
// - NewPassword: The new password.
|
||||
//
|
||||
// 字段:
|
||||
// - CurrentPassword: 用户当前的密码。
|
||||
// - NewPassword: 新密码。
|
||||
type ChangePasswordRequest struct {
|
||||
CurrentPassword string `json:"currentPassword" binding:"required"`
|
||||
NewPassword string `json:"newPassword" binding:"required,min=6"`
|
||||
}
|
||||
Reference in New Issue
Block a user