import { request, type RequestOptions } from '@/utils/request';

/** 获取原材料盘点列表 GET /api/materials-inventory */
export async function materialsInventoryList(
  params: API.MaterialsInventoryListParams,
  options?: RequestOptions,
) {
  return request<{
    items?: API.MaterialsInventoryEntity[];
    meta?: {
      itemCount?: number;
      totalItems?: number;
      itemsPerPage?: number;
      totalPages?: number;
      currentPage?: number;
    };
  }>('/api/materials-inventory', {
    method: 'GET',
    params: {
      // page has a default value: 1
      page: '1',
      // pageSize has a default value: 10
      pageSize: '10',

      ...params,
    },
    ...(options || {}),
  });
}

/** 导出原材料盘点表 GET /api/materials-inventory/export*/
export async function materialsInventoryExport(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.MaterialsInventoryExportParams,
  options?: RequestOptions,
) {
  const { ...queryParams } = params;
  return request(`/api/materials-inventory/export`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || { responseType: 'blob', isReturnResult: false }),
  });
}
/** 新增原材料盘点 POST /api/materials-inventory */
export async function materialsInventoryCreate(
  body: API.MaterialsInventoryDto,
  options?: RequestOptions,
) {
  return request<any>('/api/materials-inventory', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || { successMsg: '创建成功' }),
  });
}

/** 获取原材料盘点信息 GET /api/materials-inventory/${param0} */
export async function materialsInventoryInfo(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.MaterialsInventoryInfoParams,
  options?: RequestOptions,
) {
  const { id: param0, ...queryParams } = params;
  return request<API.MaterialsInventoryEntity>(`/api/materials-inventory/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 解除原材料盘点和附件关联 PUT /api/materials-inventory/unlink-attachments/${param0} */
export async function unlinkAttachments(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.MaterialsInventoryUpdateParams,
  body: API.MaterialsInventoryDto,
  options?: RequestOptions,
) {
  const { id: param0, ...queryParams } = params;
  return request<any>(`/api/materials-inventory/unlink-attachments/${param0}`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    params: { ...queryParams },
    data: body,
    ...options,
  });
}

/** 更新原材料盘点 PUT /api/materials-inventory/${param0} */
export async function MaterialsInventoryUpdate(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.MaterialsInventoryUpdateParams,
  body: API.MaterialsInventoryUpdateDto,
  options?: RequestOptions,
) {
  const { id: param0, ...queryParams } = params;
  return request<any>(`/api/materials-inventory/${param0}`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    params: { ...queryParams },
    data: body,
    ...(options || { successMsg: '更新成功' }),
  });
}

/** 删除原材料盘点 DELETE /api/materials-inventory/${param0} */
export async function materialsInventoryDelete(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.MaterialsInventoryDeleteParams,
  options?: RequestOptions,
) {
  const { id: param0, ...queryParams } = params;
  return request<any>(`/api/materials-inventory/${param0}`, {
    method: 'DELETE',
    params: { ...queryParams },
    ...(options || { successMsg: '删除成功' }),
  });
}
