hover-control.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import HoverService from "../service/hover-service.js";
  2. import ApiResult from "../config/api.js";
  3. const HoverControl = {
  4. list: async (req, res) => {
  5. try {
  6. HoverService.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. HoverService.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. HoverService.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. HoverService.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. HoverService.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. HoverService.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. }
  71. export default HoverControl