Built motion from commit 5e31ea4.|0.0.32
[motion.git] / server / api / report_chat / report_chat.controller.js
index 894eb55..d727f82 100644 (file)
@@ -1 +1,96 @@
-var _0xa8e7=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\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"];_0xa8e7[0];var _=require(_0xa8e7[1]);var ReportChat=require(_0xa8e7[3])[_0xa8e7[2]];var sequelize=require(_0xa8e7[3])[_0xa8e7[4]];exports[_0xa8e7[5]]=function(_0xde94x4,_0xde94x5){ReportChat[_0xa8e7[10]]()[_0xa8e7[9]](function(_0xde94x7){return _0xde94x5[_0xa8e7[8]](200)[_0xa8e7[7]](_0xde94x7)})[_0xa8e7[6]](function(_0xde94x6){return handleError(_0xde94x5,_0xde94x6)})};exports[_0xa8e7[11]]=function(_0xde94x4,_0xde94x5){ReportChat[_0xa8e7[15]](_0xde94x4[_0xa8e7[14]][_0xa8e7[13]])[_0xa8e7[9]](function(_0xde94x8){if(!_0xde94x8){return _0xde94x5[_0xa8e7[12]](404)};return _0xde94x5[_0xa8e7[7]](_0xde94x8);})[_0xa8e7[6]](function(_0xde94x6){return handleError(_0xde94x5,_0xde94x6)})};exports[_0xa8e7[16]]=function(_0xde94x4,_0xde94x5){ReportChat[_0xa8e7[16]](_0xde94x4[_0xa8e7[17]])[_0xa8e7[9]](function(_0xde94x8){return _0xde94x5[_0xa8e7[8]](201)[_0xa8e7[7]](_0xde94x8)})[_0xa8e7[6]](function(_0xde94x6){return handleError(_0xde94x5,_0xde94x6)})};exports[_0xa8e7[18]]=function(_0xde94x4,_0xde94x5,_0xde94x9){if(_0xde94x4[_0xa8e7[17]][_0xa8e7[13]]){delete _0xde94x4[_0xa8e7[17]][_0xa8e7[13]]};return ReportChat[_0xa8e7[15]](_0xde94x4[_0xa8e7[14]][_0xa8e7[13]])[_0xa8e7[9]](function(_0xde94x8){if(!_0xde94x8){return _0xde94x5[_0xa8e7[12]](404)};var _0xde94xa=_[_0xa8e7[19]](_0xde94x8,_0xde94x4[_0xa8e7[17]]);return _0xde94xa[_0xa8e7[20]]()[_0xa8e7[9]](function(){return _0xde94x5[_0xa8e7[8]](200)[_0xa8e7[7]](_0xde94x8)});})[_0xa8e7[6]](sequelize.ValidationError,function(_0xde94x6){return handleError(_0xde94x5,_0xde94x6)})[_0xa8e7[6]](function(_0xde94x6){return handleError(_0xde94x5,_0xde94x6)});};exports[_0xa8e7[21]]=function(_0xde94x4,_0xde94x5){ReportChat[_0xa8e7[15]](_0xde94x4[_0xa8e7[14]][_0xa8e7[13]])[_0xa8e7[9]](function(_0xde94x8){if(!_0xde94x8){return _0xde94x5[_0xa8e7[12]](404)};_0xde94x8[_0xa8e7[21]]()[_0xa8e7[9]](function(){return _0xde94x5[_0xa8e7[12]](204)})[_0xa8e7[6]](function(_0xde94x6){return handleError(_0xde94x5,_0xde94x6)});})[_0xa8e7[6]](function(_0xde94x6){return handleError(_0xde94x5,_0xde94x6)})};function handleError(_0xde94x5,_0xde94x6){return _0xde94x5[_0xa8e7[8]](500)[_0xa8e7[7]](_0xde94x6)}
\ No newline at end of file
+'use strict';
+
+var _ = require('lodash');
+var ReportChat = require('../../models').ReportChat;
+var sequelize = require('../../models').sequelize;
+
+// Get list of report_chats
+exports.index = function (req, res) {
+  ReportChat
+    .findAll()
+    .then(function (report_chats) {
+      return res.status(200).send(report_chats);
+    })
+    .catch(function (err) {
+      return handleError(res, err);
+    });
+};
+
+// Get a single reportChat
+exports.show = function (req, res) {
+  ReportChat
+    .findById(req.params.id)
+    .then(function (reportChat) {
+      if (!reportChat) {
+        return res.sendStatus(404);
+      }
+      return res.send(reportChat);
+    })
+    .catch(function (err) {
+      return handleError(res, err);
+    });
+};
+
+// Creates a new reportChat in the DB.
+exports.create = function (req, res) {
+  ReportChat
+    .create(req.body)
+    .then(function (reportChat) {
+      return res.status(201).send(reportChat);
+    })
+    .catch(function (err) {
+      return handleError(res, err);
+    });
+};
+
+// Updates an existing reportChat in the DB.
+exports.update = function (req, res, next) {
+  if (req.body.id) {
+    delete req.body.id;
+  }
+
+  return ReportChat
+    .findById(req.params.id)
+    .then(function (reportChat) {
+      if (!reportChat) {
+        return res.sendStatus(404);
+      }
+      var updated = _.merge(reportChat, req.body);
+      return updated
+        .save()
+        .then(function () {
+          return res.status(200).send(reportChat);
+        });
+    })
+    .catch(sequelize.ValidationError, function (err) {
+      return handleError(res, err);
+    })
+    .catch(function (err) {
+      return handleError(res, err);
+    });
+};
+
+// Deletes a reportChat from the DB.
+exports.destroy = function (req, res) {
+  ReportChat
+    .findById(req.params.id)
+    .then(function (reportChat) {
+      if (!reportChat) {
+        return res.sendStatus(404);
+      }
+      reportChat.destroy()
+        .then(function () {
+          return res.sendStatus(204);
+        })
+        .catch(function (err) {
+          return handleError(res, err);
+        });
+    })
+    .catch(function (err) {
+      return handleError(res, err);
+    });
+};
+
+function handleError(res, err) {
+  return res.status(500).send(err);
+}