import request from '@/utils/request'

// 查询分类列表（树形结构）
export function listKnowledgeCategories() {
  return request({
    url: '/api/knowledge/categories',
    method: 'get'
  })
}

// 根据父分类ID查询子分类
export function listKnowledgeCategoriesByParent(parentId) {
  return request({
    url: `/api/knowledge/categories/parent/${parentId}`,
    method: 'get'
  })
}

// 获取分类详情
export function getKnowledgeCategory(id) {
  return request({
    url: `/api/knowledge/categories/${id}`,
    method: 'get'
  })
}

// 新增分类
export function addKnowledgeCategory(data) {
  return request({
    url: '/api/knowledge/categories',
    method: 'post',
    data
  })
}

// 修改分类
export function updateKnowledgeCategory(id, data) {
  return request({
    url: `/api/knowledge/categories/${id}`,
    method: 'put',
    data
  })
}

// 删除分类
export function deleteKnowledgeCategory(id) {
  return request({
    url: `/api/knowledge/categories/${id}`,
    method: 'delete'
  })
}

