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

enum Api {
    GetVersionList = '/base-center/resourcesversion/getDVersion',
    SaveVersion = '/base-center/resourcesversion/saveVersion',
    DelVersion = '/base-center/resourcesversion/deleteVersion',

    GetResVersion = '/base-center/resourcesversion/getResVersion',
    SaveResVersion = '/base-center/resourcesversion/saveResVersion',
    RemoveResVersion = '/base-center/resourcesversion/removeResVersion',
    GetOneVersion = '/base-center/resourcesversion/getOneVersion'
}

/**
 * @description: 获取所有版本
 * @param page string 页码
 * @param rows string 每页大小
 * @param fid string 资源版本管理信息id
 * @param keyStr string 关键字
 * @param serviceType string 资源类型
 */
export const getVersionList = (params: any) => {
    let param = {
        page:1,
        rows:1000000,
        ...params
    }
    return new Promise<void>((resolve) => {
        defHttp.post({url: Api.GetVersionList, params: param }).then((res) => {
            resolve(res)
        })
    })
};

/**
 * @description: 保存版本
 * @param: 2:实体json {}
 */
export const saveVersion = (params: any) => {
    return new Promise<void>((resolve) => {
        defHttp.post({ url: Api.SaveVersion, params: params }).then((res) => {
            resolve(res)
        })
    })
};

/**
 * @description: 删除版本
 * @param fid string 版本id
 */
export const delVersion = (params: any) => {
    return new Promise<void>((resolve) => {
        defHttp.post({ url: Api.DelVersion, params: params }).then((res) => {
            resolve(res)
        })
    })
};

/**
 * @description: 获取大版本下的资源历史版本
 * @param page string 页码
 * @param rows string 每页大小
 * @param fid string 资源版本管理信息id
 * @param serviceType string 资源类型（MR、DR、ER、SR、interface）
 */
export const getResByVersion = (params: any) => {
    let param = {
        page:1,
        rows:1000000,
        ...params
    }
    return new Promise<void>((resolve) => {
        defHttp.post({ url: Api.GetOneVersion, params: param }).then((res) => {
            resolve(res)
        })
    })
};