import { getBanner, addBanner, updateBanner, deleteBanner, getByBannerId } from '@/api/banner'

const banner = {
  actions: {

    // 根据条件查询 banner
    GetBanner({ commit }, listQuery) {
      return new Promise((resolve, reject) => {
        getBanner(listQuery).then(response => {
          const data = response.data
          resolve(data)
        }).catch(error => {
          reject(error)
        })
        resolve
      })
    },

    // 添加 banner
    AddBanner({ commit }, banner) {
      return new Promise((resolve, reject) => {
        addBanner(banner).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 修改 banner
    UpdateBanner({ commit }, banner) {
      return new Promise((resolve, reject) => {
        updateBanner(banner).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 删除 banner
    DeleteBanner({ commit }, bannerId) {
      return new Promise((resolve, reject) => {
        deleteBanner(bannerId).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 根据bannerId查询 banner
    GetByBannerId({ commit }, bannerId) {
      return new Promise((resolve, reject) => {
        getByBannerId(bannerId).then(response => {
          const data = response.data
          resolve(data)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default banner
