import Request from '../..'

// 获取分类树
export function getCategoryTree(data: any) {
  return Request.get<API.CategoryTree>({
    url: '/ware/category/tree',
    params: data
  })
}

// 增加分类
export function addFormCategory(data: any) {
  return Request.post<API.Category>({
    url: '/ware/category/form/create',
    data: data
  })
}

// 获取租户分类组件列表
export function getWidgetList(data: any) {
  return Request.get<API.WidgetList>({
    url: '/ware/widget/list',
    params: data
  })
}

// 创建分类组件
export function addWidget(data: API.AddWidgetParams) {
  return Request.post<API.AddWidgetResult>({
    url: '/ware/widget/create',
    data
  })
}

// 更新分类组件
export function updateWidget(data: any) {
  return Request.post({
    url: '/ware/widget/update',
    data
  })
}

// 删除组件
export function deleteWidget(widgetId: number | string) {
  return Request.post({
    url: '/ware/widget/del',
    data: { widgetId, deleteType: 'SOFT' }
  })
}

// 组件排序
export function widgetSort(data: API.WidgetSortParams) {
  return Request.post({
    url: '/ware/widget/sort',
    data
  })
}

// 获取插件列表
export function getPluginList(data: any) {
  return Request.get({
    url: '/ware/plugin/list',
    params: data
  })
}

// 创建插件
export function addPlugin(data: any) {
  return Request.post({
    url: '/ware/plugin/create',
    data
  })
}

// 更新插件信息
export function updatePlugin(data: any) {
  return Request.put({
    url: '/ware/plugin',
    method: 'put',
    data
  })
}

// 删除插件
export function deletePlugin(pluginId: number) {
  return Request.delete({
    url: `/ware/plugin/${pluginId}`
  })
}
