基础架构

This commit is contained in:
2025-07-13 16:36:20 +08:00
parent e3d64e7485
commit 807004f78d
128 changed files with 17232 additions and 11396 deletions

View File

@@ -0,0 +1,57 @@
package commands
// RegisterUserCommand 用户注册命令
// @Description 用户注册请求参数
type RegisterUserCommand struct {
Phone string `json:"phone" binding:"required,len=11" example:"13800138000"`
Password string `json:"password" binding:"required,min=6,max=128" example:"password123"`
ConfirmPassword string `json:"confirm_password" binding:"required,eqfield=Password" example:"password123"`
Code string `json:"code" binding:"required,len=6" example:"123456"`
}
// LoginWithPasswordCommand 密码登录命令
// @Description 使用密码进行用户登录请求参数
type LoginWithPasswordCommand struct {
Phone string `json:"phone" binding:"required,len=11" example:"13800138000"`
Password string `json:"password" binding:"required" example:"password123"`
}
// LoginWithSMSCommand 短信验证码登录命令
// @Description 使用短信验证码进行用户登录请求参数
type LoginWithSMSCommand struct {
Phone string `json:"phone" binding:"required,len=11" example:"13800138000"`
Code string `json:"code" binding:"required,len=6" example:"123456"`
}
// ChangePasswordCommand 修改密码命令
// @Description 修改用户密码请求参数
type ChangePasswordCommand struct {
UserID string `json:"-"`
OldPassword string `json:"old_password" binding:"required" example:"oldpassword123"`
NewPassword string `json:"new_password" binding:"required,min=6,max=128" example:"newpassword123"`
ConfirmNewPassword string `json:"confirm_new_password" binding:"required,eqfield=NewPassword" example:"newpassword123"`
Code string `json:"code" binding:"required,len=6" example:"123456"`
}
// SendCodeCommand 发送验证码命令
// @Description 发送短信验证码请求参数
type SendCodeCommand struct {
Phone string `json:"phone" binding:"required,len=11" example:"13800138000"`
Scene string `json:"scene" binding:"required,oneof=register login change_password reset_password bind unbind" example:"register"`
}
// UpdateProfileCommand 更新用户信息命令
// @Description 更新用户基本信息请求参数
type UpdateProfileCommand struct {
UserID string `json:"-"`
Phone string `json:"phone" binding:"omitempty,len=11" example:"13800138000"`
// 可以在这里添加更多用户信息字段,如昵称、头像等
}
// VerifyCodeCommand 验证验证码命令
// @Description 验证短信验证码请求参数
type VerifyCodeCommand struct {
Phone string `json:"phone" binding:"required,len=11" example:"13800138000"`
Code string `json:"code" binding:"required,len=6" example:"123456"`
Scene string `json:"scene" binding:"required,oneof=register login change_password reset_password bind unbind" example:"register"`
}

View File

@@ -0,0 +1,6 @@
package queries
// GetUserQuery 获取用户信息查询
type GetUserQuery struct {
UserID string `json:"user_id"`
}

View File

@@ -0,0 +1,63 @@
package responses
import (
"time"
)
// RegisterUserResponse 用户注册响应
// @Description 用户注册成功响应
type RegisterUserResponse struct {
ID string `json:"id" example:"123e4567-e89b-12d3-a456-426614174000"`
Phone string `json:"phone" example:"13800138000"`
}
// EnterpriseInfoResponse 企业信息响应
// @Description 企业信息响应
type EnterpriseInfoResponse struct {
ID string `json:"id" example:"123e4567-e89b-12d3-a456-426614174000"`
CompanyName string `json:"company_name" example:"示例企业有限公司"`
UnifiedSocialCode string `json:"unified_social_code" example:"91110000123456789X"`
LegalPersonName string `json:"legal_person_name" example:"张三"`
LegalPersonID string `json:"legal_person_id" example:"110101199001011234"`
IsOCRVerified bool `json:"is_ocr_verified" example:"false"`
IsFaceVerified bool `json:"is_face_verified" example:"false"`
IsCertified bool `json:"is_certified" example:"false"`
CertifiedAt *time.Time `json:"certified_at,omitempty" example:"2024-01-01T00:00:00Z"`
CreatedAt time.Time `json:"created_at" example:"2024-01-01T00:00:00Z"`
UpdatedAt time.Time `json:"updated_at" example:"2024-01-01T00:00:00Z"`
}
// LoginUserResponse 用户登录响应
// @Description 用户登录成功响应
type LoginUserResponse struct {
User *UserProfileResponse `json:"user"`
AccessToken string `json:"access_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."`
TokenType string `json:"token_type" example:"Bearer"`
ExpiresIn int64 `json:"expires_in" example:"86400"`
LoginMethod string `json:"login_method" example:"password"`
}
// UserProfileResponse 用户信息响应
// @Description 用户基本信息
type UserProfileResponse struct {
ID string `json:"id" example:"123e4567-e89b-12d3-a456-426614174000"`
Phone string `json:"phone" example:"13800138000"`
EnterpriseInfo *EnterpriseInfoResponse `json:"enterprise_info,omitempty"`
CreatedAt time.Time `json:"created_at" example:"2024-01-01T00:00:00Z"`
UpdatedAt time.Time `json:"updated_at" example:"2024-01-01T00:00:00Z"`
}
// SendCodeResponse 发送验证码响应
// @Description 发送短信验证码成功响应
type SendCodeResponse struct {
Message string `json:"message" example:"验证码发送成功"`
ExpiresAt time.Time `json:"expires_at" example:"2024-01-01T00:05:00Z"`
}
// UpdateProfileResponse 更新用户信息响应
// @Description 更新用户信息成功响应
type UpdateProfileResponse struct {
ID string `json:"id" example:"123e4567-e89b-12d3-a456-426614174000"`
Phone string `json:"phone" example:"13800138000"`
UpdatedAt time.Time `json:"updated_at" example:"2024-01-01T00:00:00Z"`
}