package app

import (
	v1 "git.echol.cn/loser/st/server/api/v1"
	"git.echol.cn/loser/st/server/middleware"
	"github.com/gin-gonic/gin"
)

type AuthRouter struct{}

// InitAuthRouter 初始化前台用户认证路由
func (r *AuthRouter) InitAuthRouter(Router *gin.RouterGroup) {
	authRouter := Router.Group("auth")
	authApi := v1.ApiGroupApp.AppApiGroup.AuthApi

	{
		// 公开路由（无需认证）
		authRouter.POST("register", authApi.Register)    // 注册
		authRouter.POST("login", authApi.Login)          // 登录
		authRouter.POST("refresh", authApi.RefreshToken) // 刷新Token
	}

	// 需要认证的路由
	authRouterAuth := Router.Group("auth").Use(middleware.AppJWTAuth())
	{
		authRouterAuth.POST("logout", authApi.Logout)       // 登出
		authRouterAuth.GET("userinfo", authApi.GetUserInfo) // 获取用户信息
	}

	// 用户相关路由
	userRouter := Router.Group("user").Use(middleware.AppJWTAuth())
	{
		userRouter.PUT("profile", authApi.UpdateProfile)           // 更新用户信息
		userRouter.POST("change-password", authApi.ChangePassword) // 修改密码
	}
}
