首次提交:初始化项目代码

This commit is contained in:
sunct
2026-07-31 15:24:14 +08:00
commit 8d3c97bd01
73 changed files with 11720 additions and 0 deletions
@@ -0,0 +1,47 @@
package routes
import (
"cloudnest/internal/interface/http/handler"
"cloudnest/internal/middleware"
"github.com/gin-gonic/gin"
)
// RegisterAuthRoutes registers authentication-related routes.
// RegisterAuthRoutes 注册认证相关的路由。
//
// Parameters:
// - r: The router group to register routes on.
// - h: The authentication handler.
// - emailHandler: The email verification handler.
//
// Routes:
// - POST /register: Register a new user.
// - POST /login: Authenticate and get JWT token.
// - POST /email-code: Send email verification code.
// - GET /profile: Get user profile (requires JWT).
// - PUT /profile: Update user profile (requires JWT).
// - PUT /password: Change password (requires JWT).
//
// 参数:
// - r: 要注册路由的路由器组。
// - h: 认证处理器。
// - emailHandler: 邮箱验证码处理器。
//
// 路由:
// - POST /register: 注册新用户。
// - POST /login: 认证并获取 JWT 令牌。
// - POST /email-code: 发送邮箱验证码。
// - GET /profile: 获取用户个人信息(需要 JWT)。
// - PUT /profile: 更新用户个人信息(需要 JWT)。
// - PUT /password: 修改密码(需要 JWT)。
func RegisterAuthRoutes(r *gin.RouterGroup, h *handler.AuthHandler, emailHandler *handler.EmailHandler, jwtSecret string) {
r.POST("/register", h.Register)
r.POST("/login", h.Login)
r.POST("/email-code", emailHandler.SendEmailCode)
protected := r.Group("")
protected.Use(middleware.JWT(jwtSecret))
protected.GET("/profile", h.Profile)
protected.PUT("/profile", h.UpdateProfile)
protected.PUT("/password", h.ChangePassword)
}