rationRepositoryController.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Created by Tony on 2017/4/20.
  3. */
  4. var rationRepository = require("../models/repositoryMap");
  5. var callback = function(req, res, err, message, data){
  6. res.json({error: err, message: message, data: data});
  7. };
  8. module.exports = {
  9. addRationRepository:function(req,res){
  10. var rationObj = JSON.parse(req.body.rationRepObj);
  11. rationRepository.addRationRepository(rationObj,function(err,data){
  12. if (data) {
  13. callback(req, res, err, "has data", data);
  14. } else {
  15. callback(req, res, err, "no data", null);
  16. }
  17. })
  18. },
  19. getDisPlayRationLibs: function(req, res){
  20. rationRepository.getDisplayRationLibs(function(err, data){
  21. if (data) {
  22. callback(req, res, err, "has data",data);
  23. } else {
  24. callback(req, res, err, "no data", null);
  25. }
  26. });
  27. },
  28. getRealLibName:function(req,res){
  29. var libName = req.body.rationName;
  30. rationRepository.getRealLibName(libName,function(err,data){
  31. if (data) {
  32. callback(req, res, err, "has data", data);
  33. } else {
  34. callback(req, res, err, "no data", null);
  35. }
  36. })
  37. },
  38. deleteRationLib:function(req,res){
  39. var rationName = req.body.rationName;
  40. rationRepository.deleteRationLib(rationName,function(err,data){
  41. if (data) {
  42. callback(req, res, err, "has data", data);
  43. } else {
  44. callback(req, res, err, "no data", null);
  45. }
  46. })
  47. },
  48. updateRationRepositoryName: function(req, res) {
  49. var orgName = req.body.rationName;
  50. var newName = req.body.newName;
  51. rationRepository.updateName(orgName, newName, function(err, data){
  52. if (data) {
  53. callback(req, res, err, "has data", data);
  54. } else {
  55. callback(req, res, err, "no data", null);
  56. }
  57. });
  58. }
  59. }