import request from '@/utils/request';

/**
 * 列表
 */
export async function getPage(params) {
  const res = await request.get(`/ems/energy_type/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 详情
 */
export async function getById(id) {
  const res = await request.get(`/ems/energy_type/getById/${id}`, {});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 新增
 */
export async function save(data) {
  const res = await request.post(`/ems/energy_type/save`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改
 */
export async function update(data) {
  const res = await request.put(`/ems/energy_type/update`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 删除
 */
export async function deleteList(data) {
  const res = await request.delete(`/ems/energy_type/delete`, {
    data
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

