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:
@@ -23,13 +23,12 @@ const DashboardController = {
|
|||||||
return res.status(404).json({ success: false, message: '사용자 정보를 찾을 수 없습니다.' });
|
return res.status(404).json({ success: false, message: '사용자 정보를 찾을 수 없습니다.' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const workerId = userInfo.worker_id;
|
|
||||||
const departmentId = userInfo.department_id;
|
const departmentId = userInfo.department_id;
|
||||||
const role = userInfo.role;
|
const role = userInfo.role;
|
||||||
|
|
||||||
// 2단계: 나머지 3개 병렬 조회
|
// 2단계: 나머지 3개 병렬 조회 (연차: sp_vacation_balances from user_id)
|
||||||
const [vacationRows, overtime, quickAccess] = await Promise.all([
|
const [vacationRows, overtime, quickAccess] = await Promise.all([
|
||||||
DashboardModel.getVacationBalance(workerId, year),
|
DashboardModel.getVacationBalance(userId, year),
|
||||||
DashboardModel.getMonthlyOvertime(userId, year, month),
|
DashboardModel.getMonthlyOvertime(userId, year, month),
|
||||||
DashboardModel.getQuickAccess(userId, departmentId, role)
|
DashboardModel.getQuickAccess(userId, departmentId, role)
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -27,17 +27,19 @@ const DashboardModel = {
|
|||||||
/**
|
/**
|
||||||
* 연차 현황 조회 (쿼리 2)
|
* 연차 현황 조회 (쿼리 2)
|
||||||
*/
|
*/
|
||||||
getVacationBalance: async (workerId, year) => {
|
getVacationBalance: async (userId, year) => {
|
||||||
if (!workerId) return [];
|
if (!userId) return [];
|
||||||
const db = await getDb();
|
const db = await getDb();
|
||||||
const [rows] = await db.execute(`
|
const [rows] = await db.execute(`
|
||||||
SELECT vbd.vacation_type_id, vbd.total_days, vbd.used_days, vbd.remaining_days,
|
SELECT svb.vacation_type_id, 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
|
vt.type_name, vt.type_code
|
||||||
FROM vacation_balance_details vbd
|
FROM sp_vacation_balances svb
|
||||||
JOIN vacation_types vt ON vbd.vacation_type_id = vt.id
|
JOIN vacation_types vt ON svb.vacation_type_id = vt.id
|
||||||
WHERE vbd.worker_id = ? AND vbd.year = ?
|
WHERE svb.user_id = ? AND svb.year = ?
|
||||||
ORDER BY vt.priority
|
ORDER BY vt.priority
|
||||||
`, [workerId, year]);
|
`, [userId, year]);
|
||||||
return rows;
|
return rows;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,15 @@ const vacationBalanceModel = {
|
|||||||
const db = await getDb();
|
const db = await getDb();
|
||||||
const [rows] = await db.query(`
|
const [rows] = await db.query(`
|
||||||
SELECT
|
SELECT
|
||||||
vbd.*,
|
svb.id, svb.user_id, svb.vacation_type_id, svb.year,
|
||||||
vt.type_name,
|
svb.total_days, svb.used_days,
|
||||||
vt.type_code,
|
(svb.total_days - svb.used_days) AS remaining_days,
|
||||||
vt.priority,
|
svb.balance_type, svb.expires_at, svb.notes,
|
||||||
vt.is_special
|
svb.created_by, svb.created_at, svb.updated_at,
|
||||||
FROM vacation_balance_details vbd
|
vt.type_name, vt.type_code, vt.priority, vt.is_special
|
||||||
INNER JOIN vacation_types vt ON vbd.vacation_type_id = vt.id
|
FROM sp_vacation_balances svb
|
||||||
WHERE vbd.user_id = ? AND vbd.year = ?
|
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
|
ORDER BY vt.priority ASC, vt.type_name ASC
|
||||||
`, [userId, year]);
|
`, [userId, year]);
|
||||||
return rows;
|
return rows;
|
||||||
@@ -33,14 +34,16 @@ const vacationBalanceModel = {
|
|||||||
const db = await getDb();
|
const db = await getDb();
|
||||||
const [rows] = await db.query(`
|
const [rows] = await db.query(`
|
||||||
SELECT
|
SELECT
|
||||||
vbd.*,
|
svb.id, svb.user_id, svb.vacation_type_id, svb.year,
|
||||||
vt.type_name,
|
svb.total_days, svb.used_days,
|
||||||
vt.type_code
|
(svb.total_days - svb.used_days) AS remaining_days,
|
||||||
FROM vacation_balance_details vbd
|
svb.balance_type, svb.expires_at,
|
||||||
INNER JOIN vacation_types vt ON vbd.vacation_type_id = vt.id
|
vt.type_name, vt.type_code
|
||||||
WHERE vbd.user_id = ?
|
FROM sp_vacation_balances svb
|
||||||
AND vbd.vacation_type_id = ?
|
INNER JOIN vacation_types vt ON svb.vacation_type_id = vt.id
|
||||||
AND vbd.year = ?
|
WHERE svb.user_id = ?
|
||||||
|
AND svb.vacation_type_id = ?
|
||||||
|
AND svb.year = ?
|
||||||
`, [userId, vacationTypeId, year]);
|
`, [userId, vacationTypeId, year]);
|
||||||
return rows;
|
return rows;
|
||||||
},
|
},
|
||||||
@@ -52,16 +55,17 @@ const vacationBalanceModel = {
|
|||||||
const db = await getDb();
|
const db = await getDb();
|
||||||
const [rows] = await db.query(`
|
const [rows] = await db.query(`
|
||||||
SELECT
|
SELECT
|
||||||
vbd.*,
|
svb.id, svb.user_id, svb.vacation_type_id, svb.year,
|
||||||
w.worker_name,
|
svb.total_days, svb.used_days,
|
||||||
w.employment_status,
|
(svb.total_days - svb.used_days) AS remaining_days,
|
||||||
vt.type_name,
|
svb.balance_type, svb.expires_at, svb.notes,
|
||||||
vt.type_code,
|
svb.created_by, svb.created_at, svb.updated_at,
|
||||||
vt.priority
|
w.worker_name, w.employment_status,
|
||||||
FROM vacation_balance_details vbd
|
vt.type_name, vt.type_code, vt.priority
|
||||||
INNER JOIN workers w ON vbd.user_id = w.user_id
|
FROM sp_vacation_balances svb
|
||||||
INNER JOIN vacation_types vt ON vbd.vacation_type_id = vt.id
|
INNER JOIN workers w ON svb.user_id = w.user_id
|
||||||
WHERE vbd.year = ?
|
INNER JOIN vacation_types vt ON svb.vacation_type_id = vt.id
|
||||||
|
WHERE svb.year = ?
|
||||||
AND w.employment_status = 'employed'
|
AND w.employment_status = 'employed'
|
||||||
ORDER BY w.worker_name ASC, vt.priority ASC
|
ORDER BY w.worker_name ASC, vt.priority ASC
|
||||||
`, [year]);
|
`, [year]);
|
||||||
|
|||||||
Reference in New Issue
Block a user