From 8d7388f685173fe650b8bc296e892542fffe337a Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 20 Oct 2022 14:31:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E5=81=87=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/attendance/index.js | 21 +++++++++++++++++++++ api/app/lib/routes/attendance/index.js | 3 +++ 2 files changed, 24 insertions(+) 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);