import { request } from '@/api/_service'

const CATEGORY_BASE = 'system_settings/system_assistant/problem_help/category/'
const MARKDOWN_BASE = 'system_settings/system_assistant/problem_help/markdown/'

export function getCategoryTree (data) {
  return request({
    url: CATEGORY_BASE + 'tree',
    method: 'get',
    params: {
      method: 'system_settings_system_assistant_problem_category_tree',
      platform: 'background',
      ...data
    }
  })
}

export function setCategoryAdd (data) {
  return request({
    url: CATEGORY_BASE + 'add',
    method: 'post',
    data: {
      method: 'system_settings_system_assistant_problem_category_add',
      platform: 'background',
      ...data
    }
  })
}

export function setCategoryUpdate (data) {
  return request({
    url: CATEGORY_BASE + 'edit',
    method: 'put',
    data: {
      method: 'system_settings_system_assistant_problem_category_edit',
      platform: 'background',
      ...data
    }
  })
}

export function delCategory (data) {
  return request({
    url: CATEGORY_BASE + 'delete',
    method: 'post',
    data: {
      method: 'system_settings_system_assistant_problem_category_delete',
      platform: 'background',
      ...data
    }
  })
}

export function getProblemTree (data) {
  return request({
    url: MARKDOWN_BASE + 'tree',
    method: 'get',
    params: {
      method: 'system_settings_system_assistant_problem_markdown_tree',
      platform: 'background',
      ...data
    }
  })
}

export function getMarkdownDetails (data) {
  return request({
    url: MARKDOWN_BASE + 'details',
    method: 'get',
    params: {
      method: 'system_settings_system_assistant_problem_markdown_details',
      platform: 'background',
      ...data
    }
  })
}

export function setMarkdownAdd (data) {
  return request({
    url: MARKDOWN_BASE + 'add',
    method: 'post',
    data: {
      method: 'system_settings_system_assistant_problem_markdown_add',
      platform: 'background',
      ...data
    }
  })
}

export function setMarkdownEdit (data) {
  return request({
    url: MARKDOWN_BASE + 'edit',
    method: 'put',
    data: {
      method: 'system_settings_system_assistant_problem_markdown_edit',
      platform: 'background',
      ...data
    }
  })
}

export function delMarkdownDetails (data) {
  return request({
    url: MARKDOWN_BASE + 'del',
    method: 'delete',
    data: {
      method: 'system_settings_system_assistant_problem_markdown_del',
      platform: 'background',
      ...data
    }
  })
}

export function deleteProblem (data) {
  return request({
    url: MARKDOWN_BASE + 'delete',
    method: 'post',
    data: {
      method: 'del.problem.item',
      platform: 'admin',
      ...data
    }
  })
}

export function searchMarkdown (data) {
  return request({
    url: MARKDOWN_BASE + 'search',
    method: 'get',
    params: {
      method: 'system_settings_system_assistant_problem_markdown_search',
      platform: 'background',
      ...data
    }
  })
}

export function getRoleAll (data) {
  return request({
    url: 'system_settings/user_management/role/list',
    method: 'get',
    params: {
      method: 'system_settings_user_management_role_list',
      platform: 'background',
      page_size: 9999,
      ...data
    }
  })
}
