import request from '@/utils/request'

/**
 * 通过实体id获取实体属性
 * @param opts
 * @id:id
 */
//旧的getEntityAttrById函数
/* function getEntityAttrById (id, data, isModel) {
  return ajax({
    method: 'get',
    url: '/ent/{id}/attrs',
    path: {
      id: id
    },
    data: {
      attrType: data.attrType,
      id: id,
      isModel
    }
  })
} */
//新的getEntityAttrById函数
function getEntityAttrById(id, data, isModel) {
	return request({
		method: 'get',
		url: `/knowledge/entityAttribute/ent/${id}/attrs`,
		params: {
			id: id,
			attrType: data.attrType,
			isModel
		}
	})
}

/**
 * 编辑实体属性
 * @param opts
 * @id:id
 */
//旧的updateEntityAttr函数
/* function updateEntityAttr (data) {
  return ajax({
    method: 'post',
    url: 'entattr/update',
    data: {
      attrID: data.attrID,
      attrClsID: data.attrClsID,
      attrMemo: data.attrMemo,
      attrType: data.attrType,
      attrValue: data.attrValue,
      entID: data.entID
    }
  })
} */
//新的updateEntityAttr函数
function updateEntityAttr(data) {
	return request({
		method: 'post',
		url: `entattr/update`,
		data: {
			attrID: data.attrID,
			attrClsID: data.attrClsID,
			attrMemo: data.attrMemo,
			attrType: data.attrType,
			attrValue: data.attrValue,
			entID: data.entID
		}
	})
}

/**
 * 通过实体id获取关系属性
 * @entId:实体id
 * @relId:关系id
 */
//旧的getRelationAttrById函数
/* function getRelationAttrById (path, entType) {
  return ajax({
    method: 'get',
    url: 'relattr/{id}/list',
    path: {
      id: path
    },
    data: {
      id: path,
      entType: entType
    }
  })
} */
//新的getRelationAttrById函数
function getRelationAttrById(path, entType) {
	return request({
		method: 'get',
		url: `relattr/${path}/list`,
		params: {
			id: path,
			entType: entType
		}
	})
}

/**
 * 通过实体类,属性,指标能力id查询列表
 * @param entClsId
 * @param attrClsId
 * @param abilityId
 * @returns {*}
 */
//旧的getTargetList函数
/* function getTargetList(entClsId, attrClsId, abilityId) {
	return ajax({
		method: 'get',
		url: '/sysmgt/list',
		data: {
			entClsId: entClsId,
			attrClsId: attrClsId,
			abilityId: abilityId
		}
	})
} */
//新的getTargetList函数
function getTargetList(entClsId, attrClsId, abilityId) {
	return request({
		method: 'get',
		url: `/sysmgt/list`,
		data: {
			entClsId: entClsId,
			attrClsId: attrClsId,
			abilityId: abilityId
		}
	})
}

/**
 * 获得指标能力树
 * @returns {*}
 */
//旧的getTargetAbilityTree函数
/* function getTargetAbilityTree() {
	return ajax({
		method: 'get',
		url: '/sysmgt/ability/tree',
		path: {}
	})
} */
//新的getTargetAbilityTree函数
function getTargetAbilityTree() {
	return request({
		method: 'get',
		url: `/sysmgt/ability/tree`,
		path: {}
	})
}

/**
 * 根据能力abilityId获取单个算法详情
 * @returns {*}
 */
//旧的getAlgorithmDetail函数
/* function getAlgorithmDetail(abilityId) {
	return ajax({
		method: 'get',
		url: '/sysmgt/flow',
		data: {
			abilityId: abilityId
		}
	})
} */
//新的getAlgorithmDetail函数
function getAlgorithmDetail(abilityId) {
	return request({
		method: 'get',
		url: `/sysmgt/flow`,
		data: {
			abilityId: abilityId
		}
	})
}

/**
 * 数组list参数保存指标
 * @param abilityParam
 * @returns {*}
 */
//旧的saveTargetList函数
/* function saveTargetList(abilityParam) {
	return ajax({
		method: 'post',
		url: '/sysmgt/add/array',
		headers: {
			'Content-Type': 'application/json;charset=UTF-8'
		},
		data: abilityParam,
		json: true
	})
} */
//新的saveTargetList函数
function saveTargetList(abilityParam) {
	return request({
		method: 'post',
		url: `/sysmgt/add/array`,
		headers: {
			'Content-Type': 'application/json;charset=UTF-8'
		},
		data: abilityParam,
		json: true
	})
}

/**
 * 获得指标树能力id
 * @param entClsId
 * @param attrClsId
 * @returns {*}
 */
//旧的getAbilityId函数
/* function getAbilityId(entClsId, attrClsId) {
	return ajax({
		method: 'get',
		url: '/sysmgt/getability',
		data: {
			entClsId: entClsId,
			attrClsId: attrClsId
		}
	})
} */
//新的getAbilityId函数
function getAbilityId(entClsId, attrClsId) {
	return request({
		method: 'get',
		url: `/sysmgt/getability`,
		data: {
			entClsId: entClsId,
			attrClsId: attrClsId
		}
	})
}

/**
 * 运行测试
 * @param entId
 * @param attrClsId
 * @returns {*}
 */
//旧的runFlow函数
/* function runFlow(entId, attrClsId, isModel) {
	return ajax({
		method: 'post',
		url: '/sysmgt/run/flow',
		data: {
			entId: entId,
			attrClsId: attrClsId,
			isModel
		}
	})
} */
//新的runFlow函数
function runFlow(entId, attrClsId, isModel) {
	return request({
		method: 'post',
		url: `/sysmgt/run/flow`,
		data: {
			entId: entId,
			attrClsId: attrClsId,
			isModel
		}
	})
}

/**
 * 删除属性值
 * @param attrID
 * @returns {*}
 */
//旧的deleteAttrValue函数
/* function deleteAttrValue(attrID) {
	return ajax({
		method: 'post',
		url: '/attr/del',
		data: {
			attrID: attrID
		}
	})
} */
//新的deleteAttrValue函数
function deleteAttrValue(attrID) {
	return request({
		method: 'post',
		url: `/attr/del`,
		data: {
			attrID: attrID
		}
	})
}

export {
	deleteAttrValue,
	runFlow,
	getAbilityId,
	saveTargetList,
	getEntityAttrById,
	updateEntityAttr,
	getRelationAttrById,
	getTargetList,
	getTargetAbilityTree,
	getAlgorithmDetail
}
