import request from '@/utils/request'

/*
* 根据输入的字符搜索实体列表
* @param str
* @returns []
* */
function getEntityListByStr(str) {
    return request({
        method: 'get',
        url: '/show/entlist',
        data: {
            name: str
        }
    })
}

/**
 * 根据ID、度数获取实体，关系列表，实体类列表，关系类列表
 * @param id
 * @returns {*}
 */
function getEntityListByEntityId(id, degree, entClsIDs, relClsIDs, direction, entName) {
    let url = id ? `/knowledge/statisticalMap/all/${id}/list` : '/all/list'
    return request({
        method: 'get',
        url: url,
        path: {
            id: id
        },
        data: {
            degree: degree,
            entClsIDs: entClsIDs,
            relClsIDs: relClsIDs,
            direction: direction,
            entName: entName
        }
    })
}

/**
 * bf版本：根据ID、度数获取实体，关系列表，实体类列表，关系类列表
 * @param id
 * @returns {*}
 */
function getBfEntityListByEntityId(id, degree, entClsIDs, relClsIDs, direction) {
    return request({
        method: 'get',
        url: '/bf/all/{id}/list',
        path: {
            id: id
        },
        data: {
            degree: degree,
            entClsIDs: entClsIDs,
            relClsIDs: relClsIDs,
            direction: direction
        }
    })
}

/*
* 根据ID获取实体的详情
* @param id
* @return {}
* */
function getEntityInfoByEntityId(id) {
    return request({
        method: 'get',
        url: '/ent/{id}',
        path: {
            id: id
        }
    })
}

/*
* 根据ID获取实体属性的列表
* @param id
* @return {}
* */
function getEntityAttrsByEntityId(id, type) {
    return request({
        method: 'get',
        url: '/ent/{id}/attrs',
        path: {
            id: id
        },
        data: {
            attrType: type
        }
    })
}

/*
* 根据ID获取关系详情
* @param id
* @return {}
* */
function getRelationInfoByRelationId(id) {
    return request({
        method: 'get',
        url: '/show/{id}',
        path: {
            id: id
        }
    })
}

/*
* 根据ID获取关系属性的列表
* @param id
* @return {}
* */
function getRelationAttrsByRelationId(id) {
    return request({
        method: 'get',
        url: '/show/{id}/attrs',
        path: {
            id: id
        }
    })
}

/**
 * 显示图数据统计 实体类的信息以及实例化实体的个数
 * @param id
 * @returns {*}
 */
function getGraphEntClsTree(id) {
    return request({
        method: 'get',
        url: '/statistic/entclslist',
        path: {
            id: id
        }
    })
}

/**
 * 实体类下关系类以及该关系类下实体数量
 * @param id
 * @returns {*}
 */
function getRelclsentByEntClsId(entClsID) {
    return request({
        method: 'get',
        url: '/statistic/relclsent',
        data: {
            entClsID: entClsID
        }
    })
}

/**
 * 实体类ID获取属性类列表接口s
 * @param entClsID
 * @returns {*}
 */
function getAttrClsListByEntClsId(attrType, entClsID) {
    return request({
        method: 'get',
        url: '/attrcls/{id}/list',
        path: {
            id: entClsID
        },
        data: {
            attrType: attrType,
            id: entClsID
        }
    })
}

/**
 * 实体类下属性信息以及该属性所连实体数量
 * @param attrClsID
 * @param entClsID
 * @returns {*}
 */
function getAllAttrAndEntity(attrClsID, entClsID) {
    return request({
        method: 'get',
        url: '/statistic/attrent',
        data: {
            attrClsID: attrClsID,
            entClsID: entClsID
        }
    })
}

/**
 * 所有关系类以及关系类下实体数量（默认显示最大为100条关系类 按每个关系类下实体数量从大到小排列)
 * @returns {*}
 */
function getAllRelClsEnt() {
    return request({
        method: 'get',
        url: '/statistic/allrelclsent',
        data: {}
    })
}


function compare(data) {
    return request({
        method: 'post',
        url: '/show/graph/compare',
        data: data,
        headers: {'Content-Type': 'application/json;charset=UTF-8'},
        json: true
    })
}

export {
    getAllRelClsEnt,
    getAllAttrAndEntity,
    getAttrClsListByEntClsId,
    getRelclsentByEntClsId,
    getGraphEntClsTree,
    getEntityListByStr,
    getEntityListByEntityId,
    getBfEntityListByEntityId,
    getEntityInfoByEntityId,
    getEntityAttrsByEntityId,
    getRelationInfoByRelationId,
    getRelationAttrsByRelationId,
    compare
}
