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

package handler

import (
	"net/http"

	auth "juwan-backend/app/users/api/internal/handler/auth"
	user "juwan-backend/app/users/api/internal/handler/user"
	verification_admin "juwan-backend/app/users/api/internal/handler/verification_admin"
	verification_user "juwan-backend/app/users/api/internal/handler/verification_user"
	"juwan-backend/app/users/api/internal/svc"

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

func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
	server.AddRoutes(
		[]rest.Route{
			{
				// 用户登录
				Method:  http.MethodPost,
				Path:    "/login",
				Handler: auth.LoginHandler(serverCtx),
			},
			{
				// 用户注册
				Method:  http.MethodPost,
				Path:    "/register",
				Handler: auth.RegisterHandler(serverCtx),
			},
			{
				// 重置密码
				Method:  http.MethodPost,
				Path:    "/reset-password",
				Handler: auth.ResetPasswordHandler(serverCtx),
			},
		},
		rest.WithPrefix("/api/v1/auth"),
	)

	server.AddRoutes(
		[]rest.Route{
			{
				// 退出登录
				Method:  http.MethodPost,
				Path:    "/logout",
				Handler: auth.LogoutHandler(serverCtx),
			},
		},
		rest.WithPrefix("/api/v1/auth"),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.Logger},
			[]rest.Route{
				{
					// 关注用户
					Method:  http.MethodPost,
					Path:    "/:id/follow",
					Handler: user.FollowUserHandler(serverCtx),
				},
				{
					// 取消关注用户
					Method:  http.MethodDelete,
					Path:    "/:id/follow",
					Handler: user.UnfollowUserHandler(serverCtx),
				},
				{
					// 获取当前登录用户信息
					Method:  http.MethodGet,
					Path:    "/me",
					Handler: user.GetMeHandler(serverCtx),
				},
				{
					// 更新个人资料
					Method:  http.MethodPut,
					Path:    "/me",
					Handler: user.UpdateMeHandler(serverCtx),
				},
				{
					// 更新通知偏好
					Method:  http.MethodPut,
					Path:    "/me/preferences/notifications",
					Handler: user.UpdateNotificationSettingsHandler(serverCtx),
				},
				{
					// 更新主题偏好
					Method:  http.MethodPut,
					Path:    "/me/preferences/theme",
					Handler: user.UpdateThemeSettingsHandler(serverCtx),
				},
				{
					// 切换当前激活角色
					Method:  http.MethodPost,
					Path:    "/me/switch-role",
					Handler: user.SwitchRoleHandler(serverCtx),
				},
			}...,
		),
		rest.WithPrefix("/api/v1/users"),
	)

	server.AddRoutes(
		[]rest.Route{
			{
				// 获取指定用户信息
				Method:  http.MethodGet,
				Path:    "/:id",
				Handler: user.GetUserInfoHandler(serverCtx),
			},
		},
		rest.WithPrefix("/api/v1/users"),
	)

	server.AddRoutes(
		[]rest.Route{
			{
				// 管理员获取认证申请列表 (分页)
				Method:  http.MethodGet,
				Path:    "/verifications",
				Handler: verification_admin.GetVerificationsHandler(serverCtx),
			},
			{
				// 管理员通过申请
				Method:  http.MethodPost,
				Path:    "/verifications/:id/approve",
				Handler: verification_admin.ApproveVerificationHandler(serverCtx),
			},
			{
				// 管理员驳回申请
				Method:  http.MethodPost,
				Path:    "/verifications/:id/reject",
				Handler: verification_admin.RejectVerificationHandler(serverCtx),
			},
		},
		rest.WithPrefix("/api/v1/admin"),
	)

	server.AddRoutes(
		[]rest.Route{
			{
				// 提交或修改角色认证申请 (支持幂等更新)
				Method:  http.MethodPost,
				Path:    "/me/verification",
				Handler: verification_user.ApplyVerificationHandler(serverCtx),
			},
			{
				// 获取我的所有认证状态
				Method:  http.MethodGet,
				Path:    "/me/verification",
				Handler: verification_user.GetMyVerificationsHandler(serverCtx),
			},
		},
		rest.WithPrefix("/api/v1/users"),
	)
}
