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

/**
 * 工具类自动生成的API，请勿做任何修改，请勿做任何修改，请勿做任何修改（重要的事情说3遍）
 * 工具作者: 杨志杰
 * PC-会计科目接口. 
 */
export default {

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * PC-根据clientId全查询会计科目. 
	 */
  findByClientIdAndAccountSubjectClass: function(accountSubjectClass){
    var requestUrl = 'AccountSubjectResource/findByClientIdAndAccountSubjectClass';
    var paramCount = 0;
    if(accountSubjectClass != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('accountSubjectClass=' + accountSubjectClass);
      paramCount ++;
    }


    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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * PC-根据上级科目，获取最新的子级科目编号 
	 */
  getAccountSubjectNo: function(accountSubjectDto){
    var requestUrl = 'AccountSubjectResource/getAccountSubjectNo';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * PC-新增会计分类，新增会计分类子级 
	 */
  insert: function(accountSubjectDto){
    var requestUrl = 'AccountSubjectResource/insert';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据会计科目大类查询会计科目 
	 */
  queryAccountSubjectDtoByAccountSubjectClass: function(accountSubjectClass){
    var requestUrl = 'AccountSubjectResource/queryAccountSubjectDtoByAccountSubjectClass';
    var paramCount = 0;
    if(accountSubjectClass != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('accountSubjectClass=' + accountSubjectClass);
      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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * PC-编辑单条会计科目 
	 */
  update: function(accountSubjectDto){
    var requestUrl = 'AccountSubjectResource/update';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * PC-根据ID集合，批量删除，批量启用，批量禁用
通过operating的字符串来决定 是 批量删除delete，批量启用enable，批量禁用disable 
	 */
  updateByAccountSubjectIds: function(ids, operating){
    var requestUrl = 'AccountSubjectResource/updateByAccountSubjectIds';
    var paramCount = 0;
    if(operating != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('operating=' + operating);
      paramCount ++;
    }


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