import request from '@/utils/request';

// 获取友情链接分类列表
export async function getCategoryList(params: API.PageRequest) {
  return request('/portals/classification/getPage', {
    method: 'POST',
    data: params,
  });
}

// 获取所有友情链接分类
export async function getAllCategories() {
  return request('/portals/classification/getAll', {
    method: 'GET',
  });
}

// 获取友情链接分类详情
export async function getCategoryDetail(id: string) {
  return request(`/portals/classification/${id}`, {
    method: 'GET',
  });
}

// 添加友情链接分类
export async function addCategory(data: API.CategoryRequest) {
  return request('/portals/classification', {
    method: 'POST',
    data,
  });
}

// 更新友情链接分类
export async function updateCategory(data: API.CategoryRequest) {
  return request('/portals/classification', {
    method: 'PUT',
    data,
  });
}

// 删除友情链接分类
export async function deleteCategory(id: string) {
  return request(`/portals/classification/${id}`, {
    method: 'DELETE',
  });
}

// 获取友情链接列表
export async function getLinkList(params: API.PageRequest) {
  return request('/portals/links/getPage', {
    method: 'POST',
    data: params,
  });
}

// 获取所有友情链接
export async function getAllLinks() {
  return request('/portals/links/getAll', {
    method: 'GET',
  });
}

// 添加友情链接
export async function addLink(data: API.LinkRequest) {
  return request('/portals/links', {
    method: 'POST',
    data,
  });
}

// 更新友情链接
export async function updateLink(data: API.LinkRequest) {
  return request('/portals/links', {
    method: 'PUT',
    data,
  });
}

// 删除友情链接
export async function deleteLink(id: string) {
  return request(`/portals/links/${id}`, {
    method: 'DELETE',
  });
}

// 启用友情链接
export async function enableLink(id: string) {
  return request(`/portals/links/up/${id}`, {
    method: 'POST',
  });
}

// 禁用友情链接
export async function disableLink(id: string) {
  return request(`/portals/links/down/${id}`, {
    method: 'POST',
  });
}

// 获取友情链接详情
export async function getLinkDetail(id: string) {
  return request(`/portals/links/${id}`, {
    method: 'GET',
  });
}
