import http from '@/utils/request'

// 获取景点列表
export function getScenic (params) {
  // eslint-disable-next-line prefer-const
  let { pageNum = 1, pageSize = 10, status = ['inactive', 'active'] } = params
  status = status.map(val => {
    return `status=${val}`
  }).join('&')
  return http.get(`scenic/?pageSize=${params.pageSize !== undefined ? params.pageSize : 10}&pageNum=${pageNum}&pageSize=${pageSize}&${status}`)
}

// 获取景点列表
export function getScenicById (id) {
  return http.get(`scenic/${id}`)
}

// 添加景点
export function addScenic (params) {
  return http.post('scenic', params)
}

export function deleteScenic (id) {
  return http.delete(`scenic/${id}`)
}

// 编辑景点
export function updateScenic (id, params) {
  return http.put(`scenic/${id}`, params)
}

// 设置激活景点
export function setScenicActive (id, bool) {
  const params = {
    active: bool
  }
  return http.post(`scenic/${id}/active`, params)
}

// 获取景点标签
export function getScenicTag (pageNum = 1, pageSize = 999) {
  return http.get(`scenictag/?pageNum=${pageNum}&pageSize=${pageSize}`)
}

// 新增景点标签
export function addScenicTag (params) {
  return http.post('scenictag/', params)
}

// 编辑景点标签
export function setScenicTag (id, params) {
  return http.put(`scenictag/${id}`, params)
}

// 删除景点标签
export function deleteScenicTag (id) {
  return http.delete(`scenictag/${id}`)
}

// 获取景点自助机
export function getScenicTerms (id) {
  return http.get(`scenic/${id}/terms`)
}

// 获取景点自助机
export function setScenicTerms (id, terms) {
  return http.post(`scenic/${id}/terms`, {
    terms
  })
}

// 景点排序
export function updateScenicSeq (ids) {
  return http.post(`/scenic/updateseq`, {
    ids
  })
}
