import { createCrudRoutes } from '@d8d/shared-crud';
import { OpenAPIHono } from '@hono/zod-openapi';
import { OrderRefund } from '../../entities/order-refund.entity';
import { OrderRefundSchema, CreateOrderRefundDto, UpdateOrderRefundDto } from '../../schemas/order-refund.schema';
import { authMiddleware } from '@d8d/auth-module';

// 管理员退款路由 - 无数据权限限制，完整CRUD功能
const adminRefundsRoutes = createCrudRoutes({
  entity: OrderRefund,
  createSchema: CreateOrderRefundDto,
  updateSchema: UpdateOrderRefundDto,
  getSchema: OrderRefundSchema,
  listSchema: OrderRefundSchema,
  searchFields: ['orderNo', 'refundOrderNo'],
  relations: ['order'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
  // 管理员路由不设置dataPermission，可以访问所有数据
});

export default adminRefundsRoutes;