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

@@ -12,14 +12,14 @@ const createBatch = async (reports) => {
const sql = `
INSERT INTO WorkReports
(\`date\`, worker_id, project_id, task_id, overtime_hours, work_details, memo)
(\`date\`, user_id, project_id, task_id, overtime_hours, work_details, memo)
VALUES (?, ?, ?, ?, ?, ?, ?)
`;
for (const rpt of reports) {
const params = [
rpt.date,
rpt.worker_id,
rpt.user_id,
rpt.project_id,
rpt.task_id || null,
rpt.overtime_hours || null,
@@ -44,18 +44,18 @@ const createBatch = async (reports) => {
const create = async (report) => {
const db = await getDb();
const {
date, worker_id, project_id,
date, user_id, project_id,
task_id, overtime_hours,
work_details, memo
} = report;
const [result] = await db.query(
`INSERT INTO WorkReports
(\`date\`, worker_id, project_id, task_id, overtime_hours, work_details, memo)
(\`date\`, user_id, project_id, task_id, overtime_hours, work_details, memo)
VALUES (?, ?, ?, ?, ?, ?, ?)`,
[
date,
worker_id,
user_id,
project_id,
task_id || null,
overtime_hours || null,
@@ -74,7 +74,7 @@ const getAllByDate = async (date) => {
const db = await getDb();
const sql = `
SELECT
wr.worker_id,
wr.user_id,
wr.id,
wr.\`date\`,
w.worker_name,
@@ -84,7 +84,7 @@ const getAllByDate = async (date) => {
wr.work_details,
wr.memo
FROM WorkReports wr
LEFT JOIN workers w ON wr.worker_id = w.worker_id
LEFT JOIN workers w ON wr.user_id = w.user_id
LEFT JOIN projects p ON wr.project_id = p.project_id
LEFT JOIN Tasks t ON wr.task_id = t.task_id
WHERE wr.\`date\` = ?
@@ -100,7 +100,7 @@ const getAllByDate = async (date) => {
const getByRange = async (start, end) => {
const db = await getDb();
const [rows] = await db.query(
`SELECT id, \`date\`, worker_id, project_id, morning_task_id, afternoon_task_id, overtime_hours, overtime_task_id, work_details, note, memo, created_at, updated_at, morning_project_id, afternoon_project_id, overtime_project_id, task_id FROM WorkReports
`SELECT id, \`date\`, user_id, project_id, morning_task_id, afternoon_task_id, overtime_hours, overtime_task_id, work_details, note, memo, created_at, updated_at, morning_project_id, afternoon_project_id, overtime_project_id, task_id FROM WorkReports
WHERE \`date\` BETWEEN ? AND ?
ORDER BY \`date\` ASC`,
[start, end]
@@ -114,7 +114,7 @@ const getByRange = async (start, end) => {
const getById = async (id) => {
const db = await getDb();
const [rows] = await db.query(
`SELECT id, \`date\`, worker_id, project_id, morning_task_id, afternoon_task_id, overtime_hours, overtime_task_id, work_details, note, memo, created_at, updated_at, morning_project_id, afternoon_project_id, overtime_project_id, task_id FROM WorkReports WHERE id = ?`,
`SELECT id, \`date\`, user_id, project_id, morning_task_id, afternoon_task_id, overtime_hours, overtime_task_id, work_details, note, memo, created_at, updated_at, morning_project_id, afternoon_project_id, overtime_project_id, task_id FROM WorkReports WHERE id = ?`,
[id]
);
return rows[0];
@@ -126,7 +126,7 @@ const getById = async (id) => {
const update = async (id, report) => {
const db = await getDb();
const {
date, worker_id, project_id,
date, user_id, project_id,
task_id, overtime_hours,
work_details, memo
} = report;
@@ -134,7 +134,7 @@ const update = async (id, report) => {
const [result] = await db.query(
`UPDATE WorkReports
SET \`date\` = ?,
worker_id = ?,
user_id = ?,
project_id = ?,
task_id = ?,
overtime_hours = ?,
@@ -144,7 +144,7 @@ const update = async (id, report) => {
WHERE id = ?`,
[
date,
worker_id,
user_id,
project_id,
task_id || null,
overtime_hours || null,
@@ -172,11 +172,11 @@ const remove = async (id) => {
/**
* 8. 중복 확인
*/
const existsByDateAndWorker = async (date, worker_id) => {
const existsByDateAndWorker = async (date, user_id) => {
const db = await getDb();
const [rows] = await db.query(
`SELECT 1 FROM WorkReports WHERE \`date\` = ? AND worker_id = ? LIMIT 1`,
[date, worker_id]
`SELECT 1 FROM WorkReports WHERE \`date\` = ? AND user_id = ? LIMIT 1`,
[date, user_id]
);
return rows.length > 0;
};