DTHRouter.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // 倾斜数据管理模块
  2. const express = require("express");
  3. const router = express.Router();
  4. const pgClient = require("../../core/pgClient/pgClient.js");
  5. const sqlUtil = require("./sql.js");
  6. /* 1.获取所有数据 */
  7. router.post("/getAlldata", function (req, res) {
  8. let sqlstr = sqlUtil.getAlldata(req);
  9. // 执行sql
  10. pgClient.query(sqlstr).then((data) => {
  11. res.send(data);
  12. });
  13. });
  14. /* 1.获取所有接图表数据 */
  15. router.post("/getAllJieTuBiao", function (req, res) {
  16. let sqlstr = sqlUtil.getAllJieTuBiao(req);
  17. // 执行sql
  18. pgClient.query(sqlstr).then((data) => {
  19. res.send(data);
  20. });
  21. });
  22. /* 2.插入数据 */
  23. router.post("/InsertDataWithGeom", function (req, res) {
  24. let sqlstr = sqlUtil.InsertDataWithGeom(req);
  25. // 执行sql
  26. pgClient.query(sqlstr).then((data) => {
  27. res.send(data);
  28. });
  29. });
  30. /* 3.单体化点击查询 */
  31. router.post("/selectWithPoint", function (req, res) {
  32. let sqlstr = sqlUtil.selectWithPoint(req);
  33. // 执行sql
  34. pgClient.query(sqlstr).then((data) => {
  35. res.send(data);
  36. });
  37. });
  38. /* 接图表点击查询 */
  39. router.post("/selectWithJieTuPoint", function (req, res) {
  40. let sqlstr = sqlUtil.selectWithJieTuPoint(req);
  41. // 执行sql
  42. pgClient.query(sqlstr).then((data) => {
  43. res.send(data);
  44. });
  45. });
  46. /* 4.单体化table用id查询 */
  47. router.post("/qureyByID", function (req, res) {
  48. let sqlstr = sqlUtil.qureyByID(req);
  49. // 执行sql
  50. pgClient.query(sqlstr).then((data) => {
  51. res.send(data);
  52. });
  53. });
  54. /*接图表table用id查询 */
  55. router.post("/qureyByJieTuID", function (req, res) {
  56. let sqlstr = sqlUtil.qureyByJieTuID(req);
  57. // 执行sql
  58. pgClient.query(sqlstr).then((data) => {
  59. res.send(data);
  60. });
  61. });
  62. /* 5.更新数据 */
  63. router.post("/UpdataDataWithGeom", function (req, res) {
  64. let sqlstr = sqlUtil.UpdataDataWithGeom(req);
  65. // 执行sql
  66. pgClient.query(sqlstr).then((data) => {
  67. res.send(data);
  68. });
  69. });
  70. /* 5.单体化table用label查询*/
  71. router.post("/getDataByLabel", function (req, res) {
  72. let sqlstr = sqlUtil.getDataByLabel(req);
  73. // 执行sql
  74. pgClient.query(sqlstr).then((data) => {
  75. res.send(data);
  76. });
  77. });
  78. module.exports = router;