diff --git a/api/app/lib/controllers/overview/operation.js b/api/app/lib/controllers/overview/operation.js index d21eed83..4fde47db 100644 --- a/api/app/lib/controllers/overview/operation.js +++ b/api/app/lib/controllers/overview/operation.js @@ -92,9 +92,15 @@ async function vehicleStatistic (ctx) { type: 'vehicle' } }) + const freightTransport = await models.Statistic.findOne({ + where: { + type: 'freight' + } + }) const vehicleState = { passengerTransport: passengerTransport ? passengerTransport.count : 0, + freightTransport: freightTransport ? freightTransport.count : 0, taxi: await models.MunicipalVehicle.count({ where: { type: '出租车' diff --git a/api/app/lib/routes/data/index.js b/api/app/lib/routes/data/index.js index c8a2fe2b..68f800a0 100644 --- a/api/app/lib/routes/data/index.js +++ b/api/app/lib/routes/data/index.js @@ -20,6 +20,23 @@ module.exports = function (app, router, opts) { router.get('/data/god_trans', dataIndex.godTrans); // 运政 + //货运 + async function setVehicleType (ctx, next) { + ctx.request.body = { + ...(ctx.request.body || {}), + type: 'freight' + } + await next() + } + app.fs.api.logAttr['GET/vehicle/freight'] = { content: '获取运政列表', visible: true }; + router.get('/vehicle/freight', setVehicleType, vehicle.get); + + app.fs.api.logAttr['PUT/vehicle/freight'] = { content: '编辑运政数据', visible: true }; + router.put('/vehicle/freight', setVehicleType, vehicle.edit); + + app.fs.api.logAttr['DEL/vehicle/freight/:id'] = { content: '删除运政数据', visible: false }; + router.del('/vehicle/freight/:id', setVehicleType, vehicle.del); + //客运车 async function setVehicleType (ctx, next) { ctx.request.body = { diff --git a/scripts/1.1.0/data/1.create_freight_type.sql b/scripts/1.1.0/data/1.create_freight_type.sql new file mode 100644 index 00000000..74d1ddda --- /dev/null +++ b/scripts/1.1.0/data/1.create_freight_type.sql @@ -0,0 +1 @@ +INSERT INTO statistic (name, count, type) values ('货运车', 0, 'freight'); \ No newline at end of file