import request from '@/utils/request';

// 列表
export async function getVersionManagePageAPI(data) {
  const res = await request.post(`/main/versionmanagerment/page`, data);
  console.log(res.data.code == 0)
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 详情
export async function getDetailsByTypeAPI(type) {
  const res = await request.get(`/main/versionmanagerment/getDetailsByType/${type}`, {
    data
  });
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
// 详情
export async function getDetailsByIdAPI(id) {
  const res = await request.get(`/main/versionmanagerment/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 删除
export async function versionManageDeleteAPI(data) {
  const res = await request.delete(`/main/versionmanagerment/delete`, {
    data
  });
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
// 新增
export async function versionManageSaveAPI(data) {
  const res = await request.post(`/main/versionmanagerment/save`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 修改
export async function versionManageUpdateAPI(data) {
  const res = await request.put(`/main/versionmanagerment/update`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 修改updateStatus
export async function updateStatus(data) {
  const res = await request.put(`/main/versionmanagerment/updateStatus`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 查询分类列表一二级数据
export async function getSubTwoLevelAPI(params) {
  const res = await request.get(`/main/categoryLevel/getSubPageList`, {params});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
