import request from '@/utils/request'

/**
 * 获得指定实体类为起点的所有关系类列表
 * @param id
 * @returns {*}
 */
//旧的getAllRelationClassList函数
/* function getAllRelationClassList (id, entClsType) {
  return ajax({
    method: 'get',
    url: '/relcls/{id}/list',
    path: {
      id: id
    },
    data: {
      entClsType: entClsType,
    }
  })
} */
//新的getAllRelationClassList函数
function getAllRelationClassList(id, entClsType) {
	return request({
		method: 'get',
		url: `/knowledge/classRelation/relcls/${id}/list`,
		params: {
			id: id,
			entClsType: entClsType,
		}
	})
}

/**
 * 删除关系类
 * @param id
 * @returns {*}
 */
//旧的deleteRelationClass函数
/* function deleteRelationClass (id) {
  return ajax({
    method: 'post',
    url: '/relcls/del/{id}',
    path: {
      id: id
    }
  })
} */
//新的deleteRelationClass函数
function deleteRelationClass(id) {
	return request({
		method: 'post',
		url: `/knowledge/classRelation/relcls/del/${id}`,
		params: {
			id: id
		}
	})
}

/**
 * 通过名称获取所有关系类列表
 * @param name
 * @returns {*}
 */
//旧的getAllRelationClassListByName函数
/* function getAllRelationClassListByName (name, isModel, current, size) {
  return ajax({
    method: 'get',
    url: '/relcls/list',
    data: {
      name: name,
      current,
      size,
      isModel
    }
  })
} */
//新的getAllRelationClassListByName函数
function getAllRelationClassListByName(name, isModel, current, size) {
	return request({
		method: 'get',
		url: `/knowledge/classRelation/relcls/list`,
		params: {
			name: name,
			pageNum: current,
			pageSize: size,
			isModel
		}
	})
}

/**
 * 修改一个关系类名
 * @param data
 * @returns {*}
 */
//旧的editRelationClass函数
/* function editRelationClass (data) {
  return ajax({
    method: 'post',
    url: '/relcls/update',
    data: data
  })
} */
//新的editRelationClass函数
function editRelationClass(data) {
	return request({
		method: 'post',
		url: `/knowledge/classRelation/relcls/update`,
		data: data
	})
}

/**
 * 添加一个关系类
 * @param data
 * @returns {*}
 */
//旧的addRelationClass函数
/* function addRelationClass (data) {
  return ajax({
    method: 'post',
    url: '/relcls/add',
    data: data
  })
} */
//新的addRelationClass函数
function addRelationClass(data) {
	return request({
		method: 'post',
		url: `/knowledge/classRelation/relcls/add`,
		data: data
	})
}

/**
 * 新建实体关系
 * @param data
 * @returns {*}
 */
//旧的addEntityRelation函数
/* function addEntityRelation (data) {
  return ajax({
    method: 'post',
    url: '/rel/add',
    data: data
  })
} */
//新的addEntityRelation函数
function addEntityRelation(data) {
	return request({
		method: 'post',
		url: `/rel/add`,
		data: data
	})
}

/**
 * 删除实体关系
 * @param relID, isModel
 * @returns {*}
 */
//旧的deleteEntityRelation函数
/* function deleteEntityRelation (relID, isModel) {
  return ajax({
    method: 'post',
    url: '/rel/del/{id}',
    path: {
      id: relID
    },
    data: {
      id: relID,
      isModel
    }
  })
} */
//新的deleteEntityRelation函数
function deleteEntityRelation(relIds, isModel) {
	return request({
		method: 'delete',
		url: `/knowledge/entityRelation/rel/del/${relIds}`
	})
}

/**
 * 查找所有关系类
 * */
//旧的getAllRelationClass函数
/* function getAllRelationClass () {
  return ajax({
    method: 'post',
    url: '/relcls/getall'
  })
} */
//新的getAllRelationClass函数
function getAllRelationClass() {
	return request({
		method: 'get',
		url: `/knowledge/classRelation/relcls/getall`
	})
}

/**
 * 批量新增实体关系
 * */
//旧的addRelBatch函数
/* function addRelBatch (data) {
  return ajax({
    method: 'post',
    url: '/rel/add/batch',
    data: data
  })
} */
//新的addRelBatch函数
function addRelBatch(data) {
	return request({
		method: 'post',
		url: `/knowledge/entityRelation/rel/add/batch`,
		data: data
	})
}

/**
 * 查询此关系类所指向实体类还未有关联的实体列表
 * @param relClsId direction isModel current size
 * @returns {*}
 */
//旧的getEntityListByEntityClassId函数
/* function getRelclsUnpoint(relClsId, direction, entId, isModel, current, size) {
  return ajax({
    method: 'get',
    url: '/relcls/{direction}/{relClsId}/unpoint/{entId}',
    data: {
      current,
      size,
      isModel
    },
    path: {
      direction,
      relClsId,
      entId
    }
  })
} */
//新的getEntityListByEntityClassId函数
function getRelclsUnpoint(relClsId, direction, entId, isModel, current, size) {
	return request({
		method: 'get',
		url: `/relcls/${direction}/${relClsId}/unpoint/${entId}`,
		params: {
			pageNum: current,
			pageSize: size,
			isModel,
			direction,
			relClsId,
			entId
		}
	})
}

/**
 * 查询此关系类所指向实体类还未有关联的实体列表(带属性类)
 * @param relClsId direction isModel current size
 * @returns {*}
 */
//旧的getEntityListByEntityClassId函数
/* function getRelclsEnt(relClsId, direction, entId, isModel, entName, current, size) {
	return ajax({
		method: 'get',
		url: '/relcls/{direction}/{relClsId}/ent/{entId}',
		data: {
			entName,
			current,
			size,
			isModel
		},
		path: {
			direction,
			relClsId,
			entId
		}
	})
} */
//新的getEntityListByEntityClassId函数
function getRelclsEnt(relClsId, direction, entId, isModel, entName, current, size) {
	return request({
		method: 'get',
		url: `/knowledge/entity/relcls/${direction}/${relClsId}/ent/${entId}`,
		params: {
			entName,
			pageNum: current,
			pageSize: size,
			isModel,
			direction,
			relClsId,
			entId
		}
	})
}

/**
 * 批量编辑实体关系
 * */
//旧的editRelBatch函数
/* function editRelBatch(data) {
	return ajax({
		method: 'post',
		url: '/relattr/update/batch',
		data: data
	})
} */
//新的editRelBatch函数
function editRelBatch(data) {
	return request({
		method: 'post',
		url: `/relattr/update/batch`,
		data: data
	})
}

export {
	addRelationClass,
	getAllRelationClassList,
	deleteRelationClass,
	getAllRelationClassListByName,
	editRelationClass,
	deleteEntityRelation,
	addEntityRelation,
	getAllRelationClass,
	addRelBatch,
	getRelclsUnpoint,
	editRelBatch,
	getRelclsEnt
}
