import request from '@/utils/request';

/**
 * 分页查询团队
 * @param params 查询条件
 */
export async function pageTeams(params) {
  const res = await request.get('/institution/team/page', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询团队列表
 * @param params 查询条件
 */
export async function listTeams(params) {
  const res = await request.get('/institution/team', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加团队
 * @param data 团队信息
 */
export async function addTeam(data) {
  const res = await request.post('/institution/team', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改团队
 * @param data 团队信息
 */
export async function updateTeam(data) {
  const res = await request.put('/institution/team', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除团队
 * @param id 团队id
 */
export async function removeTeam(id) {
  const res = await request.delete('/institution/team/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
