import { IQueryCommon, IRes, IResult } from '@/api/common'
import axios from '@/utils/request'
import { base, INeighbor } from './common'

const uris = {
  base: `${base}/sitelinkrelation`,
  page: `${base}/sitelinkrelation/list`,
  del: `${base}/sitelinkrelation/deleteByIds`
}

export const addNeighbor = (data: Omit<INeighbor, 'id'>) =>
  axios.request<IRes<boolean>>({ url: uris.base, method: 'post', data })

export const deleteNeighbor = (id: string) =>
  axios.request<IRes<boolean>>({ url: `${uris.base}/${id}`, method: 'delete' })

export const updateNeighbor = (data: INeighbor) => axios.request<IRes<boolean>>({ url: uris.base, method: 'put', data })

export const getNeighbor = (id: string) =>
  axios.request<IResult<INeighbor>>({ url: `${uris.base}/${id}`, method: 'get' })

export const neighborPage = (params: Partial<INeighbor & IQueryCommon>) =>
  axios.request<IRes<INeighbor[]>>({ url: uris.page, method: 'get', params })

export const deleteNeighborBatch = (ids: string) =>
  axios.request<IRes<boolean>>({ url: uris.del, method: 'delete', params: { ids } })
