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

// 获取内容列表
export function getContentListApi(page, limit = 10,classify) {
  return request({
    url: `/admin/cms/${page}/${limit}?classify=${classify}`,
    method: "get",
  });
}

// 新增内容
export function saveContentApi(data) {
  return request({
    url: `/admin/cms/save`,
    method: "post",
    data
  });
}

// 更新内容
export function updateContentApi(data) {
  return request({
    url: `/admin/cms/update`,
    method: "put",
    data
  });
}

// 删除内容
export function deleteContentApi(id) {
  return request({
    url: `/admin/cms/remove/${id}`,
    method: "delete",
  });
}

// 上传图片
export function uploadImageApi(file) {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: '/admin/cms/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

