feat(tkfb): 연차 데이터 정본 전환 — vacation_balance_details → sp_vacation_balances
대시보드 + 연간 연차 현황 페이지의 읽기를 tksupport 정본 테이블로 전환. - dashboardModel: getVacationBalance worker_id → user_id, sp_vacation_balances - dashboardController: worker_id 전달 제거, user_id 직접 사용 - vacationBalanceModel: 읽기 함수 3개 sp_vacation_balances로 전환 (쓰기 함수 deductByPriority 등은 vacation_balance_details 유지) - remaining_days: STORED GENERATED 대신 (total_days - used_days) AS 계산 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,14 +13,15 @@ const vacationBalanceModel = {
|
||||
const db = await getDb();
|
||||
const [rows] = await db.query(`
|
||||
SELECT
|
||||
vbd.*,
|
||||
vt.type_name,
|
||||
vt.type_code,
|
||||
vt.priority,
|
||||
vt.is_special
|
||||
FROM vacation_balance_details vbd
|
||||
INNER JOIN vacation_types vt ON vbd.vacation_type_id = vt.id
|
||||
WHERE vbd.user_id = ? AND vbd.year = ?
|
||||
svb.id, svb.user_id, svb.vacation_type_id, svb.year,
|
||||
svb.total_days, svb.used_days,
|
||||
(svb.total_days - svb.used_days) AS remaining_days,
|
||||
svb.balance_type, svb.expires_at, svb.notes,
|
||||
svb.created_by, svb.created_at, svb.updated_at,
|
||||
vt.type_name, vt.type_code, vt.priority, vt.is_special
|
||||
FROM sp_vacation_balances svb
|
||||
INNER JOIN vacation_types vt ON svb.vacation_type_id = vt.id
|
||||
WHERE svb.user_id = ? AND svb.year = ?
|
||||
ORDER BY vt.priority ASC, vt.type_name ASC
|
||||
`, [userId, year]);
|
||||
return rows;
|
||||
@@ -33,14 +34,16 @@ const vacationBalanceModel = {
|
||||
const db = await getDb();
|
||||
const [rows] = await db.query(`
|
||||
SELECT
|
||||
vbd.*,
|
||||
vt.type_name,
|
||||
vt.type_code
|
||||
FROM vacation_balance_details vbd
|
||||
INNER JOIN vacation_types vt ON vbd.vacation_type_id = vt.id
|
||||
WHERE vbd.user_id = ?
|
||||
AND vbd.vacation_type_id = ?
|
||||
AND vbd.year = ?
|
||||
svb.id, svb.user_id, svb.vacation_type_id, svb.year,
|
||||
svb.total_days, svb.used_days,
|
||||
(svb.total_days - svb.used_days) AS remaining_days,
|
||||
svb.balance_type, svb.expires_at,
|
||||
vt.type_name, vt.type_code
|
||||
FROM sp_vacation_balances svb
|
||||
INNER JOIN vacation_types vt ON svb.vacation_type_id = vt.id
|
||||
WHERE svb.user_id = ?
|
||||
AND svb.vacation_type_id = ?
|
||||
AND svb.year = ?
|
||||
`, [userId, vacationTypeId, year]);
|
||||
return rows;
|
||||
},
|
||||
@@ -52,16 +55,17 @@ const vacationBalanceModel = {
|
||||
const db = await getDb();
|
||||
const [rows] = await db.query(`
|
||||
SELECT
|
||||
vbd.*,
|
||||
w.worker_name,
|
||||
w.employment_status,
|
||||
vt.type_name,
|
||||
vt.type_code,
|
||||
vt.priority
|
||||
FROM vacation_balance_details vbd
|
||||
INNER JOIN workers w ON vbd.user_id = w.user_id
|
||||
INNER JOIN vacation_types vt ON vbd.vacation_type_id = vt.id
|
||||
WHERE vbd.year = ?
|
||||
svb.id, svb.user_id, svb.vacation_type_id, svb.year,
|
||||
svb.total_days, svb.used_days,
|
||||
(svb.total_days - svb.used_days) AS remaining_days,
|
||||
svb.balance_type, svb.expires_at, svb.notes,
|
||||
svb.created_by, svb.created_at, svb.updated_at,
|
||||
w.worker_name, w.employment_status,
|
||||
vt.type_name, vt.type_code, vt.priority
|
||||
FROM sp_vacation_balances svb
|
||||
INNER JOIN workers w ON svb.user_id = w.user_id
|
||||
INNER JOIN vacation_types vt ON svb.vacation_type_id = vt.id
|
||||
WHERE svb.year = ?
|
||||
AND w.employment_status = 'employed'
|
||||
ORDER BY w.worker_name ASC, vt.priority ASC
|
||||
`, [year]);
|
||||
|
||||
Reference in New Issue
Block a user