import Common from '../common/Common.js';

/**
 * 工具类自动生成的API，请勿做任何修改，请勿做任何修改，请勿做任何修改（重要的事情说3遍）
 * 工具作者: 杨志杰
 * 工作流编辑Resource 
 */
export default {

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 删除工作流 
	 */
  deleteWorkflowDto: function(workflowDto){
    var requestUrl = 'workflowEditResource/deleteWorkflowDto';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(workflowDto),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 删除实例 
	 */
  deleteWorkflowResource: function(workflowDtos){
    var requestUrl = 'workflowEditResource/deleteWorkflowResource';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(workflowDtos),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 流程实例数量 
	 */
  getProcessInstanceCount: function(workflowDto){
    var requestUrl = 'workflowEditResource/getProcessInstanceCount';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
				
        dataType: 'json',
        data: JSON.stringify(workflowDto),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },


  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 获取所有工作流 
	 */
  getWorkflowDtos: function(queryParamDto){
    var requestUrl = 'workflowEditResource/getWorkflowDtos';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
				
        dataType: 'json',
        data: JSON.stringify(queryParamDto),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 获取工作流类型 
	 */
  getWorkflowTypes: function(){
    var requestUrl = 'workflowEditResource/getWorkflowTypes';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'get',
				
        dataType: 'json',
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 查询已经部署的流程id 
	 */
  queryDeploymentIds: function(){
    var requestUrl = 'workflowEditResource/queryDeploymentIds';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'get',
				
        dataType: 'json',
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 保存工作流 
	 */
  saveListWorkflowDto: function(workflowDtos){
    var requestUrl = 'workflowEditResource/saveListWorkflowDto';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
        dataType: 'json',
        data: JSON.stringify(workflowDtos),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 保存工作流 
	 */
  saveWorkflowDto: function(workflowDto, saveformData, saveProcessData, saveAdvancedSettingData, deployProcessData){
    var requestUrl = 'workflowEditResource/saveWorkflowDto';
    var paramCount = 0;
    if(saveformData != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('saveformData=' + saveformData);
      paramCount ++;
    }
    if(saveProcessData != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('saveProcessData=' + saveProcessData);
      paramCount ++;
    }
    if(saveAdvancedSettingData != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('saveAdvancedSettingData=' + saveAdvancedSettingData);
      paramCount ++;
    }
    if(deployProcessData != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('deployProcessData=' + deployProcessData);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(workflowDto),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 启动工作流 
	 */
  start: function(workflowDto){
    var requestUrl = 'workflowEditResource/start';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
				
				
        data: JSON.stringify(workflowDto),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 审批工作流程编辑器发布自动同步流程文件 
	 */
  syncApproverWorkflow: function(workflowId, bpmnFileName){
    var requestUrl = 'workflowEditResource/syncApproverWorkflow';
    var paramCount = 0;
    if(workflowId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('workflowId=' + workflowId);
      paramCount ++;
    }
    if(bpmnFileName != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('bpmnFileName=' + bpmnFileName);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'get',
        contentType: 'application/json',
				
				
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 同步工作流,将工作流文件部署到服务器 
	 */
  syncWorkflowDto: function(workflowDto){
    var requestUrl = 'workflowEditResource/syncWorkflowDto';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(workflowDto),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据工作流Id查询工作流的定义 
	 */
  uniqueById: function(id){
    var requestUrl = 'workflowEditResource/uniqueById';
    var paramCount = 0;
    if(id != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('id=' + id);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'get',
				
        dataType: 'json',
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },
};
