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

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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 数据校验 
	 */
  check: function(curdWindow){
    var requestUrl = 'api/CurdWindowEditResource/check';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 删除一个curd 
	 */
  deleteOne: function(curdWindow){
    var requestUrl = 'api/CurdWindowEditResource/deleteOne';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 查询全部的CurdWindow的定义 
	 */
  list: function(){
    var requestUrl = 'api/CurdWindowEditResource/list';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据窗口名称、编号查询CurdWindow的定义 
	 */
  listByNameOrNo: function(){
    var requestUrl = 'api/CurdWindowEditResource/listByCondition';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 读取文件服务器下面{}/CurdWindow/{moduleNo}/{curdWindowNo}.js文件内容 
	 */
  readJs: function(){
    var requestUrl = 'api/CurdWindowEditResource/readJs';


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


  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 保存 
	 */
  save: function(curdWindow){
    var requestUrl = 'api/CurdWindowEditResource/save';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据查询窗口编号精确查询 
	 */
  uniqueByNo: function(curdWindowNo){
    var requestUrl = 'api/CurdWindowEditResource/uniqueByNo';
    var paramCount = 0;
    if(curdWindowNo != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('curdWindowNo=' + curdWindowNo);
      paramCount ++;
    }


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 向文件服务器下面{}/CurdWindow/{moduleNo}/{windowNo}.js 写入文件内容 
	 */
  writeJs: function(curdWindowJs){
    var requestUrl = 'api/CurdWindowEditResource/writeJs';


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