import { Router } from 'express'

import { listAdminPendingNotifications } from '../../services/admin/admin-notification-service.js'
import { createJsonHandler, requireAdminRoles } from './session.js'

const router = Router()

router.get(
  '/notifications',
  requireAdminRoles(['admin', 'operator', 'support']),
  createJsonHandler((req) => listAdminPendingNotifications(Number(req.query.limit || 20)), {
    successMessage: 'ok',
    errorMessage: '读取后台待办失败',
    scope: '[admin/notifications]',
  }),
)

export default router
