- 전사 휴가 부여/관리 (company-holidays) CRUD + 연차차감 트랜잭션 - 전체 휴가관리 대시보드 (vacation-dashboard) 부서별/직원별 현황 - 내 휴가 현황 개선 (/my-status) balance_type별 카드, 전사 휴가일 - requireSupportTeam 미들웨어, 부서명 JOIN, 마이그레이션 002 추가 - 사이드바 roles 기반 메뉴 필터링 (하위호환 유지) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
const vacationDashboardModel = require('../models/vacationDashboardModel');
|
|
|
|
const vacationDashboardController = {
|
|
async getDashboard(req, res) {
|
|
try {
|
|
const year = parseInt(req.query.year) || new Date().getFullYear();
|
|
const filters = {
|
|
department_id: req.query.department_id || null,
|
|
search_name: req.query.search_name || null
|
|
};
|
|
|
|
const [summary, rows] = await Promise.all([
|
|
vacationDashboardModel.getSummary(year),
|
|
vacationDashboardModel.getEmployeeList(year, filters)
|
|
]);
|
|
|
|
// user_id별 그룹핑
|
|
const employeeMap = {};
|
|
rows.forEach(row => {
|
|
if (!employeeMap[row.user_id]) {
|
|
employeeMap[row.user_id] = {
|
|
user_id: row.user_id,
|
|
name: row.name,
|
|
username: row.username,
|
|
department_name: row.department_name,
|
|
hire_date: row.hire_date,
|
|
balances: []
|
|
};
|
|
}
|
|
if (row.id) {
|
|
employeeMap[row.user_id].balances.push({
|
|
balance_type: row.balance_type,
|
|
type_name: row.type_name,
|
|
type_code: row.type_code,
|
|
total_days: row.total_days,
|
|
used_days: row.used_days,
|
|
remaining_days: row.remaining_days,
|
|
expires_at: row.expires_at
|
|
});
|
|
}
|
|
});
|
|
const employees = Object.values(employeeMap);
|
|
|
|
res.json({ success: true, data: { summary, employees } });
|
|
} catch (error) {
|
|
console.error('휴가 대시보드 조회 오류:', error);
|
|
res.status(500).json({ success: false, error: '서버 오류가 발생했습니다' });
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = vacationDashboardController;
|