import { PostJSON, GetJSON, PostFile, Post, Get, callFetchRawByFormData, Delete } from "../util/axios"

export function importElement(payload) {
  return PostFile("/dataassetmanager/elementApi/import", payload);
}

export function getLogs(payload) {
  return GetJSON("/dataassetmanager/elementApi/listOperationLogsByPage", payload);
}

export function listElements() {
  return PostJSON("/dataassetmanager/elementApi/listElements");
}

export function listElementsAndFillValue(payload) {
  return PostJSON("/dataassetmanager/elementApi/listElementAndFillValueByDirId", payload)
}

export function listUserElements() {
  return PostJSON("/dataassetmanager/elementApi/listSelectedRangeElements");
}

export function listCustomElements() {
  return GetJSON("/dataassetmanager/elementApi/listCustomElements");
}

export function listFilterElementIds(payload) {
  return GetJSON("/dataassetmanager/elementApi/listFilterElementIds", payload);
}

export function listFilterElements() {
  return GetJSON("/dataassetmanager/elementApi/listFilterElements");
}

// export function listFilterElementsGroupByType(payload) {
//   return GetJSON("/dataassetmanager/elementApi/listFilterElementsGroupByType", payload);
// }
export function listFilterElementsGroupByType(payload) {
  return GetJSON("/dataassetmanager/elementApi/listFilterElements", payload);
}

export function setupFilterElementIds(payload) {
  return PostJSON("/dataassetmanager/elementApi/setupFilterElementIds", payload);
}

export function listFilterElementIdsConfig() {
  return PostJSON("/dataassetmanager/configApi/listFilterElementIds");
}

export function setupFilterElementIdsConfig(payload) {
  return PostJSON("/dataassetmanager/configApi/setupFilterElementIds", payload);
}

export function addOrUpdateDataAsset(payload) {
  return PostJSON("/dataassetmanager/dataAssetApi/addOrUpdateDataAsset", payload);
}

export function checkCodeIsExist(payload) {
  return Post("/dataassetmanager/dataAssetApi/checkDataAssetCodeIsExist", payload);
}

export function checkDataAssetEditable(payload) {
  return Post("/dataassetmanager/dataAssetApi/checkDataAssetEditable", payload);
}

export function addDataAssetByDirIds(payload) {
  return PostJSON("/dataassetmanager/dataAssetApi/addDataAssetByDirIds", payload);
}

export function recoverDataAssetsFromRecycleBin(payload) {
  return PostJSON("/dataassetmanager/dataAssetApi/recoveryFromRecycleBin", payload);
}

export function deleteDataAssets(payload) {
  return PostJSON("/dataassetmanager/dataAssetApi/deleteDataAssets", payload);
}

export function getDataAssetDetail(payload) {
  return GetJSON("/dataassetmanager/dataAssetApi/getDataAssetDetail", payload);
}

export function listDataAssetDetails(payload) {
  return PostJSON("/dataassetmanager/dataAssetApi/listDataAssetDetails", payload);
}

export function listDataAssetsByPage(payload) {
  return GetJSON("/dataassetmanager/dataAssetApi/listDataAssetsByPage", payload);
}

export function listDataAssetsByPersonalCustomType(payload) {
  return GetJSON("/dataassetmanager/dataAssetApi/listDataAssetsByPersonalCustomType", payload);
}

export function listRecycleBinDataAssetsByPage(payload) {
  return GetJSON("/dataassetmanager/dataAssetApi/listRecycleBinDataAssetsByPage", payload);
}

export function loadDataAssets(payload) {
  return PostJSON("/dataassetmanager/dataAssetApi/loadDataAssets", payload);
}

export function listBusinessColumnElements(payload) {
  return GetJSON("/dataassetmanager/elementApi/listBusinessColumnElements", payload);
}

export function listDraftStates() {
  return GetJSON("/dataassetmanager/draftApi/listDraftStates")
}

export function loadDataAssetsAsDraft(payload) {
  return PostJSON("/dataassetmanager/draftApi/loadDataAssetsAsDraft", payload)
}

export function unloadDataAssets(payload) {
  return PostJSON("/dataassetmanager/dataAssetApi/unloadDataAssetsByDataAssetIdAndDirId", payload);
}

export function unloadDataAssetsFromAllDirs(payload) {
  return PostJSON("/dataassetmanager/dataAssetApi/unloadDataAssetsFromAllDirs", payload);
}

export function getDataAssetLocation(payload) {
  return GetJSON("/dataassetmanager/dataAssetApi/locateDataAssetById", payload);
}

export function createDataAssetByMetadataIds(payload) {
  return PostJSON("/dataassetmanager/dataAssetApi/createDataAssetByMetadataIds", payload);
}

export function importLogs(payload) {
  return GetJSON("/dataassetmanager/dataAssetApi/listDataAssetImportLogsByPage", payload);
}

export function importBusinessColumnLogs(payload) {
  return GetJSON("/dataassetmanager/dataAssetColumnApi/listBusinessColumnImportLogsByPage", payload);
}

export function recoveryFromRecycleBin(payload) {
  return PostJSON("/dataassetmanager/dataAssetApi/recoveryFromRecycleBin", payload);
}

export function getAssetPaths(payload) {
  return GetJSON("/dataassetmanager/dataAssetApi/getMultiPath", payload);
}

export function addOrUpdateDirectory(payload) {
  return PostJSON("/dataassetmanager/directoryApi/addOrUpdateDirectory", payload);
}

export function checkDirectoryDeleteAble(payload) {
  return Post("/dataassetmanager/directoryApi/checkDirDeleteAble", payload);
}

export function deleteDirectory(payload) {
  return PostJSON("/dataassetmanager/directoryApi/deleteDirectory", payload);
}

export function deletePersonalCustomDirectory(payload) {
  return PostJSON("/dataassetmanager/directoryApi/deletePersonalCustomDirectory", payload);
}

export function existDataAsset(payload) {
  return GetJSON("/dataassetmanager/directoryApi/existDataAsset", payload);
}

export function queryAllDirectoryAsTree(payload) {
  return GetJSON("/dataassetmanager/directoryApi/queryAllDirectoryAsTree", payload);
}

export function queryDirectoryTreeByMetadataId(payload) {
  return GetJSON("/dataassetmanager/directoryApi/queryDirectoryTreeByMetadataIdPath", payload)
}

export function queryDirectoryTreeAndElementTemplateByMetadataId(payload) {
  return GetJSON("/dataassetmanager/directoryApi/queryDirectoryTreeAndElementTemplateByMetadataIdPath", payload)
}

export function queryResourceDirectoryAsTree() {
  return PostJSON("/dataassetmanager/directoryApi/querySourceTypeAsTree");
}

export function queryAssetDirectoryAsTree() {
  return PostJSON("/dataassetmanager/directoryApi/queryDataAssetTypeAsTree");
}

export function listAllTopics(payload) {
  return GetJSON("/dataassetmanager/directoryApi/listAllTopics", payload);
}

export function directoryImport(payload) {
  return PostFile("/dataassetmanager/directoryApi/importCheckRepeatPath", payload);
}

export function previewTreeByCustomElements(payload) {
  return PostJSON("/dataassetmanager/directoryApi/previewAsTreeByCustomElements", payload);
}

export function previewTreeByCustomElementsAndResourceType(payload) {
  return PostJSON("/dataassetmanager/directoryApi/previewAsTreeByCustomElementsAndResourceType", payload); 
}

export function saveTreeByCustomElements(payload) {
  return PostJSON("/dataassetmanager/directoryApi/saveCustomElementTree", payload);
}

export function saveTreeByCustomElementsAndResourceType(payload) {
  return PostJSON("/dataassetmanager/directoryApi/savePersonalCustomElementTreeByResourceType", payload);
}

export function assetImport(payload) {
  return PostFile("/dataassetmanager/dataAssetApi/import", payload);
}

export function assetImportBusinessColumn(payload) {
  return PostFile("/dataassetmanager/dataAssetColumnApi/importBusinessColumn", payload);
}

export function getDirectoryById(payload) {
  return GetJSON("/dataassetmanager/directoryApi/getDirectoryById", payload);
}

export function getPersonalCustomDirectoryById(payload) {
  return GetJSON("/dataassetmanager/directoryApi/getPersonalCustomDirectoryById", payload);
}

export function upDownDirectory(payload) {
  return PostJSON("/dataassetmanager/directoryApi/upDownDirectory", payload);
}

export function upDownPersonalCustomDirectory(payload) {
  return PostJSON("/dataassetmanager/directoryApi/upDownPersonalCustomDirectory", payload);
}

export function listDirectoryByName(payload) {
  return GetJSON("/dataassetmanager/directoryApi/listDirectoryByName", payload);
}

export function getDirectoryChild(payload) {
  return GetJSON("/dataassetmanager/directoryApi/getChildByParentId", payload);
}

export function getPersonalCustomDirecotryChild(payload) {
  return GetJSON("/dataassetmanager/directoryApi/getPersonalCustomChildByParentId", payload);
}

export function getMetadataModelTree() {
  return GetJSON("/metadatarepo/rest/model/tree");
}

export function getAttributesByMetadataModel(payload) {
  return GetJSON("/dataassetmanager/eleAndAttrApi/getModelAttributes", payload);
}

export function loadElementWithoutCustom() {
  return GetJSON("/dataassetmanager/eleAndAttrApi/loadElementWithoutCustom");
}

export function saveEleAndAttrRel(payload) {
  return PostJSON("/dataassetmanager/eleAndAttrApi/saveEleAndAttrRel", payload);
}

export function getRelAttrByModel(payload) {
  return PostJSON("/dataassetmanager/eleAndAttrApi/getRelAttrByModel", payload);
}

export function listSourceModels() {
  return GetJSON("/dataassetmanager/eleAndAttrApi/listSourceModels")
}

export function saveEleAndAttrRelWithSourceModel(payload) {
  return PostJSON("/dataassetmanager/eleAndAttrApi/saveEleAndAttrRelWithSourceModel", payload)
}

export function getRelAttrBySourceModel(payload) {
  return GetJSON("/dataassetmanager/eleAndAttrApi/getRelAttrBySourceModel", payload)
}

export function deleteRelAttrBySourceModel(payload) {
  return PostJSON("/dataassetmanager/eleAndAttrApi/delEleAndAttrRelWithSourceModel", payload)
}

export function fillElementValueBeforeCreate(payload) {
  return PostJSON("/dataassetmanager/eleAndAttrApi/fillElementValueBeforeCreate", payload);
}

export function listSupportSourceModels() {
  return GetJSON("/dataassetmanager/eleAndAttrApi/listSupportSourceModels");
}

export function countResourceState(payload) {
  return GetJSON("/dataassetmanager/countApi/countResourceState", payload);
}

export function getResourceRelations(payload) {
  return GetJSON("/dataassetmanager/resourceApi/getResourceRelations", payload);
}

export function updateResourceState(payload) {
  return PostJSON("/dataassetmanager/resourceApi/updateResourceState", payload);
}

export function subs(payload) {
  return Get("/dataassetmanager/subApi/subs", payload);
}

export function startFlow(payload) {
  return Post("/dataassetmanager/flowApi/startDataAssetFlow", payload);
}

export function getSystems(payload) {
  return GetJSON(`/authservice/domains/${payload.env}/systems`);
}

export function getStandardTree(payload) {
  return GetJSON('/standard/rest/standard/maintain/tree/list', payload);
}

export function getStandardList(payload) {
  return PostJSON('/standard/rest/standard/maintain/standard/list', payload);
}

export function standardBatchMetadata(payload) {
  return PostJSON('/standard/indicator/save/batch', payload);
}

export function getMetadataStandardList(payload) {
  return PostJSON('/standard/indicator/find', payload);
}

export function deleteStandardBatchMetadata(payload) {
  return PostJSON('/standard/indicator/delete', payload);
}

export function exportIndicator(payload) {
  return callFetchRawByFormData('post', '/standard/indicator/exportData', payload)
}

export function importIndicator(payload) {
  return PostFile('/standard/indicator/import', payload);
}

export function importIndicatorLog(payload) {
  return GetJSON('/standard/indicator/importLog', payload);
}

export function getPermission(payload) {
  return GetJSON("/dataassetmanager/permissionApi/getPermissionDetail", payload);
}

export function getTemplates() {
  return GetJSON("/dataassetmanager/elementTemplateApi/listSupportTemplates")
}

export function getMetadataTemplates(payload) {
  return GetJSON("/dataassetmanager/elementTemplateApi/listSupportElementTemplatesByMetadataIdPath", payload)
}

export function checkAdmin() {
  return Post("/dataassetmanager/dataAssetApi/checkCurrentUserIsAdmin")
}

export function checkIsNeedSaveAsDraft(payload) {
  return Post("/dataassetmanager/dataAssetApi/checkIsNeedSaveAsDraft", payload)
}

export function checkDataKeyUser() {
  return Post("/dataassetmanager/dataAssetApi/checkCurrentUserIsDataKeyUser")
}

export function offline(payload) {
  return PostJSON("/dataassetmanager/dataAssetApi/offline", payload)
}

export function getDrafts(payload) {
  return GetJSON("/dataassetmanager/draftApi/listDataAssetsByPage", payload)
}

export function listDraftFilterElementsGroupByType(payload) {
  return GetJSON("/dataassetmanager/elementApi/listDraftFilterElements", payload);
}


export function getDraftDetail(payload) {
  return PostJSON("/dataassetmanager/draftApi/getDraftDetail", payload)
}

export function updateDraft(payload) {
  return PostJSON("/dataassetmanager/draftApi/updateDraft", payload)
}

export function deleteDrafts(payload) {
  return PostJSON("/dataassetmanager/draftApi/deleteDrafts", payload)
}

export function getDraftAssetPaths(payload) {
  return GetJSON("/dataassetmanager/draftApi/getMultiPath", payload)
}

export function checkDraftEditable(payload) {
  return Post("/dataassetmanager/draftApi/checkDraftEditable", payload)
}

export function publishDrafts(payload) {
  return PostJSON("/dataassetmanager/draftApi/publishDrafts", payload)
}

export function offlineAsDraft(payload) {
  return PostJSON("/dataassetmanager/draftApi/offlineAsDraft", payload)
}

export function saveAsDraft(payload) {
  return PostJSON("/dataassetmanager/draftApi/saveAsDraft", payload)
}

export function distributeTask(payload) {
  return PostJSON("/dataassetmanager/draftApi/distributeTask", payload)
}

export function reDistributeTask(payload) {
  return PostJSON("/dataassetmanager/draftApi/reDistributeTask", payload)
}

export function submitDraft(payload) {
  return PostJSON("/dataassetmanager/draftApi/submit", payload)
}

export function changeToPendingSubmitDraft(payload) {
  return PostJSON("/dataassetmanager/draftApi/changeToPendingSubmit", payload)
}

export function addSubscribe(payload) {
  return PostJSON("/subscribe/subscribe/add", payload)
}

export function deleteSubsribe(payload) {
  return Delete("/subscribe/subscribe/dels", payload)
}

export function subsribeDataList(payload) {
  return GetJSON("/subscribe/subscribe/subscribeDataList", payload)
}

export function startProcess(payload) {
  return PostJSON("/dataassetmanager/flowApi/startProcess", payload)
}

export function getRelatedServices(payload) {
  return PostJSON("/dataassetmanager/postApi/getRelatedServices", payload)
}

export function fillRelatedAssetsInfo(payload) {
  return PostJSON("/dataassetmanager/postApi/fillRelatedAssetsInfo", payload)
}

export function getDraftRelatedAssets(payload) {
  return PostJSON("/dataassetmanager/postDraftApi/getRelatedAssets", payload)
}

export function getDraftRelatedServices(payload) {
  return PostJSON("/dataassetmanager/postDraftApi/getRelatedServices", payload)
}

export function importDraftLogs(payload) {
  return GetJSON("/dataassetmanager/draftApi/listDraftImportLogsByPage", payload);
}

export function draftAssetImport(payload) {
  return PostFile("/dataassetmanager/draftApi/batchUpdateByImport", payload);
}

export function getRelatedAssets(payload) {
  return GetJSON("/dataassetmanager/dataAssetRelatedApi/listRelations", payload)
}

export function fillRelationDisplayInfo(payload) {
  return GetJSON("/dataassetmanager/dataAssetRelatedApi/fillRelationDisplayInfo", payload)
}

export function getColumns(payload) {
  return GetJSON("/dataassetmanager/dataAssetColumnApi/listColumnsByDataAssetId", payload)
}

export function getBusinessColumns(payload) {
  return GetJSON("/dataassetmanager/dataAssetColumnApi/listBusinessColumnsByDataAssetId", payload)
}

export function saveBusinessColumns(payload) {
  return PostJSON("/dataassetmanager/dataAssetColumnApi/saveBusinessColumnsByDataAssetId", payload)
}

export function listSupportReportTypes() {
  return GetJSON("/dataassetmanager/reportApi/listSupportReportTypes")
}

export function listWorkbooksByType(payload) {
  return GetJSON("/dataassetmanager/reportApi/listWorkbooks", payload)
}

export function getViewUrlByWorkbookId(payload) {
  return Get("/dataassetmanager/reportApi/getViewUrlByWorkbookId", payload)
}

export function saveWorkbookByType(payload) {
  return Post("/dataassetmanager/reportApi/saveWorkbook", payload)
}

export function deleteWorkbooks(payload) {
  return PostJSON("/dataassetmanager/reportApi/deleteWorkbooks", payload)
}

export function getEvaluations(payload) {
  return GetJSON('/dataassetmanager/evaluationApi/listProjects', payload)
}

export function saveEvaluation(payload) {
  return PostJSON('/dataassetmanager/evaluationApi/saveProject', payload)
}

export function runEvaluations(payload) {
  return PostJSON('/dataassetmanager/evaluationApi/run', payload)
}

export function deleteEvaluations(payload) {
  return PostJSON('/dataassetmanager/evaluationApi/deleteProjects', payload)
}

export function listTasks(payload) {
  return PostJSON("/dataassetmanager/dataAssetCheckApi/listTasks", payload);
}

export function saveTask(payload) {
  return PostJSON("/dataassetmanager/dataAssetCheckApi/saveTask", payload);
}

export function auditTask(payload) {
  return PostJSON("/dataassetmanager/dataAssetCheckApi/audit", payload);
}

export function uploadDataAssetExcel(payload) {
  return PostFile("/dataassetmanager/dataAssetCheckApi/uploadDataAssetExcel", payload, 'reportFile');
}

export function compareDataAssetWithDescribeInfo(payload) {
  return PostJSON("/dataassetmanager/versionApi/compareDataAssetWithDescribeInfo", payload);
}

export function listDataAssetHistoryTimeline(payload) {
  return GetJSON("/dataassetmanager/versionApi/listDataAssetHistoryTimeline", payload);
}

export function queryCustomTypeRootDirectory() {
  return GetJSON("/dataassetmanager/directoryApi/queryCustomTypeRootDirectory");
}

export function saveCustomTree(payload) {
  return PostJSON("/dataassetmanager/directoryApi/saveCustomElementTree", payload)
}

export function getPrivilegeByRange(payload) {
  return GetJSON("/dataassetmanager/AuthorityApi/listAllowButtonsByRange", payload);
}

export function getPrivilegeByRangeAndDirId(payload) {
  return GetJSON("/dataassetmanager/AuthorityApi/listAllowButtonsByRangeAndOptionId", payload);
}

export function submitForAudit(payload) {
  return PostJSON("/dataassetmanager/flowApi/submitForAudit", payload)
}

export function listSubmitForAuditAssetsInfo(payload) {
  return GetJSON("/dataassetmanager/flowApi/listSubmitForAuditAssetsInfo", payload)
}

export function uploadAttachment(payload) {
  return PostFile("/dataassetmanager/fileApi/uploadAttachment", payload)
}

export function processDetail(payload) {
  return GetJSON("/dataassetmanager/flowApi/processDetail", payload)
}

export function auditProcess(payload) {
  return PostJSON("/dataassetmanager/flowApi/auditProcess", payload)
}


