import Vue from 'vue';
import Vuex from 'vuex';
import _ from 'lodash';
Vue.use(Vuex);
const api = {
  query: `/api/cms/advert/query`,
  fetch: id => `/api/cms/advert/fetch/${id}`,
  create: '/api/cms/advert/create',
  update: id => `/api/cms/advert/update/${id}`,
  delete: id => `/api/cms/advert/delete/${id}`,
};
export const state = () => ({});

export const mutations = {};

export const actions = {
  async advQuery({ commit }, { page = 1, size = 10, ...info }) {
    const skip = Math.max(0, (page - 1) * size);
    let options = { skip, limit: size };
    let res = await this.$axios.$get(api.query, { ...options, ...info });
    return res;
  },
  // async fetch({ commit }, payload) {
  //   let res = await this.$axios.$get(api.fetch(payload));
  //   return res;
  // },
  // async create({ commit }, payload) {
  //   let res = await this.$axios.$post(api.create, payload);
  //   return res;
  // },
  // async update({ commit }, { id, ...payload }) {
  //   let res = await this.$axios.$post(api.update(id), payload);
  //   return res;
  // },
  // async delete({ commit }, payload) {
  //   let res = await this.$axios.$post(api.delete(payload));
  //   return res;
  // },
};
