- tkuser 서비스 신규 추가 (API + Web) - 사용자/권한/프로젝트/부서/작업자/작업장/설비/작업/휴가 통합 관리 - 작업장 탭: 공장→작업장 드릴다운 네비게이션 + 구역지도 클릭 연동 - 작업 탭: 공정(work_types)→작업(tasks) 계층 관리 - 휴가 탭: 유형 관리 + 연차 배정(근로기준법 자동계산) - 전 시스템 SSO 쿠키 인증으로 통합 (.technicalkorea.net 공유) - System 2: 작업 이슈 리포트 기능 강화 - System 3: tkuser API 연동, 페이지 권한 체계 적용 - docker-compose에 tkuser-api, tkuser-web 서비스 추가 - ARCHITECTURE.md, DEPLOYMENT.md 문서 작성 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
/**
|
|
* Department Controller
|
|
*
|
|
* 부서 CRUD
|
|
*/
|
|
|
|
const departmentModel = require('../models/departmentModel');
|
|
|
|
async function getAll(req, res, next) {
|
|
try {
|
|
const departments = await departmentModel.getAll();
|
|
res.json({ success: true, data: departments });
|
|
} catch (err) {
|
|
next(err);
|
|
}
|
|
}
|
|
|
|
async function getById(req, res, next) {
|
|
try {
|
|
const dept = await departmentModel.getById(parseInt(req.params.id));
|
|
if (!dept) {
|
|
return res.status(404).json({ success: false, error: '부서를 찾을 수 없습니다' });
|
|
}
|
|
res.json({ success: true, data: dept });
|
|
} catch (err) {
|
|
next(err);
|
|
}
|
|
}
|
|
|
|
async function create(req, res, next) {
|
|
try {
|
|
const { department_name } = req.body;
|
|
if (!department_name) {
|
|
return res.status(400).json({ success: false, error: '부서명은 필수입니다' });
|
|
}
|
|
const dept = await departmentModel.create(req.body);
|
|
res.status(201).json({ success: true, data: dept });
|
|
} catch (err) {
|
|
next(err);
|
|
}
|
|
}
|
|
|
|
async function update(req, res, next) {
|
|
try {
|
|
const id = parseInt(req.params.id);
|
|
const dept = await departmentModel.update(id, req.body);
|
|
if (!dept) {
|
|
return res.status(404).json({ success: false, error: '부서를 찾을 수 없습니다' });
|
|
}
|
|
res.json({ success: true, data: dept });
|
|
} catch (err) {
|
|
next(err);
|
|
}
|
|
}
|
|
|
|
async function remove(req, res, next) {
|
|
try {
|
|
const id = parseInt(req.params.id);
|
|
await departmentModel.deactivate(id);
|
|
res.json({ success: true, message: '부서가 비활성화되었습니다' });
|
|
} catch (err) {
|
|
next(err);
|
|
}
|
|
}
|
|
|
|
module.exports = { getAll, getById, create, update, remove };
|