import { defHttp } from '/@/utils/http/axios';

enum Api {
    GetVersionList = '/sdataversion/SDataVersionProvider/pageList',
    AddVersion = '/sdataversion/SDataVersionProvider/add',
    DelVersion = '/sdataversion/SDataVersionProvider/deleteByIds',
    GetVersionDetail = '/sdataversion/SDataVersionProvider/getDetailById',
    UpdateVersion = '/sdataversion/SDataVersionProvider/updateById'
}
const locationType = { apiUrl2: true };

/**
 * @description: 获取所有版本
 * @param: 1:用户登录tokenV2
 * @param: 2:实体json {}
 * @param: 3:页码
 * @param: 4.每页大小
 */
export const getVersionList = (params: any) => {
    return new Promise<void>((resolve) => {
        defHttp.post({ ...locationType, url: Api.GetVersionList, params: params }, { joinParamsToUrl: true }).then((res) => {
            resolve(res)
        })
    })
};

/**
 * @description: 新增版本
 * @param: 1:用户登录tokenV2
 * @param: 2:实体json {}
 */
export const addVersion = (params: any) => {
    return new Promise<void>((resolve) => {
        defHttp.post({ ...locationType, url: Api.AddVersion, params: params }, { joinParamsToUrl: true }).then((res) => {
            resolve(res)
        })
    })
};

/**
 * @description: 根据ids删除版本
 * @param: 1:用户登录tokenV2
 * @param: 2:ids
 */
export const delVersionByIds = (params: any) => {
    return new Promise<void>((resolve) => {
        defHttp.post({ ...locationType, url: Api.DelVersion, params: params }, { joinParamsToUrl: true }).then((res) => {
            resolve(res)
        })
    })
};

/**
 * @description: 更新版本信息
 * @param: 1: 用户登录tokenV2
 * @param: 2: 实体json {}
 */
export const updateVersion = (params: any) => {
    return new Promise<void>((resolve) => {
        defHttp.post({ ...locationType, url: Api.UpdateVersion, params: params }, { joinParamsToUrl: true }).then((res) => {
            resolve(res)
        })
    })
};

/**
 * @description: 获取版本下的资源详情
 * @param: 1: 用户登录tokenV2
 * @param: 2: id
 */
export const getVersionDetail = (params: any) => {
    return new Promise<void>((resolve) => {
        defHttp.post({ ...locationType, url: Api.GetVersionDetail, params: params }, { joinParamsToUrl: true }).then((res) => {
            resolve(res)
        })
    })
};