import request from '@/utils/request.js';

/**
 * 获取模板列表
 */
export async function getPosterTemplateList() {
  const res = await request.get('/barmgr/poster/posterTemplateList');
  // const res = await request.get('/barmgr/poster/fixUserToken');
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 复制模版
 */
export async function copyPosterTemplate(id) {
  const res = await request.get('/barmgr/poster/copy/' + id);
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 删除模版
 */
export async function delPosterTemplate(id) {
  const res = await request.get('/barmgr/poster/del/' + id);
  if (res.data.code === 200) {
    return res.data.msg;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取编辑器访问令牌
 */
export async function getEditorToken(data) {
  const res = await request.post('/barmgr/editor/getToken', data);
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
