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

@@ -10,12 +10,12 @@ const logger = require('../utils/logger');
const vacationBalanceController = {
/**
* 특정 작업자의 휴가 잔액 조회 (특정 연도)
* GET /api/vacation-balances/worker/:workerId/year/:year
* GET /api/vacation-balances/user/:userId/year/:year
*/
async getByWorkerAndYear(req, res) {
try {
const { workerId, year } = req.params;
const results = await vacationBalanceModel.getByWorkerAndYear(workerId, year);
const { userId, year } = req.params;
const results = await vacationBalanceModel.getByWorkerAndYear(userId, year);
res.json({ success: true, data: results });
} catch (error) {
logger.error('휴가 잔액 조회 오류:', error);
@@ -44,18 +44,18 @@ const vacationBalanceController = {
*/
async createBalance(req, res) {
try {
const { worker_id, vacation_type_id, year, total_days, used_days, notes } = req.body;
const { user_id, vacation_type_id, year, total_days, used_days, notes } = req.body;
const created_by = req.user.user_id;
if (!worker_id || !vacation_type_id || !year || total_days === undefined) {
if (!user_id || !vacation_type_id || !year || total_days === undefined) {
return res.status(400).json({
success: false,
message: '필수 필드가 누락되었습니다 (worker_id, vacation_type_id, year, total_days)'
message: '필수 필드가 누락되었습니다 (user_id, vacation_type_id, year, total_days)'
});
}
// 중복 체크
const existing = await vacationBalanceModel.getByWorkerTypeYear(worker_id, vacation_type_id, year);
const existing = await vacationBalanceModel.getByWorkerTypeYear(user_id, vacation_type_id, year);
if (existing && existing.length > 0) {
return res.status(400).json({
success: false,
@@ -64,7 +64,7 @@ const vacationBalanceController = {
}
const balanceData = {
worker_id,
user_id,
vacation_type_id,
year,
total_days,
@@ -142,13 +142,13 @@ const vacationBalanceController = {
*/
async autoCalculateAndCreate(req, res) {
try {
const { worker_id, hire_date, year } = req.body;
const { user_id, hire_date, year } = req.body;
const created_by = req.user.user_id;
if (!worker_id || !hire_date || !year) {
if (!user_id || !hire_date || !year) {
return res.status(400).json({
success: false,
message: '필수 필드가 누락되었습니다 (worker_id, hire_date, year)'
message: '필수 필드가 누락되었습니다 (user_id, hire_date, year)'
});
}
@@ -163,7 +163,7 @@ const vacationBalanceController = {
const annualTypeId = types[0].id;
// 중복 체크
const existing = await vacationBalanceModel.getByWorkerTypeYear(worker_id, annualTypeId, year);
const existing = await vacationBalanceModel.getByWorkerTypeYear(user_id, annualTypeId, year);
if (existing && existing.length > 0) {
return res.status(400).json({
success: false,
@@ -172,7 +172,7 @@ const vacationBalanceController = {
}
const balanceData = {
worker_id,
user_id,
vacation_type_id: annualTypeId,
year,
total_days: annualDays,
@@ -213,9 +213,9 @@ const vacationBalanceController = {
let errorCount = 0;
for (const balance of balances) {
const { worker_id, vacation_type_id, year, total_days, notes } = balance;
const { user_id, vacation_type_id, year, total_days, notes } = balance;
if (!worker_id || !vacation_type_id || !year || total_days === undefined) {
if (!user_id || !vacation_type_id || !year || total_days === undefined) {
errorCount++;
continue;
}
@@ -223,7 +223,7 @@ const vacationBalanceController = {
try {
const query = `
INSERT INTO vacation_balance_details
(worker_id, vacation_type_id, year, total_days, used_days, notes, created_by)
(user_id, vacation_type_id, year, total_days, used_days, notes, created_by)
VALUES (?, ?, ?, ?, 0, ?, ?)
ON DUPLICATE KEY UPDATE
total_days = VALUES(total_days),
@@ -231,7 +231,7 @@ const vacationBalanceController = {
updated_at = NOW()
`;
await db.query(query, [worker_id, vacation_type_id, year, total_days, notes || null, created_by]);
await db.query(query, [user_id, vacation_type_id, year, total_days, notes || null, created_by]);
successCount++;
} catch (err) {
logger.error('휴가 잔액 저장 오류:', err);
@@ -252,12 +252,12 @@ const vacationBalanceController = {
/**
* 작업자의 사용 가능한 휴가 일수 조회
* GET /api/vacation-balances/worker/:workerId/year/:year/available
* GET /api/vacation-balances/user/:userId/year/:year/available
*/
async getAvailableDays(req, res) {
try {
const { workerId, year } = req.params;
const results = await vacationBalanceModel.getAvailableVacationDays(workerId, year);
const { userId, year } = req.params;
const results = await vacationBalanceModel.getAvailableVacationDays(userId, year);
res.json({ success: true, data: results });
} catch (error) {
logger.error('사용 가능 휴가 조회 오류:', error);