import request from "@/utils/request.js";

/**
 * 列表
 * @param params
 * @returns {AxiosPromise}
 */
export function categoryList() {
  return request({
    url: "/category/list/",
    method: "post"
  });
}

/**
 * 列表
 * @param params
 * @returns {AxiosPromise}
 */
export function articleList(params, id) {
  return request({
    url: "/article/list/" + id,
    method: "post",
    params
  });
}

/**
 * 新闻详情
 * @param params
 * @returns {AxiosPromise}
 */
export function articleDetail(id, err403) {
  return request({
    url: "/article/" + id,
    err403,
    method: "post"
  });
}

/**
 * 收藏列表
 * @param id
 * @returns {AxiosPromise}
 */
export function articleCollect(id) {
  let url = "/article/collect-list";
  if (id) url += "?lastCollectId=" + id;
  return request({
    url: url,
    method: "get"
  });
}

/**
 * 收藏
 * @param params
 * @returns {AxiosPromise}
 */
export function collect(id) {
  return request({
    url: "/article/collect/" + id,
    method: "get"
  });
}
/**
 * 取消收藏
 * @param params
 * @returns {AxiosPromise}
 */
export function collectCancel(id) {
  return request({
    url: "/article/collect-cancel/" + id,
    method: "get"
  });
}

/**
 * 点赞
 * @param params
 * @returns {AxiosPromise}
 */
export function digg(id) {
  return request({
    url: "/article/digg/" + id,
    method: "post"
  });
}
/**
 * 取消点赞
 * @param params
 * @returns {AxiosPromise}
 */
export function diggCancel(id) {
  return request({
    url: "/article/cancel-digg/" + id,
    method: "post"
  });
}

/**
 * 获得banner
 * @returns promise
 */
export function banner() {
  return request({
    url: "/article/banner"
  });
}
/**
 * 进度
 * @returns promise
 */
export function progress(data) {
  return request({
    url: "/article/progress",
    method: "post",
    data
  });
}

/**
 * 进度
 * @returns promise
 */
export function getReadHistory(params) {
  return request({
    url: "/article/history",
    method: "get",
    params
  });
}

/**
 * 添加评论
 * @returns promise
 */
export function getComment(data) {
  return request({
    url: "/article/add-comment",
    method: "post",
    data
  });
}

/**
 * 评论列表
 * @returns promise
 */
export function getCommentList(params, id) {
  return request({
    url: "/article/comment-list/" + id,
    method: "get",
    params
  });
}
