// Code generated by goctl. DO NOT EDIT.
// goctl 1.9.0

package handler

import (
	"net/http"
	"time"

	auth "backend/internal/handler/auth"
	fileStorage "backend/internal/handler/fileStorage"
	ping "backend/internal/handler/ping"
	user "backend/internal/handler/user"
	"backend/internal/svc"

	"github.com/zeromicro/go-zero/rest"
)

func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
	server.AddRoutes(
		[]rest.Route{
			{
				// 執行密碼重設
				Method:  http.MethodPut,
				Path:    "/password-resets",
				Handler: auth.ResetPasswordHandler(serverCtx),
			},
			{
				// 請求發送密碼重設驗證碼
				Method:  http.MethodPost,
				Path:    "/password-resets/request",
				Handler: auth.RequestPasswordResetHandler(serverCtx),
			},
			{
				// 校驗密碼重設驗證碼
				Method:  http.MethodPost,
				Path:    "/password-resets/verify",
				Handler: auth.VerifyPasswordResetCodeHandler(serverCtx),
			},
			{
				// 註冊新帳號
				Method:  http.MethodPost,
				Path:    "/register",
				Handler: auth.RegisterHandler(serverCtx),
			},
			{
				// 使用者登入
				Method:  http.MethodPost,
				Path:    "/sessions",
				Handler: auth.LoginHandler(serverCtx),
			},
			{
				// 刷新 Access Token
				Method:  http.MethodPost,
				Path:    "/sessions/refresh",
				Handler: auth.RefreshTokenHandler(serverCtx),
			},
		},
		rest.WithPrefix("/api/v1/auth"),
		rest.WithTimeout(10000*time.Millisecond),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.AuthMiddleware},
			[]rest.Route{
				{
					// create - 上傳圖片檔案
					Method:  http.MethodPost,
					Path:    "/fileStorage/img/upload",
					Handler: fileStorage.UploadImgHandler(serverCtx),
				},
				{
					// create - 上傳影片檔案
					Method:  http.MethodPost,
					Path:    "/fileStorage/video/upload",
					Handler: fileStorage.UploadVideoHandler(serverCtx),
				},
			}...,
		),
		rest.WithPrefix("/api/v1/fileStorage"),
		rest.WithTimeout(300000*time.Millisecond),
	)

	server.AddRoutes(
		[]rest.Route{
			{
				// 系統健康檢查
				Method:  http.MethodGet,
				Path:    "/health",
				Handler: ping.PingHandler(serverCtx),
			},
		},
		rest.WithPrefix("/api/v1"),
		rest.WithTimeout(10000*time.Millisecond),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.AuthMiddleware},
			[]rest.Route{
				{
					// 取得當前登入的會員資訊(自己)
					Method:  http.MethodGet,
					Path:    "/me",
					Handler: user.GetUserInfoHandler(serverCtx),
				},
				{
					// 更新當前登入的會員資訊
					Method:  http.MethodPut,
					Path:    "/me",
					Handler: user.UpdateUserInfoHandler(serverCtx),
				},
				{
					// 修改當前登入使用者的密碼
					Method:  http.MethodPut,
					Path:    "/me/password",
					Handler: user.UpdatePasswordHandler(serverCtx),
				},
				{
					// 請求發送驗證碼 (用於驗證信箱/手機)
					Method:  http.MethodPost,
					Path:    "/me/verifications",
					Handler: user.RequestVerificationCodeHandler(serverCtx),
				},
				{
					// 提交驗證碼以完成驗證
					Method:  http.MethodPut,
					Path:    "/me/verifications",
					Handler: user.SubmitVerificationCodeHandler(serverCtx),
				},
			}...,
		),
		rest.WithPrefix("/api/v1/user"),
		rest.WithTimeout(10000*time.Millisecond),
	)
}
