import request from '@/utils/request';
import type { Page } from '@/types/base';
import type {
    TeamApplicationQuery,
    TeamApplicationResponse,
    TeamApplicationRequest,
} from './types';

const BASE_URL = '/api/v1/team-applications';

/**
 * 分页查询团队应用关联
 */
export const getTeamApplications = (params?: TeamApplicationQuery) =>
    request.get<Page<TeamApplicationResponse>>(`${BASE_URL}/page`, { params });

/**
 * 根据ID获取团队应用关联
 */
export const getTeamApplicationById = (id: number) =>
    request.get<TeamApplicationResponse>(`${BASE_URL}/${id}`);

/**
 * 创建团队应用关联
 */
export const createTeamApplication = (data: TeamApplicationRequest) =>
    request.post<TeamApplicationResponse>(BASE_URL, data);

/**
 * 更新团队应用关联
 */
export const updateTeamApplication = (id: number, data: TeamApplicationRequest) =>
    request.put<TeamApplicationResponse>(`${BASE_URL}/${id}`, data);

/**
 * 删除团队应用关联
 */
export const deleteTeamApplication = (id: number) =>
    request.delete<void>(`${BASE_URL}/${id}`);

