-'use strict';
-
-var _ = require('lodash');
-var SquareOdbc = require('../../models').SquareOdbc;
-var util = require('util');
-
-// Get list of square_odbcs
-exports.index = function(req, res) {
- var attributes = ['name', 'description'];
- var per_page = req.query.per_page ? parseInt(req.query.per_page, 10) : 100;
- var page = req.query.page ? parseInt(req.query.page, 10) : 0;
-
- var query = {
- where: {},
- limit: per_page,
- offset: page * per_page
- };
-
- _.forIn(req.query, function(value, key) {
- switch (key) {
- case 'per_page':
- case 'page':
- break;
- case 'sort_by':
- query.order = util.format('%s %s', req.query.sort_by, req.query.sort_order || 'ASC') || null;
- break;
- case 'sort_order':
- break;
- case '$':
- query.where.$or = [];
- attributes.forEach(function(attribute) {
- var tmp = {};
- tmp[attribute] = {
- $like: '%' + value + '%'
- };
-
- query.where.$or.push(tmp);
- });
- break;
- default:
- query.where[key] = {
- $like: {}
- };
- query.where[key].$like = '%' + value + '%';
- }
- });
-
- SquareOdbc
- .findAndCountAll(query)
- .then(function(result) {
-
- var total_pages = Math.ceil(result.count / per_page);
- var next_page = total_pages > (query.offset + 1) ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page + 1) : null;
- var previous_page = page > 0 ? util.format('%s://%s%s?page=%d', req.protocol, req.headers.host, req.baseUrl, page - 1) : null;
-
- res.status(200).send({
- count: result.count,
- rows: result.rows,
- next_page: next_page,
- previous_page: previous_page,
- total_pages: total_pages
- });
-
- })
- .catch(function(err) {
- res.status(500).send({
- error: 'Something blew up!'
- });
- });
-};
-
-exports.odbcValidation = function(req, res) {
- console.log(req.body);
- SquareOdbc
- .findAll({
- where: {
- name: req.body.name
- }
- })
- .then(function(square_odbcs) {
- if (!square_odbcs) {
- return res.sendStatus(404);
- }
- return res.send(square_odbcs);
- })
- .catch(function(err) {
- return handleError(res, err);
- });
-};
-
-// Get a single square_odbc
-exports.show = function(req, res) {
- SquareOdbc
- .findById(req.params.id)
- .then(function(square_odbc) {
- if (!square_odbc) {
- return res.sendStatus(404);
- }
- return res.send(square_odbc);
- })
- .catch(function(err) {
- return handleError(res, err);
- });
-};
-
-// Creates a new square_odbc in the DB.
-exports.create = function(req, res) {
- SquareOdbc
- .create(req.body)
- .then(function(square_odbc) {
- return res.status(201).send(square_odbc);
- })
- .catch(function(err) {
- return handleError(res, err);
- });
-};
-
-// Updates an existing square_odbc in the DB.
-exports.update = function(req, res) {
- SquareOdbc
- .findAll({
- where: {
- name: req.body.name,
- id: {
- $ne: req.body.id
- }
- }
- })
- .then(function(square_odbcs) {
- if (!square_odbcs) {
- return res.sendStatus(404);
- }
- if (square_odbcs.length > 0) {
- return res.status(500).send({
- message: 'MESSAGE_EXIST_ODBC'
- })
- }
- if (req.body.id) {
- delete req.body.id;
- }
- SquareOdbc
- .findById(req.params.id)
- .then(function(square_odbc) {
- if (!square_odbc) {
- return res.sendStatus(404);
- }
- var updated = _.merge(square_odbc, req.body);
- updated.save()
- .then(function() {
- return res.status(200).send(square_odbc);
- })
- .catch(function(err) {
- return handleError(res, err);
- });
- })
- .catch(function(err) {
- return handleError(res, err);
- });
- })
- .catch(function(err) {
- return handleError(res, err);
- });
-};
-
-// Deletes a square_odbc from the DB.
-exports.destroy = function(req, res) {
- SquareOdbc
- .find({
- where: {
- id: req.params.id
- }
- })
- .then(function(square_odbc) {
- if (!square_odbc) {
- return res.sendStatus(404);
- }
- square_odbc.destroy()
- .then(function() {
- return res.sendStatus(204);
- })
- .catch(function(err) {
- return handleError(res, err);
- });
- })
- .catch(function(err) {
- return handleError(res, err);
- });
-};
-
-// Deletes a square_project from the DB.
-exports.bulkDestroy = function(req, res) {
- SquareOdbc
- .destroy({
- where: {
- id: req.query.id
- },
- individualHooks: true
- })
- .then(function() {
- return res.sendStatus(204);
- })
- .catch(function(err) {
- return handleError(res, err);
- });
-};
-
-function handleError(res, err) {
- return res.status(500).send(err);
-}
+var _0x115b=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x53\x71\x75\x61\x72\x65\x4F\x64\x62\x63","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x6F\x64\x62\x63\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x6C\x6F\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x4F\x44\x42\x43","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x66\x69\x6E\x64","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x115b[0];var _=require(_0x115b[1]);var SquareOdbc=require(_0x115b[3])[_0x115b[2]];var util=require(_0x115b[4]);exports[_0x115b[5]]=function(_0x12f8x4,_0x12f8x5){var _0x12f8x6=[_0x115b[6],_0x115b[7]];var _0x12f8x7=_0x12f8x4[_0x115b[9]][_0x115b[8]]?parseInt(_0x12f8x4[_0x115b[9]][_0x115b[8]],10):100;var _0x12f8x8=_0x12f8x4[_0x115b[9]][_0x115b[10]]?parseInt(_0x12f8x4[_0x115b[9]][_0x115b[10]],10):0;var _0x12f8x9={where:{},limit:_0x12f8x7,offset:_0x12f8x8*_0x12f8x7};_[_0x115b[24]](_0x12f8x4[_0x115b[9]],function(_0x12f8xa,_0x12f8xb){switch(_0x12f8xb){case _0x115b[8]:;case _0x115b[10]:break ;;case _0x115b[13]:_0x12f8x9[_0x115b[11]]=util[_0x115b[16]](_0x115b[12],_0x12f8x4[_0x115b[9]][_0x115b[13]],_0x12f8x4[_0x115b[9]][_0x115b[14]]||_0x115b[15])||null;break ;;case _0x115b[14]:break ;;case _0x115b[22]:_0x12f8x9[_0x115b[18]][_0x115b[17]]=[];_0x12f8x6[_0x115b[21]](function(_0x12f8xc){var _0x12f8xd={};_0x12f8xd[_0x12f8xc]={$like:_0x115b[19]+_0x12f8xa+_0x115b[19]};_0x12f8x9[_0x115b[18]][_0x115b[17]][_0x115b[20]](_0x12f8xd);});break ;;default:_0x12f8x9[_0x115b[18]][_0x12f8xb]={$like:{}};_0x12f8x9[_0x115b[18]][_0x12f8xb][_0x115b[23]]=_0x115b[19]+_0x12f8xa+_0x115b[19];;}});SquareOdbc[_0x115b[39]](_0x12f8x9)[_0x115b[38]](function(_0x12f8xf){var _0x12f8x10=Math[_0x115b[30]](_0x12f8xf[_0x115b[29]]/_0x12f8x7);var _0x12f8x11=_0x12f8x10>(_0x12f8x9[_0x115b[31]]+1)?util[_0x115b[16]](_0x115b[32],_0x12f8x4[_0x115b[33]],_0x12f8x4[_0x115b[35]][_0x115b[34]],_0x12f8x4[_0x115b[36]],_0x12f8x8+1):null;var _0x12f8x12=_0x12f8x8>0?util[_0x115b[16]](_0x115b[32],_0x12f8x4[_0x115b[33]],_0x12f8x4[_0x115b[35]][_0x115b[34]],_0x12f8x4[_0x115b[36]],_0x12f8x8-1):null;_0x12f8x5[_0x115b[27]](200)[_0x115b[26]]({count:_0x12f8xf[_0x115b[29]],rows:_0x12f8xf[_0x115b[37]],next_page:_0x12f8x11,previous_page:_0x12f8x12,total_pages:_0x12f8x10});})[_0x115b[28]](function(_0x12f8xe){_0x12f8x5[_0x115b[27]](500)[_0x115b[26]]({error:_0x115b[25]})});};exports[_0x115b[40]]=function(_0x12f8x4,_0x12f8x5){console[_0x115b[42]](_0x12f8x4[_0x115b[41]]);SquareOdbc[_0x115b[44]]({where:{name:_0x12f8x4[_0x115b[41]][_0x115b[6]]}})[_0x115b[38]](function(_0x12f8x13){if(!_0x12f8x13){return _0x12f8x5[_0x115b[43]](404)};return _0x12f8x5[_0x115b[26]](_0x12f8x13);})[_0x115b[28]](function(_0x12f8xe){return handleError(_0x12f8x5,_0x12f8xe)});};exports[_0x115b[45]]=function(_0x12f8x4,_0x12f8x5){SquareOdbc[_0x115b[48]](_0x12f8x4[_0x115b[47]][_0x115b[46]])[_0x115b[38]](function(_0x12f8x14){if(!_0x12f8x14){return _0x12f8x5[_0x115b[43]](404)};return _0x12f8x5[_0x115b[26]](_0x12f8x14);})[_0x115b[28]](function(_0x12f8xe){return handleError(_0x12f8x5,_0x12f8xe)})};exports[_0x115b[49]]=function(_0x12f8x4,_0x12f8x5){SquareOdbc[_0x115b[49]](_0x12f8x4[_0x115b[41]])[_0x115b[38]](function(_0x12f8x14){return _0x12f8x5[_0x115b[27]](201)[_0x115b[26]](_0x12f8x14)})[_0x115b[28]](function(_0x12f8xe){return handleError(_0x12f8x5,_0x12f8xe)})};exports[_0x115b[50]]=function(_0x12f8x4,_0x12f8x5){SquareOdbc[_0x115b[44]]({where:{name:_0x12f8x4[_0x115b[41]][_0x115b[6]],id:{$ne:_0x12f8x4[_0x115b[41]][_0x115b[46]]}}})[_0x115b[38]](function(_0x12f8x13){if(!_0x12f8x13){return _0x12f8x5[_0x115b[43]](404)};if(_0x12f8x13[_0x115b[51]]>0){return _0x12f8x5[_0x115b[27]](500)[_0x115b[26]]({message:_0x115b[52]})};if(_0x12f8x4[_0x115b[41]][_0x115b[46]]){delete _0x12f8x4[_0x115b[41]][_0x115b[46]]};SquareOdbc[_0x115b[48]](_0x12f8x4[_0x115b[47]][_0x115b[46]])[_0x115b[38]](function(_0x12f8x14){if(!_0x12f8x14){return _0x12f8x5[_0x115b[43]](404)};var _0x12f8x15=_[_0x115b[53]](_0x12f8x14,_0x12f8x4[_0x115b[41]]);_0x12f8x15[_0x115b[54]]()[_0x115b[38]](function(){return _0x12f8x5[_0x115b[27]](200)[_0x115b[26]](_0x12f8x14)})[_0x115b[28]](function(_0x12f8xe){return handleError(_0x12f8x5,_0x12f8xe)});})[_0x115b[28]](function(_0x12f8xe){return handleError(_0x12f8x5,_0x12f8xe)});})[_0x115b[28]](function(_0x12f8xe){return handleError(_0x12f8x5,_0x12f8xe)})};exports[_0x115b[55]]=function(_0x12f8x4,_0x12f8x5){SquareOdbc[_0x115b[56]]({where:{id:_0x12f8x4[_0x115b[47]][_0x115b[46]]}})[_0x115b[38]](function(_0x12f8x14){if(!_0x12f8x14){return _0x12f8x5[_0x115b[43]](404)};_0x12f8x14[_0x115b[55]]()[_0x115b[38]](function(){return _0x12f8x5[_0x115b[43]](204)})[_0x115b[28]](function(_0x12f8xe){return handleError(_0x12f8x5,_0x12f8xe)});})[_0x115b[28]](function(_0x12f8xe){return handleError(_0x12f8x5,_0x12f8xe)})};exports[_0x115b[57]]=function(_0x12f8x4,_0x12f8x5){SquareOdbc[_0x115b[55]]({where:{id:_0x12f8x4[_0x115b[9]][_0x115b[46]]},individualHooks:true})[_0x115b[38]](function(){return _0x12f8x5[_0x115b[43]](204)})[_0x115b[28]](function(_0x12f8xe){return handleError(_0x12f8x5,_0x12f8xe)})};function handleError(_0x12f8x5,_0x12f8xe){return _0x12f8x5[_0x115b[27]](500)[_0x115b[26]](_0x12f8xe)}
\ No newline at end of file