import request from "@/utils/request";

/**
 * 获取所有Banner
 * @returns {Promise}
 */
export function getBanners() {
  return request({
    url: "/backend/allbanners",
    method: "get",
  });
}

/**
 * 创建Banner
 * @param {Object} bannerData Banner数据
 * @returns {Promise}
 */
export function createBanner(formData) {
  return request({
    url: "/backend/createbanner",
    method: "post",
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
}

/**
 * 编辑Banner
 * @param {number|string} id Banner ID
 * @param {Object} bannerData 更新的数据
 * @returns {Promise}
 */
export function editBanner(id, bannerData) {
  return request({
    url: `/backend/editbanner/${id}`,
    method: "post",
    data: bannerData,
  });
}

/**
 * 删除Banner
 * @param {number|string} id Banner ID
 * @returns {Promise}
 */
export function deleteBanner(id) {
  return request({
    url: `/backend/deletebanner/${id}`,
    method: "delete",
  });
}

