import { Router } from 'express'

import {
  getAdminFinanceSummary,
  listAdminFinanceTransactions,
} from '../../services/admin/admin-finance-service.js'
import { createJsonHandler, requireAdminRoles } from './session.js'

const router = Router()

router.get(
  '/finance/summary',
  requireAdminRoles(['admin', 'operator', 'finance']),
  createJsonHandler((req) => getAdminFinanceSummary(req.query), {
    successMessage: 'ok',
    errorMessage: '读取财务汇总失败',
    scope: '[admin/finance/summary]',
  }),
)

router.get(
  '/finance/transactions',
  requireAdminRoles(['admin', 'operator', 'finance']),
  createJsonHandler((req) => listAdminFinanceTransactions(req.query), {
    successMessage: 'ok',
    errorMessage: '读取财务明细失败',
    scope: '[admin/finance/transactions]',
  }),
)

export default router
