import { Common } from 'pc-component-v3';

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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 *  
	 */
  findByIdAndClientId: function(id){
    var requestUrl = 'InventoryResource/findByIdAndClientId';
    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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据条件分页查询存货 
	 */
  findByQueryCodition: function(inventoryQueryConditionRequest){
    var requestUrl = 'InventoryResource/findByQueryCodition';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据QueryParamDto查询InventoryDto2 
	 */
  findByQueryParamDto: function(queryParamDto){
    var requestUrl = 'InventoryResource/findByQueryParamDto';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据InventorId查询Inventor详情 
	 */
  findInventoryById: function(inventoryId){
    var requestUrl = 'InventoryResource/findInventoryById';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 查询消耗品 
	 */
  findInventoryDto: function(start, length, searchString, isPrinted, addSelectCondition){
    var requestUrl = 'InventoryResource/findInventoryDto';
    var paramCount = 0;
    if(start != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('start=' + start);
      paramCount ++;
    }
    if(length != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('length=' + length);
      paramCount ++;
    }
    if(searchString != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('searchString=' + searchString);
      paramCount ++;
    }
    if(isPrinted != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('isPrinted=' + isPrinted);
      paramCount ++;
    }
    if(addSelectCondition != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('addSelectCondition=' + addSelectCondition);
      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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * APP端存货新增字段查询dto 
	 */
  findInventoryFieldByClientId: function(){
    var requestUrl = 'InventoryResource/findByClientId';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据存货编号、名称保存新的存货 
	 */
  insert: function(inventoryDto){
    var requestUrl = 'InventoryResource/insert';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 查询消耗品 
	 */
  queryInventoryByCondition: function(param){
    var requestUrl = 'InventoryResource/queryInventoryByCondition';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据存货id、编号、名称更新存货 
	 */
  update: function(inventoryDto){
    var requestUrl = 'InventoryResource/update';


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