import { createCrudRoutes } from '@d8d/shared-crud';
import { OrderGoodsMt } from '../../entities/order-goods.mt.entity';
import { OrderGoodsSchema, CreateOrderGoodsDto, UpdateOrderGoodsDto } from '../../schemas/order-goods.schema';
import { authMiddleware } from '@d8d/auth-module-mt';

// 多租户管理员订单商品路由 - 无数据权限限制，完整CRUD功能
const adminOrderItemsRoutes = createCrudRoutes({
  entity: OrderGoodsMt,
  createSchema: CreateOrderGoodsDto,
  updateSchema: UpdateOrderGoodsDto,
  getSchema: OrderGoodsSchema,
  listSchema: OrderGoodsSchema,
  searchFields: ['orderNo', 'goodsName'],
  relations: ['order', 'goods', 'supplier', 'imageFile'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  },
  tenantOptions: {
    enabled: true,
    tenantIdField: 'tenantId'
  }
  // 管理员路由不设置dataPermission，可以访问所有数据
});

export default adminOrderItemsRoutes;