import httpRequest from '@/utils/axios'
/* ------------------------------------广告------------------------------------ */
/**
 * 获取广告列表
 * @param {string} type_id 类型id
 * @param {number} id_title id或标题
 * @param {string} project_id 项目id
 */
export function getAdList(params) {
  return httpRequest.get('/api/cms/admin/v1/advertisements', { params })
}
/**
 * 创建广告
 */
export function createAd(data) {
  return httpRequest.post('/api/cms/admin/v1/advertisement/create', data)
}
/**
 * 更新广告
 * @param {string} id 广告id
 * @param {object} data 广告表单数据
 */
export function updateAd(id, data) {
  return httpRequest.put(`/api/cms/admin/v1/advertisement/${id}/update`, data)
}
/**
 * 发布广告
 * @param {string} id
 * @param {number} data.is_publish 发布1 取消发布0
 */
export function publishAd(id, data) {
  return httpRequest.post(`/api/cms/admin/v1/advertisement/${id}/publish`, data)
}
/**
 * 审核广告
 * @param {string} id
 * @param {number} data.audit_status 2通过 3驳回
 * @param {string} data.audit_remarks 审核说明
 */
export function auditAd(id, data) {
  return httpRequest.post(`/api/cms/admin/v1/advertisement/${id}/audit`, data)
}
/**
 * 置顶广告
 * @param {string} id
 * @param {number} data.is_top 是否置顶：0否 1是
 * @param {number} data.weight 权重：0-10
 */
export function topAd(id, data) {
  return httpRequest.post(`/api/cms/admin/v1/advertisement/${id}/top`, data)
}
/**
 * 批量删除广告
 * @param {string} data.ids
 */
export function batchDeleteAd(data) {
  return httpRequest.post('/api/cms/admin/v1/advertisement/batch-delete', data)
}

/* ------------------------------------文章------------------------------------ */
/**
 * 获取文章列表
 * @param {string} type_id 类型id
 * @param {number} id_title id或标题
 * @param {string} project_id 项目id
 */
export function getArticleList(params) {
  return httpRequest.get('/api/cms/admin/v1/articles', { params })
}
/**
 * 创建文章
 */
export function createArticle(data) {
  return httpRequest.post('/api/cms/admin/v1/article/create', data)
}
/**
 * 更新文章
 * @param {string} id
 * @param {number} data
 */
export function updateArticle(id, data) {
  return httpRequest.put(`/api/cms/admin/v1/article/${id}/update`, data)
}
/**
 * 审核文章
 * @param {string} id
 * @param {number} data.audit_status 2通过 3驳回
 * @param {string} data.audit_remarks 审核说明
 */
export function auditArticle(id, data) {
  return httpRequest.post(`/api/cms/admin/v1/article/${id}/audit`, data)
}
/**
 * 发布文章
 * @param {string} id
 * @param {number} data.is_publish 发布1 取消发布0
 */
export function publishArticle(id, data) {
  return httpRequest.post(`/api/cms/admin/v1/article/${id}/publish`, data)
}
/**
 * 置顶文章
 * @param {string} id
 * @param {number} data.is_top 是否置顶：0否 1是
 */
export function topArticle(id, data) {
  return httpRequest.post(`/api/cms/admin/v1/article/${id}/top`, data)
}
/**
 * 推荐文章
 * @param {string} id
 * @param {number} data.is_recommend 是否推荐：0否 1是
 */
export function recommendArticle(id, data) {
  return httpRequest.post(`/api/cms/admin/v1/article/${id}/recommend`, data)
}
/**
 * 批量删除文章
 * @param {string} data.ids
 */
export function batchDeleteArticle(data) {
  return httpRequest.post('/api/cms/admin/v1/article/batch-delete', data)
}

/* ------------------------------------图文------------------------------------ */
/**
 * 获取图文列表
 * @param {string} type_id 类型id
 * @param {number} id_title id或标题
 * @param {string} project_id 项目id
 */
export function getImgTextList(params) {
  return httpRequest.get('/api/cms/admin/v1/img-texts', { params })
}
/**
 * 创建文章
 */
export function createImgText(data) {
  return httpRequest.post('/api/cms/admin/v1/img-text/create', data)
}
/**
 * 更新图文
 * @param {string} id
 * @param {number} data
 */
export function updateImgText(id, data) {
  return httpRequest.put(`/api/cms/admin/v1/img-text/${id}/update`, data)
}
/**
 * 审核图文
 * @param {string} id
 * @param {number} data.audit_status 2通过 3驳回
 * @param {string} data.audit_remarks 审核说明
 */
export function auditImgText(id, data) {
  return httpRequest.post(`/api/cms/admin/v1/img-text/${id}/audit`, data)
}
/**
 * 发布图文
 * @param {string} id
 * @param {number} data.is_publish 发布1 取消发布0
 */
export function publishImgText(id, data) {
  return httpRequest.post(`/api/cms/admin/v1/img-text/${id}/publish`, data)
}
/**
 * 获取广告/文章/图文新建时所选项目对应的类型
 * @param {number} content_type 类型 1文章 2广告 3图文
 * @param {string} params.project_id 项目id
 */
export function getProjectContentTypeList(type, params) {
  return httpRequest.get(`/api/cms/admin/v1/type/${type}/project`, { params })
}
/**
 * 置顶图文
 * @param {string} id
 * @param {number} data.is_top 是否置顶：0否 1是
 */
export function topImgText(id, data) {
  return httpRequest.post(`/api/cms/admin/v1/img-text/${id}/top`, data)
}
/**
 * 批量删除图文
 * @param {string} data.ids
 */
export function batchDeleteImgText(data) {
  return httpRequest.post('/api/cms/admin/v1/img-text/batch-delete', data)
}
