import { Router } from 'express'

import { getAdminWorkerLeaderboard } from '../../../services/worker-platform/index.js'
import { createJsonHandler, requireAdminRoles } from '../session.js'

const router = Router()

router.get(
  '/worker-platform/leaderboard',
  requireAdminRoles(['admin', 'operator', 'support']),
  createJsonHandler((req) => getAdminWorkerLeaderboard(req.query), {
    successMessage: 'ok',
    errorMessage: '读取接单排行榜失败',
    scope: '[admin/worker-platform/leaderboard]',
  }),
)

export default router
