You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.0 KiB
42 lines
1.0 KiB
'use strict';
|
|
|
|
async function statistic (ctx) {
|
|
try {
|
|
const models = ctx.fs.dc.models;
|
|
const { userId } = ctx.fs.api;
|
|
const { projectType } = ctx.query;
|
|
|
|
let findOption = {
|
|
where: {
|
|
reportType: 'conserve',
|
|
},
|
|
attributes: ['id', 'road', 'time', 'projectType', 'projectType'],
|
|
include: [{
|
|
model: models.User,
|
|
attributes: ['name']
|
|
}],
|
|
}
|
|
|
|
if (projectType) {
|
|
findOption.where.projectType = projectType;
|
|
}
|
|
|
|
const reportRes = await await models.Report.findAll(findOption)
|
|
|
|
ctx.status = 200
|
|
ctx.body = {
|
|
processed: reportRes.length,
|
|
reportList: reportRes,
|
|
}
|
|
} catch (error) {
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
|
|
ctx.status = 400;
|
|
ctx.body = {
|
|
message: typeof error == 'string' ? error : undefined
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
statistic,
|
|
};
|