import { request } from '@/service/request';

export function fetchGetDeskCategoryList(data: any) {
  return request<Api.goods.ShopCategory[]>({
    url: '/platform/shopCategory/list',
    method: 'get',
    params: data
  });
}

export function fetchGategoryImport(data: File) {
  return request({
    url: '/platform/shopCategory/import',
    method: 'post',
    data: {
      file: data
    },
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

/**
 * 获取所有门店列表
 * @returns
 */
export function fetchGetAllStoreList() {
  return request({
    url: '/hb/store/list',
    method: 'get'
  });
}

/**
 * 修改前台类目
 * @param data
 * @returns
 */
export function fetchUpdateCategory(data: any) {
  return request({
    url: '/platform/shopCategory',
    method: 'PUT',
    data
  });
}
/**
 * 新增分类
 * @param data
 * @returns
 */
export function fetchAddCategory(data: any) {
  return request({
    url: '/platform/shopCategory',
    method: 'POST',
    data
  });
}
/**
 * 删除分类
 */
export function fetchDeleteCategory(id: any) {
  return request({
    url: `/platform/shopCategory/${id}`,
    method: 'DELETE'
  });
}

/**
 * 查询门店前台类目导入记录
 * @returns
 */
export function fetchGetFailLogList() {
  return request<Api.goods.ShopCategoryLogVO[]>({
    url: '/platform/shopCategoryLog/list',
    method: 'get'
  });
}

/**
 *
 * 查询已关联商品传三级分类code
 *
 * 分页通过code查询分类绑定商品
 * @param data
 * @returns
 */
export function fetchGetCategoryProdList(data: any) {
  return request<Api.goods.CategoryProd[]>({
    url: '/platform/categoryProd/pageByCode',
    method: 'get',
    params: data
  });
}

/**
 *
 * @param data 查询未关联商品传二级分类code
 * @returns
 */
export function fetchGetCategoryProdHb(data: any) {
  return request<Api.goods.CategoryProd[]>({
    url: '/platform/categoryProdHb/pageByCode',
    method: 'get',
    params: data
  });
}

/***
 * 绑定门店分类商品
 */
export function fetchEditCategoryProd(data: any) {
  return request({
    url: '/platform/categoryProd/categoryProduct',
    method: 'POST',
    data
  });
}

/**
 * 取消分类绑定商品
 */
export function fetchCancelCategoryProd(data: any) {
  return request({
    url: '/platform/categoryProd/cancelCategoryProduct',
    method: 'POST',
    data
  });
}
