Built motion from commit 5e31ea4.|0.0.32
[motion.git] / server / api / report_chat_session / report_chat_session.controller.js
index 088f07c..7d61812 100644 (file)
@@ -1 +1,113 @@
-var _0xe1e8=["\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\x53\x65\x73\x73\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\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","\x64\x65\x73\x63\x72\x69\x62\x65","\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","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0xe1e8[0];var _=require(_0xe1e8[1]);var ReportChatSession=require(_0xe1e8[3])[_0xe1e8[2]];exports[_0xe1e8[4]]=function(_0xe320x3,_0xe320x4){ReportChatSession[_0xe1e8[9]]()[_0xe1e8[8]](function(_0xe320x6){return _0xe320x4[_0xe1e8[7]](200)[_0xe1e8[6]](_0xe320x6)})[_0xe1e8[5]](function(_0xe320x5){return handleError(_0xe320x4,_0xe320x5)})};exports[_0xe1e8[10]]=function(_0xe320x3,_0xe320x4){ReportChatSession[_0xe1e8[10]]()[_0xe1e8[8]](function(_0xe320x7){return _0xe320x4[_0xe1e8[7]](200)[_0xe1e8[6]](_0xe320x7)})[_0xe1e8[5]](function(_0xe320x5){return handleError(_0xe320x4,_0xe320x5)})};exports[_0xe1e8[11]]=function(_0xe320x3,_0xe320x4){ReportChatSession[_0xe1e8[15]](_0xe320x3[_0xe1e8[14]][_0xe1e8[13]])[_0xe1e8[8]](function(_0xe320x8){if(!_0xe320x8){return _0xe320x4[_0xe1e8[12]](404)};return _0xe320x4[_0xe1e8[6]](_0xe320x8);})[_0xe1e8[5]](function(_0xe320x5){return handleError(_0xe320x4,_0xe320x5)})};exports[_0xe1e8[16]]=function(_0xe320x3,_0xe320x4){ReportChatSession[_0xe1e8[16]](_0xe320x3[_0xe1e8[17]])[_0xe1e8[8]](function(_0xe320x8){return _0xe320x4[_0xe1e8[7]](201)[_0xe1e8[6]](_0xe320x8)})[_0xe1e8[5]](function(_0xe320x5){return handleError(_0xe320x4,_0xe320x5)})};exports[_0xe1e8[18]]=function(_0xe320x3,_0xe320x4){if(_0xe320x3[_0xe1e8[17]][_0xe1e8[13]]){delete _0xe320x3[_0xe1e8[17]][_0xe1e8[13]]};ReportChatSession[_0xe1e8[21]]({where:{id:_0xe320x3[_0xe1e8[14]][_0xe1e8[13]]}})[_0xe1e8[8]](function(_0xe320x8){if(!_0xe320x8){return _0xe320x4[_0xe1e8[12]](404)};var _0xe320x9=_[_0xe1e8[19]](_0xe320x8,_0xe320x3[_0xe1e8[17]]);_0xe320x9[_0xe1e8[20]]()[_0xe1e8[8]](function(){return _0xe320x4[_0xe1e8[7]](200)[_0xe1e8[6]](_0xe320x8)})[_0xe1e8[5]](function(_0xe320x5){return handleError(_0xe320x4,_0xe320x5)});})[_0xe1e8[5]](function(_0xe320x5){return handleError(_0xe320x4,_0xe320x5)});};exports[_0xe1e8[22]]=function(_0xe320x3,_0xe320x4){ReportChatSession[_0xe1e8[21]]({where:{id:_0xe320x3[_0xe1e8[14]][_0xe1e8[13]]}})[_0xe1e8[8]](function(_0xe320x8){if(!_0xe320x8){return _0xe320x4[_0xe1e8[12]](404)};_0xe320x8[_0xe1e8[22]]()[_0xe1e8[8]](function(){return _0xe320x4[_0xe1e8[12]](204)})[_0xe1e8[5]](function(_0xe320x5){return handleError(_0xe320x4,_0xe320x5)});})[_0xe1e8[5]](function(_0xe320x5){return handleError(_0xe320x4,_0xe320x5)})};function handleError(_0xe320x4,_0xe320x5){return _0xe320x4[_0xe1e8[7]](500)[_0xe1e8[6]](_0xe320x5)}
\ No newline at end of file
+'use strict';
+
+var _ = require('lodash');
+var ReportChatSession = require('../../models').ReportChatSession;
+
+// Get list of report_chat_sessions
+exports.index = function(req, res) {
+  ReportChatSession
+    .findAll()
+    .then(function(report_chat_sessions) {
+      return res.status(200).send(report_chat_sessions);
+    })
+    .catch(function(err) {
+      return handleError(res, err);
+    });
+};
+
+// Get list of fields
+exports.describe = function(req, res) {
+  ReportChatSession
+    .describe()
+    .then(function(fields) {
+      return res.status(200).send(fields);
+    })
+    .catch(function(err) {
+      return handleError(res, err);
+    });
+};
+
+// Get a single report_chat_session
+exports.show = function(req, res) {
+  ReportChatSession
+    .findById(req.params.id)
+    .then(function(report_chat_session) {
+      if (!report_chat_session) {
+        return res.sendStatus(404);
+      }
+      return res.send(report_chat_session);
+    })
+    .catch(function(err) {
+      return handleError(res, err);
+    });
+};
+
+// Creates a new report_chat_session in the DB.
+exports.create = function(req, res) {
+  ReportChatSession
+    .create(req.body)
+    .then(function(report_chat_session) {
+      return res.status(201).send(report_chat_session);
+    })
+    .catch(function(err) {
+      return handleError(res, err);
+    });
+};
+
+// Updates an existing report_chat_session in the DB.
+exports.update = function(req, res) {
+  if (req.body.id) {
+    delete req.body.id;
+  }
+  ReportChatSession
+    .find({
+      where: {
+        id: req.params.id
+      }
+    })
+    .then(function(report_chat_session) {
+      if (!report_chat_session) {
+        return res.sendStatus(404);
+      }
+      var updated = _.merge(report_chat_session, req.body);
+      updated.save()
+        .then(function() {
+          return res.status(200).send(report_chat_session);
+        })
+        .catch(function(err) {
+          return handleError(res, err);
+        });
+    })
+    .catch(function(err) {
+      return handleError(res, err);
+    });
+};
+
+// Deletes a report_chat_session from the DB.
+exports.destroy = function(req, res) {
+  ReportChatSession
+    .find({
+      where: {
+        id: req.params.id
+      }
+    })
+    .then(function(report_chat_session) {
+      if (!report_chat_session) {
+        return res.sendStatus(404);
+      }
+      report_chat_session.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);
+}