source-control.js 1.3 KB

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