import { createCrudRoutes } from '../../utils/generic-crud.routes';
import { OrderGoods } from '../../modules/orders/order-goods.entity';
import { OrderGoodsSchema, CreateOrderGoodsDto, UpdateOrderGoodsDto } from '../../modules/orders/order-goods.schema';
import { authMiddleware } from '../../middleware/auth.middleware';

const orderGoodsRoutes = createCrudRoutes({
  entity: OrderGoods,
  createSchema: CreateOrderGoodsDto,
  updateSchema: UpdateOrderGoodsDto,
  getSchema: OrderGoodsSchema,
  listSchema: OrderGoodsSchema,
  searchFields: ['goodsName', 'orderNo'],
  relations: ['order', 'goods', 'supplier', 'imageFile'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
});

export default orderGoodsRoutes;