import { withErrorBoundary } from '../utils/handler.js' import { guardMethod } from '../utils/method.js' import { getBearerToken, readJson } from '../utils/request.js' import { adminAuthService } from '../services/admin-auth.service.js' import { serviceFail } from '../types/service-result.js' import { merchantInvoiceService, type MerchantInvoiceListInput, type MerchantInvoiceFileInput } from '../services/merchant-invoice.service.js' import { toHttpResponse } from './controller-response.js' export const merchantInvoiceListController = withErrorBoundary(async request => { const methodResponse = guardMethod(request, ['POST']) if (methodResponse) return methodResponse if (!await adminAuthService.findSession(getBearerToken(request))) return toHttpResponse(serviceFail('登录已失效,请重新登录', 401, 'UNAUTHORIZED')) return toHttpResponse(await merchantInvoiceService.list(await readJson(request))) }) export const merchantInvoiceFileController = withErrorBoundary(async request => { const methodResponse = guardMethod(request, ['POST']) if (methodResponse) return methodResponse if (!await adminAuthService.findSession(getBearerToken(request))) return toHttpResponse(serviceFail('登录已失效,请重新登录', 401, 'UNAUTHORIZED')) return toHttpResponse(await merchantInvoiceService.file(await readJson(request))) })