周沫沫历险记
2 years ago
4 changed files with 68 additions and 4 deletions
@ -0,0 +1,23 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
// 查询储备项目统计表
|
||||
|
async function getReserveItemReport(ctx, next) { |
||||
|
const { type } = ctx.request.query; |
||||
|
let rslt = null; |
||||
|
try { |
||||
|
rslt = await ctx.fs.dc.models.ReserveItemReport.findAll({ |
||||
|
order: [['year', 'DESC'], ['month', 'DESC']], |
||||
|
where: { type: type } |
||||
|
}) |
||||
|
ctx.status = 200 |
||||
|
ctx.body = rslt |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path:${ctx.path},error:${error}`) |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { name: 'FindAllError', message: '获取失败' } |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
getReserveItemReport |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
/* eslint-disable*/ |
||||
|
'use strict'; |
||||
|
|
||||
|
module.exports = dc => { |
||||
|
const DataTypes = dc.ORM; |
||||
|
const sequelize = dc.orm; |
||||
|
const ReserveItemReport = sequelize.define("reserveItemReport", { |
||||
|
year: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: true, |
||||
|
field: "year", |
||||
|
}, |
||||
|
month: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: true, |
||||
|
field: "month", |
||||
|
}, |
||||
|
path: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false, |
||||
|
field: "path", |
||||
|
}, |
||||
|
type: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: true, |
||||
|
field: "type", |
||||
|
} |
||||
|
}, { |
||||
|
tableName: "reserve_item_report", |
||||
|
}); |
||||
|
dc.models.ReserveItemReport = ReserveItemReport; |
||||
|
return ReserveItemReport; |
||||
|
}; |
@ -0,0 +1,8 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const report = require('../../controllers/report'); |
||||
|
|
||||
|
module.exports = function (app, router, opts) { |
||||
|
app.fs.api.logAttr['GET/getReserveItemReport'] = { content: '查询储备项目统计表', visible: false }; |
||||
|
router.get('/getReserveItemReport', report.getReserveItemReport); |
||||
|
}; |
Loading…
Reference in new issue