feat(tkuser): Sprint 001 Section A — 연차/휴가 백엔드 전환 (DB + API)

workers/vacation_balance_details → sso_users/sp_vacation_balances 기반 전환.
부서장 설정, 승인권한 CRUD, vacation_settings 테이블, 장기근속 자동부여,
startup migration 추가.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-23 08:13:03 +09:00
parent b44ae36329
commit c158da7832
11 changed files with 501 additions and 70 deletions

View File

@@ -1,7 +1,7 @@
/**
* Department Controller
*
* 부서 CRUD
* 부서 CRUD + 승인권한 관리
*/
const departmentModel = require('../models/departmentModel');
@@ -63,4 +63,49 @@ async function remove(req, res, next) {
}
}
module.exports = { getAll, getById, create, update, remove };
/* ===== 승인권한 (Approval Authority) ===== */
async function getApprovalAuthorities(req, res, next) {
try {
const departmentId = parseInt(req.params.id);
const data = await departmentModel.getApprovalAuthorities(departmentId);
res.json({ success: true, data });
} catch (err) {
next(err);
}
}
async function createApprovalAuthority(req, res, next) {
try {
const departmentId = parseInt(req.params.id);
const { approval_type, approver_user_id } = req.body;
if (!approval_type || !approver_user_id) {
return res.status(400).json({ success: false, error: '승인유형과 승인자는 필수입니다' });
}
const data = await departmentModel.createApprovalAuthority({
department_id: departmentId,
...req.body
});
res.status(201).json({ success: true, data });
} catch (err) {
if (err.code === 'ER_DUP_ENTRY') {
return res.status(409).json({ success: false, error: '이미 등록된 승인권한입니다' });
}
next(err);
}
}
async function deleteApprovalAuthority(req, res, next) {
try {
const authId = parseInt(req.params.authId);
await departmentModel.deleteApprovalAuthority(authId);
res.json({ success: true, message: '승인권한이 삭제되었습니다' });
} catch (err) {
next(err);
}
}
module.exports = {
getAll, getById, create, update, remove,
getApprovalAuthorities, createApprovalAuthority, deleteApprovalAuthority
};