refactor: worker_id → user_id 전체 마이그레이션 (Phase 1-4)

sso_users.user_id를 단일 식별자로 통합. JWT에서 worker_id 제거,
department_id/is_production 추가. 백엔드 15개 모델, 11개 컨트롤러,
4개 서비스, 7개 라우트, 프론트엔드 32+ JS/11+ HTML 변환.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-05 13:13:10 +09:00
parent 2197cdb3d5
commit abd7564e6b
90 changed files with 1790 additions and 925 deletions

View File

@@ -49,7 +49,7 @@ class MonthlyStatusModel {
// daily_work_reports에서 직접 집계하여 조회 (중복 없음 보장)
const [rows] = await db.query(`
SELECT
w.worker_id,
w.user_id,
w.worker_name,
w.job_type,
YEAR(?) as year,
@@ -77,9 +77,9 @@ class MonthlyStatusModel {
END as has_issues,
MAX(dwr.created_at) as last_updated
FROM workers w
LEFT JOIN daily_work_reports dwr ON w.worker_id = dwr.worker_id AND dwr.report_date = ?
LEFT JOIN daily_work_reports dwr ON w.user_id = dwr.user_id AND dwr.report_date = ?
WHERE w.status = 'active'
GROUP BY w.worker_id, w.worker_name, w.job_type
GROUP BY w.user_id, w.worker_name, w.job_type
ORDER BY w.worker_name ASC
`, [date, date, date, date]);
@@ -97,15 +97,15 @@ class MonthlyStatusModel {
try {
// 해당 월의 모든 날짜와 작업자 조합을 찾아서 재계산
const [workDates] = await db.execute(`
SELECT DISTINCT report_date, worker_id
FROM daily_work_reports
SELECT DISTINCT report_date, user_id
FROM daily_work_reports
WHERE YEAR(report_date) = ? AND MONTH(report_date) = ?
`, [year, month]);
let updatedCount = 0;
for (const { report_date, worker_id } of workDates) {
await db.execute('CALL UpdateMonthlyWorkerStatus(?, ?)', [report_date, worker_id]);
for (const { report_date, user_id } of workDates) {
await db.execute('CALL UpdateMonthlyWorkerStatus(?, ?)', [report_date, user_id]);
updatedCount++;
}
@@ -119,23 +119,23 @@ class MonthlyStatusModel {
}
// 특정 날짜 집계 강제 업데이트
static async updateDateSummary(date, workerId = null) {
static async updateDateSummary(date, userId = null) {
const db = await getDb();
try {
if (workerId) {
if (userId) {
// 특정 작업자만 업데이트
await db.execute('CALL UpdateMonthlyWorkerStatus(?, ?)', [date, workerId]);
await db.execute('CALL UpdateMonthlyWorkerStatus(?, ?)', [date, userId]);
} else {
// 해당 날짜의 모든 작업자 업데이트
const [workers] = await db.execute(`
SELECT DISTINCT worker_id
FROM daily_work_reports
SELECT DISTINCT user_id
FROM daily_work_reports
WHERE report_date = ?
`, [date]);
for (const { worker_id } of workers) {
await db.execute('CALL UpdateMonthlyWorkerStatus(?, ?)', [date, worker_id]);
for (const { user_id } of workers) {
await db.execute('CALL UpdateMonthlyWorkerStatus(?, ?)', [date, user_id]);
}
}
@@ -163,7 +163,7 @@ class MonthlyStatusModel {
const [workerStatusCount] = await db.execute(`
SELECT
COUNT(*) as total_records,
COUNT(DISTINCT worker_id) as unique_workers,
COUNT(DISTINCT user_id) as unique_workers,
COUNT(DISTINCT date) as unique_dates,
MAX(last_updated) as last_update
FROM monthly_worker_status