import request from '@/utils/request'

// 查询Banner列表
export function listBanner(query) {
  return request({
    url: '/back/banner/list',
    method: 'get',
    params: query
  })
}

// 查询Banner详细
export function getBanner(id) {
  return request({
    url: '/back/banner/' + id,
    method: 'get'
  })
}

// 新增Banner
export function addBanner(data) {
  return request({
    url: '/back/banner/add',
    method: 'post',
    data: {
      name: data.name,
      sort: data.sort,
      jumpUrl: data.jumpUrl || '',
      bannerAddr: data.bannerAddr
    },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 修改Banner
export function updateBanner(data) {
  return request({
    url: '/back/banner',
    method: 'put',
    data: {
      id: data.id,
      name: data.name,
      sort: data.sort,
      jumpUrl: data.jumpUrl || '',
      bannerAddr: data.bannerAddr
    },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 删除Banner
export function delBanner(id) {
  return request({
    url: '/back/banner/' + id,
    method: 'delete'
  })
} 