import { IQueryCommon, IRes, IResult } from '@/api/common'
import axios from '@/utils/request'
import { base, ITeam } from './common'

const uris = {
  base: `${base}/groupby`,
  page: `${base}/groupby/page`,
  del: `${base}/groupby/deleteByIds`
}

export const addTeam = (data: Omit<ITeam, 'id'>) =>
  axios.request<IRes<boolean>>({ url: uris.base, method: 'post', data })

export const deleteTeam = (id: string) => axios.request<IRes<boolean>>({ url: `${uris.base}/${id}`, method: 'delete' })

export const updateTeam = (data: ITeam) => axios.request<IRes<boolean>>({ url: uris.base, method: 'put', data })

export const getTeam = (id: string) => axios.request<IResult<ITeam>>({ url: `${uris.base}/${id}`, method: 'get' })

export const teamPage = (params: Partial<ITeam & IQueryCommon>) =>
  axios.request<IRes<ITeam[]>>({ url: uris.page, method: 'get', params })

export const deleteTeamBatch = (ids: string) =>
  axios.request<IRes<boolean>>({ url: uris.del, method: 'delete', params: { ids } })
