feat: tkuser 통합 관리 서비스 + 전체 시스템 SSO 쿠키 인증 통합
- 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>
This commit is contained in:
79
user-management/api/models/projectModel.js
Normal file
79
user-management/api/models/projectModel.js
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Project Model
|
||||
*
|
||||
* projects 테이블 CRUD (MariaDB)
|
||||
* System 1과 같은 DB를 공유
|
||||
*/
|
||||
|
||||
const { getPool } = require('./userModel');
|
||||
|
||||
async function getAll() {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
'SELECT * FROM projects ORDER BY project_id DESC'
|
||||
);
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function getActive() {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
'SELECT * FROM projects WHERE is_active = TRUE ORDER BY project_name ASC'
|
||||
);
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function getById(id) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
'SELECT * FROM projects WHERE project_id = ?',
|
||||
[id]
|
||||
);
|
||||
return rows[0] || null;
|
||||
}
|
||||
|
||||
async function create({ job_no, project_name, contract_date, due_date, delivery_method, site, pm }) {
|
||||
const db = getPool();
|
||||
const [result] = await db.query(
|
||||
`INSERT INTO projects (job_no, project_name, contract_date, due_date, delivery_method, site, pm)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
||||
[job_no, project_name, contract_date || null, due_date || null, delivery_method || null, site || null, pm || null]
|
||||
);
|
||||
return getById(result.insertId);
|
||||
}
|
||||
|
||||
async function update(id, data) {
|
||||
const db = getPool();
|
||||
const fields = [];
|
||||
const values = [];
|
||||
|
||||
if (data.job_no !== undefined) { fields.push('job_no = ?'); values.push(data.job_no); }
|
||||
if (data.project_name !== undefined) { fields.push('project_name = ?'); values.push(data.project_name); }
|
||||
if (data.contract_date !== undefined) { fields.push('contract_date = ?'); values.push(data.contract_date || null); }
|
||||
if (data.due_date !== undefined) { fields.push('due_date = ?'); values.push(data.due_date || null); }
|
||||
if (data.delivery_method !== undefined) { fields.push('delivery_method = ?'); values.push(data.delivery_method); }
|
||||
if (data.site !== undefined) { fields.push('site = ?'); values.push(data.site); }
|
||||
if (data.pm !== undefined) { fields.push('pm = ?'); values.push(data.pm); }
|
||||
if (data.is_active !== undefined) { fields.push('is_active = ?'); values.push(data.is_active); }
|
||||
if (data.project_status !== undefined) { fields.push('project_status = ?'); values.push(data.project_status); }
|
||||
if (data.completed_date !== undefined) { fields.push('completed_date = ?'); values.push(data.completed_date || null); }
|
||||
|
||||
if (fields.length === 0) return getById(id);
|
||||
|
||||
values.push(id);
|
||||
await db.query(
|
||||
`UPDATE projects SET ${fields.join(', ')} WHERE project_id = ?`,
|
||||
values
|
||||
);
|
||||
return getById(id);
|
||||
}
|
||||
|
||||
async function deactivate(id) {
|
||||
const db = getPool();
|
||||
await db.query(
|
||||
'UPDATE projects SET is_active = FALSE, project_status = ? WHERE project_id = ?',
|
||||
['completed', id]
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = { getAll, getActive, getById, create, update, deactivate };
|
||||
Reference in New Issue
Block a user