-'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 _0xb6e2=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6F\x64\x62\x63","\x53\x71\x75\x61\x72\x65\x4F\x64\x62\x63","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x67\x65\x74\x51\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x69\x64\x73","\x63\x68\x65\x63\x6B\x43\x6F\x6E\x6E\x65\x63\x74\x69\x6F\x6E","\x64\x73\x6E","\x63\x6C\x6F\x73\x65","\x6F\x70\x65\x6E"];_0xb6e2[0];var _=require(_0xb6e2[1]);var db=require(_0xb6e2[2])();var SquareOdbc=require(_0xb6e2[4])[_0xb6e2[3]];var Util=require(_0xb6e2[5]);exports[_0xb6e2[6]]=function(_0x21cax5,_0x21cax6){return SquareOdbc[_0xb6e2[13]](Util[_0xb6e2[12]](_0x21cax5[_0xb6e2[11]]))[_0xb6e2[10]](function(_0x21cax8){_0x21cax6[_0xb6e2[9]](200)[_0xb6e2[8]](_0x21cax8)})[_0xb6e2[7]](function(_0x21cax7){return handleError(_0x21cax6,_0x21cax7)})};exports[_0xb6e2[14]]=function(_0x21cax5,_0x21cax6){return SquareOdbc[_0xb6e2[18]](_0x21cax5[_0xb6e2[17]][_0xb6e2[16]])[_0xb6e2[10]](function(_0x21cax9){if(!_0x21cax9){return _0x21cax6[_0xb6e2[15]](404)};return _0x21cax6[_0xb6e2[8]](_0x21cax9)})[_0xb6e2[7]](function(_0x21cax7){return handleError(_0x21cax6,_0x21cax7)})};exports[_0xb6e2[19]]=function(_0x21cax5,_0x21cax6){return SquareOdbc[_0xb6e2[19]](_0x21cax5[_0xb6e2[20]])[_0xb6e2[10]](function(_0x21cax9){return _0x21cax6[_0xb6e2[9]](201)[_0xb6e2[8]](_0x21cax9)})[_0xb6e2[7]](function(_0x21cax7){return handleError(_0x21cax6,_0x21cax7)})};exports[_0xb6e2[21]]=function(_0x21cax5,_0x21cax6){if(_0x21cax5[_0xb6e2[20]][_0xb6e2[16]]){delete _0x21cax5[_0xb6e2[20]][_0xb6e2[16]]};return SquareOdbc[_0xb6e2[18]](_0x21cax5[_0xb6e2[17]][_0xb6e2[16]])[_0xb6e2[10]](function(_0x21cax9){if(!_0x21cax9){return _0x21cax6[_0xb6e2[15]](404)};var _0x21caxa=_[_0xb6e2[22]](_0x21cax9,_0x21cax5[_0xb6e2[20]]);_0x21caxa[_0xb6e2[23]]()[_0xb6e2[10]](function(){return _0x21cax6[_0xb6e2[9]](200)[_0xb6e2[8]](_0x21cax9)})[_0xb6e2[7]](function(_0x21cax7){return handleError(_0x21cax6,_0x21cax7)})})[_0xb6e2[7]](function(_0x21cax7){return handleError(_0x21cax6,_0x21cax7)})};exports[_0xb6e2[24]]=function(_0x21cax5,_0x21cax6){return SquareOdbc[_0xb6e2[18]](_0x21cax5[_0xb6e2[17]][_0xb6e2[16]])[_0xb6e2[10]](function(_0x21caxb){if(!_0x21caxb){return _0x21cax6[_0xb6e2[15]](404)};return _0x21caxb[_0xb6e2[24]]()})[_0xb6e2[10]](function(){return _0x21cax6[_0xb6e2[15]](204)})[_0xb6e2[7]](function(_0x21cax7){return handleError(_0x21cax6,_0x21cax7)})};exports[_0xb6e2[25]]=function(_0x21cax5,_0x21cax6){return SquareOdbc[_0xb6e2[24]]({where:{id:_0x21cax5[_0xb6e2[11]][_0xb6e2[26]]},individualHooks:true})[_0xb6e2[10]](function(){return _0x21cax6[_0xb6e2[15]](204)})[_0xb6e2[7]](function(_0x21cax7){return handleError(_0x21cax6,_0x21cax7)})};exports[_0xb6e2[27]]=function(_0x21cax5,_0x21cax6){return SquareOdbc[_0xb6e2[18]](_0x21cax5[_0xb6e2[17]][_0xb6e2[16]])[_0xb6e2[10]](function(_0x21cax9){if(!_0x21cax9){return _0x21cax6[_0xb6e2[15]](404)};db[_0xb6e2[30]](_0x21cax9[_0xb6e2[28]],function(_0x21cax7){if(_0x21cax7){return handleError(_0x21cax6,_0x21cax7)};db[_0xb6e2[29]](function(_0x21cax7){if(_0x21cax7){return handleError(_0x21cax6,_0x21cax7)};return _0x21cax6[_0xb6e2[15]](200)})})})[_0xb6e2[7]](function(_0x21cax7){return handleError(_0x21cax6,_0x21cax7)})};function handleError(_0x21cax6,_0x21cax7){return _0x21cax6[_0xb6e2[9]](500)[_0xb6e2[8]](_0x21cax7)}
\ No newline at end of file