import baseAxios from './index'

export interface nodeInfo {
  id: number,
  parent_id: number,
  name: string,
  icon: string,
  path: string,
  position: number,
  document_num: number,
  create_time: number,
  create_by: number,
  update_by: number
}

export interface treeNode {
  info: nodeInfo,
  children: Array<treeNode>,
  /* 新增属性 */
  [propname: string]: any,
}

export async function queryDocTree() {
  return baseAxios<{ children: Array<treeNode> }>({
    url: '/document/category/tree',
    method: 'GET',
  })
}

export interface info {
  id: number,
  category_id: number,
  title: string,
  introduction: string,
  content: string,
  position: number,
  create_time: number,
  update_time: number,
  create_by: number,
  update_by: number,
  /* 新增属性 */
  [propname: string]: any,
}

export interface article {
  total?: number,
  list: info[],
}

export async function queryDocList(data: {
  category_id: number,
  page: number,
  page_size: number
}) {
  return baseAxios<article>({
    url: '/document/list',
    method: 'GET',
    params: data
  })
}

export async function queryDoc(data:{id:number}) {
  return baseAxios<info>({
    url:'/document',
    method:'GET',
    params:data
  })
}


