package appuser

import (
	"hyapp-admin-server/internal/middleware"

	"github.com/gin-gonic/gin"
)

func RegisterRoutes(protected *gin.RouterGroup, h *Handler) {
	if h == nil {
		return
	}

	protected.GET("/app/users", middleware.RequirePermission("app-user:view"), h.ListUsers)
	protected.POST("/exports/app-users", middleware.RequirePermission("app-user:export"), h.CreateExport)
	protected.GET("/app/users/bans", middleware.RequirePermission("app-user:view"), h.ListBannedUsers)
	protected.GET("/app/users/login-logs", middleware.RequirePermission("app-user:view"), h.ListLoginLogs)
	protected.GET("/app/users/content-blacklist", middleware.RequirePermission("app-user:view"), h.ListUserContentBlacklist)
	protected.GET("/app/users/content-blacklist/candidate", middleware.RequirePermission("app-user:view"), h.ResolveUserContentBlacklistCandidate)
	protected.POST("/app/users/content-blacklist", middleware.RequirePermission("app-user:status"), h.AddUserContentBlacklist)
	protected.DELETE("/app/users/content-blacklist/:id", middleware.RequirePermission("app-user:status"), h.RemoveUserContentBlacklist)
	protected.GET("/app/users/:id/login-logs", middleware.RequirePermission("app-user:view"), h.ListUserLoginLogs)
	protected.GET("/app/users/:id", middleware.RequirePermission("app-user:view"), h.GetUser)
	protected.PATCH("/app/users/:id", middleware.RequirePermission("app-user:update"), h.UpdateUser)
	protected.PUT("/app/users/:id/levels", middleware.RequirePermission("app-user:level"), h.AdjustTemporaryLevels)
	protected.POST("/app/users/:id/ban", middleware.RequirePermission("app-user:status"), h.BanUser)
	protected.POST("/app/users/:id/unban", middleware.RequirePermission("app-user:status"), h.UnbanUser)
	protected.POST("/app/users/:id/password", middleware.RequirePermission("app-user:password"), h.SetPassword)
	protected.POST("/app/users/:id/access-token", middleware.RequirePermission("app-user:token"), h.IssueAccessToken)
}
