import {upcloud_base_item} from "@/config/serviceSettings";
import request from '@/utils/request'
import qs from 'qs'

const baseUrl = upcloud_base_item;

export const api = {
  queryList: baseUrl + '/item/page',
  queryItem: baseUrl + '/item',
  addItem: baseUrl + '/item/add',
  uploadItem: baseUrl + '/item/update',
  deleteList: baseUrl + '/item/delete'
};

export function queryItem(parameter) {
  return request({
    method: 'get',
    url: api.queryItem,
    params: parameter,
  })
}

export function addItem(parameter) {
  return request({
    method: 'post',
    url: api.addItem,
    data: parameter,
  })
}

export function uploadItem(parameter) {
  return request({
    method: 'post',
    url: api.uploadItem,
    data: parameter,
  })
}

export function deleteList(parameter) {
  return request({
    method: 'post',
    url: api.deleteList,
    data: qs.stringify(parameter),
    headers: {
      'content-type': 'application/x-www-form-urlencoded'
    }
  })
}