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

/**
 * 工具类自动生成的API，请勿做任何修改，请勿做任何修改，请勿做任何修改（重要的事情说3遍）
 * 工具作者: 杨志杰
 * 角色CURD访问权限Resource 
 */
export default {

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据roleId、no查询window的定义 
	 */
  loadRoleIdWindowNo: function(roleId, no){
    var requestUrl = 'RoleCurdFieldResource/loadRoleIdWindowNo';
    var paramCount = 0;
    if(roleId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('roleId=' + roleId);
      paramCount ++;
    }
    if(no != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('no=' + no);
      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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 保存角色CURD访问权限信息 
	 */
  saveRoleCurdField: function(roleId, no, roleCurdFieldDtoList){
    var requestUrl = 'RoleCurdFieldResource/saveRoleCurdField';
    var paramCount = 0;
    if(roleId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('roleId=' + roleId);
      paramCount ++;
    }
    if(no != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('no=' + no);
      paramCount ++;
    }


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