diff --git a/api/app/lib/controllers/attendance/index.js b/api/app/lib/controllers/attendance/index.js index 7ef3db0..3b7c63f 100644 --- a/api/app/lib/controllers/attendance/index.js +++ b/api/app/lib/controllers/attendance/index.js @@ -147,6 +147,26 @@ async function exportOvertimeStatistic (ctx) { } } +async function vacateType (ctx) { + try { + const { models } = ctx.fs.dc; + const { clickHouse } = ctx.app.fs + + const vacateTypeRes = await clickHouse.hr.query(` + SELECT type FROM vacate GROUP BY type ORDER BY type DESC + `).toPromise() + + ctx.status = 200; + ctx.body = vacateTypeRes + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + async function vacateStatistic (ctx) { try { const { models } = ctx.fs.dc; @@ -290,6 +310,7 @@ async function exportVacateStatistic (ctx) { module.exports = { overtimeStatistic, exportOvertimeStatistic, + vacateType, vacateStatistic, exportVacateStatistic, }; \ No newline at end of file diff --git a/api/app/lib/routes/attendance/index.js b/api/app/lib/routes/attendance/index.js index 075c6e1..cefea8e 100644 --- a/api/app/lib/routes/attendance/index.js +++ b/api/app/lib/routes/attendance/index.js @@ -9,6 +9,9 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/attendance/overtime/export'] = { content: '加班统计导出', visible: true }; router.get('/attendance/overtime/export', attendance.exportOvertimeStatistic); + app.fs.api.logAttr['GET/attendance/vacate/type'] = { content: '请假类型', visible: true }; + router.get('/attendance/vacate/type', attendance.vacateType); + app.fs.api.logAttr['GET/attendance/vacate'] = { content: '请假统计', visible: true }; router.get('/attendance/vacate', attendance.vacateStatistic);