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

/**
 * 工具类自动生成的API，请勿做任何修改，请勿做任何修改，请勿做任何修改（重要的事情说3遍）
 * 工具作者: 杨志杰
 * 历史查询资源类 
 */
export default {

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 删除对应类型的历史记录 
	 */
  deleteById: function(type, id){
    var requestUrl = 'HistoryQueryResource/deleteById';
    if(type != null){
      requestUrl += ('?type=' + type);
    }
    if(id != null){
      requestUrl += ('&id=' + id);
    }
    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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 删除对应类型的历史记录 
	 */
  deleteByType: function(type, windowNo, tabIndex){
    var requestUrl = 'HistoryQueryResource/deleteByType';
    if(type != null){
      requestUrl += ('?type=' + type);
    }
    if(windowNo != null){
      requestUrl += ('&windowNo=' + windowNo);
    }
    if(tabIndex != null){
      requestUrl += ('&tabIndex=' + tabIndex);
    }
    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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 查询历史查询记录 
	 */
  listByCondition: function(type, queryNum, windowNo, tabIndex){
    var requestUrl = 'HistoryQueryResource/listByCondition';
    if(type != null){
      requestUrl += ('?type=' + type);
    }
    if(queryNum != null){
      requestUrl += ('&queryNum=' + queryNum);
    }
    if(windowNo != null){
      requestUrl += ('&windowNo=' + windowNo);
    }
    if(tabIndex != null){
      requestUrl += ('&tabIndex=' + tabIndex);
    }
    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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 保存查询记录 
	 */
  save: function(historyQuerydto){
    var requestUrl = 'HistoryQueryResource/save';
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
        data: JSON.stringify(historyQuerydto),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },
};
