import { config, networkUtils } from '../../utils';

const { request } = networkUtils;
const { api } = config;
const { bid } = api;
const { exams } = bid;

export async function query(params: object) {
  return request({
    url: exams,
    method: 'get',
    data: params,
  });
}

export async function getSingle(id: number) {
  return request({
    url: `${exams}/${id}`,
    method: 'get',
  });
}

export async function create(params: object) {
  return request({
    url: `${exams}/saveOrUpdate`,
    method: 'post',
    data: params,
  });
}

export async function remove(ids: number[]) {
  return request({
    url: exams,
    method: 'delete',
    data: ids,
  });
}

export async function update(params: object) {
  return request({
    url: exams,
    method: 'put',
    data: params,
  });
}

export async function queryList(id: number) {
  return request({
    url: `${exams}/${id}/bids`,
    method: 'get',
  });
}

export async function queryAllList(id: number) {
  return request({
    url: `${exams}/${id}/exams`,
    method: 'get',
  });
}

export async function canBid(id: number) {
  return request({
    url: `${exams}/canBid/${id}`,
    method: 'get',
  });
}
