import ajax from '../util'

/**
 * 根据实体查询
 * @param searchStr
 * @param entClsIDs
 * @param pagenum
 * @param pagesize
 * @param isModel
 * @returns {*}
 */
function entSearch(searchStr, entClsIDs, pagenum, pagesize, isModel, isIcon, searchType) {
    return ajax({
        method: 'get',
        url: '/ent/entquery',
        data: {
            searchStr: (searchType === 'name' || searchType == null) ? searchStr : null,
            entClsIDs,
            pagenum,
            pagesize,
            isModel,
            isIcon,
            unionID: searchType === 'id' ? searchStr : null
        }
    })
}

/**
 * 根据关系查询
 * @param searchStr
 * @param entClsIDs
 * @param pagenum
 * @param pagesize
 * @returns {*}
 */
function relSearch(searchStr, entClsIDs, pagenum, pagesize) {
    return ajax({
        method: 'get',
        url: '/rel/relquery',
        data: {
            searchStr: searchStr,
            entClsIDs: entClsIDs,
            pagenum: pagenum,
            pagesize: pagesize
        }
    })
}

/**
 * k跳查询
 * @param entID
 * @param maxHops
 * @param pagenum
 * @param pagesize
 * @returns {*}
 */
function kHopSearch(entID, maxHops, pagenum, pagesize) {
    return ajax({
        method: 'get',
        url: '/ent/khopquery',
        data: {
            entID: entID,
            maxHops: maxHops,
            pagenum: pagenum,
            pagesize: pagesize
        }
    })
}

/**
 * 标签查询
 * @param tagName
 * @returns {*}
 */

function getTag(tagName) {
    return ajax({
        method: 'get',
        url: '/tag/searchtagname',
        data: {
            tagName: tagName
        }
    })
}


/**
 * 测试目标查询
 * @param entName
 * @returns {*}
 */

function testTargetQuery(entName) {
    return ajax({
        method: 'get',
        url: '/activity/target/search/name',
        data: {
            entName: entName
        }
    })
}

/**
 * 测试活动查询
 * @param targetEntId
 * @param entName
 * @returns {*}
 */

function testActivityQuery(targetEntId, entName) {
    return ajax({
        method: 'get',
        url: '/activity/search/name',
        data: {
            entName: entName,
            targetEntId: targetEntId
        }
    })
}

/**
 * 测试活动表格
 * @param targetEntId
 * @param entName
 * @returns {*}
 */
function activityform(activityEntId) {
    return ajax({
        method: 'get',
        url: '/activity/ent',
        data: {
            activityEntId
        }
    })
}


/**
 * 测试活动表格
 * @param targetEntId
 * @param Name
 * @returns {*}
 */
function activityChildren(activityEntId) {
    return ajax({
        method: 'get',
        url: '/activity/ent/child',
        data: {
            activityEntId
        }
    })
}


/**
 * 测试主体
 * @param targetEntId
 * @returns {*}
 */
function subjectInterface(targetEntId) {
    return ajax({
        method: 'get',
        url: '/activity/main',
        data: {
            targetEntId
        }
    })
}

/**
 * 标签查询列表
 * @param labels
 * @param pagenum
 * @param pagesize
 * @param tagIDs
 * @returns {*}
 */

function getTagentList(labels, pagenum, pagesize, tagIDs) {
    return ajax({
        method: 'get',
        url: '/tag/tagentlist',
        data: {
            labels: labels,
            pagenum: pagenum,
            pagesize: pagesize,
            tagIDs: tagIDs
        }
    })
}


/**
 * 初始化后台方案生成接口
 * @returns {*}
 */
function initTestTarget() {
    return ajax({
        method: 'get',
        url: '/activity/init/cls/id'
    })
}

/**
 * 下载方案生成json接口
 * @returns {*}
 */
function downloadTargetJson(id) {
    return ajax({
        method: 'get',
        path: {
            id: id
        },
        url: '/activity/json/download/{id}'
    })
}


/**
 * 上传方案接口
 * @returns {*}
 */
 function uploadButton(file) {
    return ajax({
        method: 'post',
        path: {
            file: file
        },
        url: '/activity/file/import'
    })
}

export {
    entSearch,
    relSearch,
    kHopSearch,
    getTag,
    getTagentList,
    testTargetQuery,
    testActivityQuery,
    activityform,
    activityChildren,
    subjectInterface,
    initTestTarget,
    downloadTargetJson,
    uploadButton
}