params-dict-control.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import ParamsDictService from "../service/params-dict-service.js";
  2. import ApiResult from "../config/api.js";
  3. const ParamsDictControl = {
  4. list: async (req, res) => {
  5. try {
  6. ParamsDictService.list(req.body).then(data => {
  7. res.send(new ApiResult().success(data))
  8. }).catch((e) => {
  9. res.send(new ApiResult().error(null, e))
  10. })
  11. } catch (e) {
  12. res.send(new ApiResult().error(e))
  13. }
  14. },
  15. page: async (req, res) => {
  16. try {
  17. ParamsDictService.page(req.body).then(data => {
  18. res.send(new ApiResult().success(data))
  19. }).catch((e) => {
  20. res.send(new ApiResult().error(null, e))
  21. })
  22. } catch (e) {
  23. res.send(new ApiResult().error(e))
  24. }
  25. },
  26. info: async (req, res) => {
  27. try {
  28. ParamsDictService.info(req.params.id).then(data => {
  29. res.send(new ApiResult().success(data))
  30. }).catch((e) => {
  31. res.send(new ApiResult().error(null, e))
  32. })
  33. } catch (e) {
  34. res.send(new ApiResult().error(e))
  35. }
  36. },
  37. add: async (req, res) => {
  38. try {
  39. ParamsDictService.add(req.body).then(data => {
  40. res.send(new ApiResult().success(data))
  41. }).catch((e) => {
  42. res.send(new ApiResult().error(null, e))
  43. })
  44. } catch (e) {
  45. res.send(new ApiResult().error(e))
  46. }
  47. },
  48. edit: async (req, res) => {
  49. try {
  50. ParamsDictService.edit(req.body).then(data => {
  51. res.send(new ApiResult().success(data))
  52. }).catch((e) => {
  53. res.send(new ApiResult().error(null, e))
  54. })
  55. } catch (e) {
  56. res.send(new ApiResult().error(e))
  57. }
  58. },
  59. del: async (req, res) => {
  60. try {
  61. ParamsDictService.del(req.params?.ids?.split(',')).then(data => {
  62. res.send(new ApiResult().success(data))
  63. }).catch((e) => {
  64. res.send(new ApiResult().error(null, e))
  65. })
  66. } catch (e) {
  67. res.send(new ApiResult().error(e))
  68. }
  69. },
  70. enabled: async (req, res) => {
  71. try {
  72. ParamsDictService.enabled(req.params?.ids?.split(',')).then(data => {
  73. res.send(new ApiResult().success(data))
  74. }).catch((e) => {
  75. res.send(new ApiResult().error(null, e))
  76. })
  77. } catch (e) {
  78. res.send(new ApiResult().error(e))
  79. }
  80. },
  81. disabled: async (req, res) => {
  82. try {
  83. ParamsDictService.disabled(req.params?.ids?.split(',')).then(data => {
  84. res.send(new ApiResult().success(data))
  85. }).catch((e) => {
  86. res.send(new ApiResult().error(null, e))
  87. })
  88. } catch (e) {
  89. res.send(new ApiResult().error(e))
  90. }
  91. },
  92. }
  93. export default ParamsDictControl