Browse Source

获取配置

CzRger 1 year ago
parent
commit
6258e6e521

+ 16 - 0
ship-test/control/ship-filter-control.js

@@ -0,0 +1,16 @@
+import SourceService from "../service/source-service.js";
+import ApiResult from "../config/api.js";
+const ShipFilterControl = {
+  getConfig: async (req, res) => {
+    try {
+      SourceService.list({orderByColumn: 'sort', isAsc: false}).then(data => {
+        res.send(new ApiResult().success(data))
+      }).catch((e) => {
+        res.send(new ApiResult().error(null, e))
+      })
+    } catch (e) {
+      res.send(new ApiResult().error(e))
+    }
+  },
+}
+export default ShipFilterControl

+ 2 - 0
ship-test/routers/index.js

@@ -1,5 +1,6 @@
 import express from 'express'
 import SourceControl from "../control/source-control.js";
+import ShipFilterControl from "../control/ship-filter-control.js";
 const shipTestRouter = express.Router()
 shipTestRouter.post('/source/list', SourceControl.list)
 shipTestRouter.post('/source/page', SourceControl.page)
@@ -7,4 +8,5 @@ shipTestRouter.get('/source/info/:id', SourceControl.info)
 shipTestRouter.post('/source/add', SourceControl.add)
 shipTestRouter.put('/source/edit', SourceControl.edit)
 shipTestRouter.delete('/source/del/:ids', SourceControl.del)
+shipTestRouter.get('/ship-filter/get-config', ShipFilterControl.getConfig)
 export default shipTestRouter

+ 1 - 0
ship-test/service/source-service.js

@@ -22,6 +22,7 @@ const SourceService = {
         const result = await sqlHandle(sql)
         resolve(result.map(v => new SourceEntity(v)))
       } catch (e) {
+        console.log(e)
         reject(e.sqlMessage)
       }
     })