feat(tksupport): Sprint 001 Section C — 전사 휴가관리 구현
- 전사 휴가 부여/관리 (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>
This commit is contained in:
@@ -6,6 +6,8 @@ const vacationBalanceModel = {
|
||||
const [rows] = await db.query(`
|
||||
SELECT
|
||||
vb.*,
|
||||
vb.balance_type,
|
||||
vb.expires_at,
|
||||
vt.type_name,
|
||||
vt.type_code,
|
||||
vt.priority,
|
||||
@@ -13,7 +15,7 @@ const vacationBalanceModel = {
|
||||
(vb.total_days - vb.used_days) as remaining_days
|
||||
FROM sp_vacation_balances vb
|
||||
INNER JOIN vacation_types vt ON vb.vacation_type_id = vt.id
|
||||
WHERE vb.user_id = ? AND vb.year = ?
|
||||
WHERE vb.user_id = ? AND (vb.year = ? OR (vb.balance_type = 'LONG_SERVICE' AND vb.expires_at IS NULL))
|
||||
ORDER BY vt.priority ASC, vt.type_name ASC
|
||||
`, [userId, year]);
|
||||
return rows;
|
||||
@@ -24,9 +26,12 @@ const vacationBalanceModel = {
|
||||
const [rows] = await db.query(`
|
||||
SELECT
|
||||
vb.*,
|
||||
vb.balance_type,
|
||||
su.name as user_name,
|
||||
su.username,
|
||||
su.hire_date,
|
||||
su.department_id,
|
||||
COALESCE(d.department_name, '미배정') as department_name,
|
||||
vt.type_name,
|
||||
vt.type_code,
|
||||
vt.priority,
|
||||
@@ -34,7 +39,8 @@ const vacationBalanceModel = {
|
||||
FROM sp_vacation_balances vb
|
||||
INNER JOIN sso_users su ON vb.user_id = su.user_id
|
||||
INNER JOIN vacation_types vt ON vb.vacation_type_id = vt.id
|
||||
WHERE vb.year = ? AND su.is_active = 1
|
||||
LEFT JOIN departments d ON su.department_id = d.department_id
|
||||
WHERE (vb.year = ? OR (vb.balance_type = 'LONG_SERVICE' AND vb.expires_at IS NULL)) AND su.is_active = 1
|
||||
ORDER BY su.name ASC, vt.priority ASC
|
||||
`, [year]);
|
||||
return rows;
|
||||
@@ -42,14 +48,16 @@ const vacationBalanceModel = {
|
||||
|
||||
async allocate(data) {
|
||||
const db = getPool();
|
||||
const balanceType = data.balance_type || 'AUTO';
|
||||
const expiresAt = data.expires_at || null;
|
||||
const [result] = await db.query(`
|
||||
INSERT INTO sp_vacation_balances (user_id, vacation_type_id, year, total_days, used_days, notes, created_by)
|
||||
VALUES (?, ?, ?, ?, 0, ?, ?)
|
||||
INSERT INTO sp_vacation_balances (user_id, vacation_type_id, year, total_days, used_days, notes, created_by, balance_type, expires_at)
|
||||
VALUES (?, ?, ?, ?, 0, ?, ?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
total_days = VALUES(total_days),
|
||||
notes = VALUES(notes),
|
||||
updated_at = NOW()
|
||||
`, [data.user_id, data.vacation_type_id, data.year, data.total_days, data.notes || null, data.created_by]);
|
||||
`, [data.user_id, data.vacation_type_id, data.year, data.total_days, data.notes || null, data.created_by, balanceType, expiresAt]);
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user