import request from '../../utils/request';
import { AxiosPromise } from 'axios';
import {
    ModelVendorDto,
    ModelVendorForm,
    ModelVendorQuery
} from './type';

/**
 * 分页查询模型供应商列表
 * @param query 查询参数
 */
export const listModelVendor = (query?: ModelVendorQuery): AxiosPromise<{ list: ModelVendorDto[]; total: number }> => {
    return request({
        url: '/ai/model/vendor/page',
        method: 'get',
        params: query
    });
};

/**
 * 获取模型供应商详细信息
 * @param id 供应商编码
 */
export const getModelVendor = (id: string): AxiosPromise<ModelVendorDto> => {
    return request({
        url: `/ai/model/vendor/${id}`,
        method: 'get'
    });
};

/**
 * 新增模型供应商
 * @param data 表单数据
 */
export const addModelVendor = (data: ModelVendorForm): AxiosPromise<void> => {
    return request({
        url: '/ai/model/vendor',
        method: 'post',
        data
    });
};

/**
 * 修改模型供应商
 * @param data 表单数据
 */
export const updateModelVendor = (data: ModelVendorForm): AxiosPromise<void> => {
    return request({
        url: `/ai/model/vendor/${data.id}`,
        method: 'put',
        data
    });
};

/**
 * 删除模型供应商
 * @param id 供应商编码
 */
export const delModelVendor = (id: string): AxiosPromise<void> => {
    return request({
        url: `/ai/model/vendor/${id}`,
        method: 'delete'
    });
};
