import request from "@/utils/request";

// 获取商品管理列表
export function getGoodManageInfo(query) {
  return request({
    url: "/goods/goodInfoManage/getGoodManage",
    method: "get",
    params: query,
  });
}
// 获取商品列表页顶部tab中的数据
export function getGoodManageCount(query) {
  return request({
    url: "/goods/goodInfoManage/getGoodManageCount",
    method: "get",
    params: query,
  });
}

// 获取商品分类列表
export function getGoodType(query) {
  return request({
    url: "/goods/goodInfoManage/goodType",
    method: "get",
    params: query,
  });
}

// 新增商品
export function goodAdd(data) {
  return request({
    url: "/goods/goodInfoManage/goodSave",
    method: "post",
    data: data,
  });
}
// 编辑商品
export function goodEdit(data) {
  return request({
    url: "/goods/goodInfoManage/goodEdit",
    method: "put",
    data: data,
  });
}
// 商品删除
export function goodDelete(id) {
  return request({
    url: "/goods/goodInfoManage/deleteGoodInfo?id=" + id,
    method: "delete",
  });
}

// 商品上架下架
export function goodUpAndDown(data) {
  return request({
    url: "/goods/goodInfoManage/goodOnSale",
    method: "put",
    data: data,
  });
}

// 获取商品信息（id）
export function getGoodInfo(id) {
  return request({
    url: "/goods/goodInfoManage/getGoodInfo/" + id,
    method: "get",
  });
}

// 获取商品优惠信息配置项
export function getActiveInfos() {
  return request({
    url: "/goods/goodInfoManage/getActiveInfos",
    method: "get",
  });
}

// 获取商品分类列表
export function getGoodCategoryInfo(query) {
  return request({
    url: "/goods/business/category/list",
    method: "get",
    params: query,
  });
}
// 新增商品分类
export function categoryAdd(data) {
  return request({
    url: "/goods/business/category/add",
    method: "post",
    data: data,
  });
}
// 编辑商品分类
export function categoryEdit(data) {
  return request({
    url: "/goods/business/category/edit",
    method: "post",
    data: data,
  });
}
// 商品分类删除
export function categoryRemove(data) {
  const formData = new FormData();
  // 将data对象的每个属性添加到FormData
  Object.keys(data).forEach((key) => {
    formData.append(key, data[key]);
  });
  return request({
    url: "/goods/business/category/remove",
    method: "post",
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
}
// 启用或禁用商品分类
export function enableAndDisableCategory(data) {
  return request({
    url: "/goods/business/category/enable",
    method: "put",
    data: data,
  });
}

// 获取违禁物品列表
export function getViolateGoodPage(query) {
  return request({
    url: "/goods/violate/getViolateGoodPage",
    method: "get",
    params: query,
  });
}
// 违禁物品新增
export function violateGoodSave(data) {
  return request({
    url: "/goods/violate/violateGoodSave",
    method: "post",
    data: data,
  });
}
// 违禁物品编辑
export function violateGoodEdit(data) {
  return request({
    url: "/goods/violate/violateGoodEdit",
    method: "put",
    data: data,
  });
}
// 违禁物品删除
export function deleteContraband(id) {
  return request({
    url: "/goods/violate/deleteViolateGoodInfo?id=" + id,
    method: "delete",
  });
}
//商品审核
export function goodaudit(data) {
  return request({
    url: '/goods/goodInfoManage/goodExamine',
    method: 'put',
    data: data
  })
}
