feat(tkuser): 입사일 자동표시 + 퇴사자 목록 분리 + 퇴사일 관리

- 사용자 추가 시 hire_date 전송 (서울 오늘날짜 기본값)
- resigned_date 컬럼 마이그레이션 + CRUD 지원
- 비활성화(삭제) 시 resigned_date 자동 설정 (COALESCE)
- 활성/비활성 사용자 목록 분리, 퇴사자 접기/펼치기
- 퇴사자 재활성화 기능 (resigned_date 초기화)
- 편집 모달에 퇴사일 필드 추가

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-23 15:47:14 +09:00
parent 1f3eb14128
commit f09aa0875a
8 changed files with 120 additions and 27 deletions

View File

@@ -79,18 +79,18 @@ async function findById(userId) {
async function findAll() {
const db = getPool();
const [rows] = await db.query(
'SELECT user_id, username, name, department, department_id, role, system1_access, system2_access, system3_access, is_active, last_login, created_at, hire_date FROM sso_users WHERE partner_company_id IS NULL ORDER BY user_id'
'SELECT user_id, username, name, department, department_id, role, system1_access, system2_access, system3_access, is_active, last_login, created_at, hire_date, resigned_date FROM sso_users WHERE partner_company_id IS NULL ORDER BY user_id'
);
return rows;
}
async function create({ username, password, name, department, department_id, role }) {
async function create({ username, password, name, department, department_id, role, hire_date }) {
const db = getPool();
const password_hash = await hashPassword(password);
const [result] = await db.query(
`INSERT INTO sso_users (username, password_hash, name, department, department_id, role)
VALUES (?, ?, ?, ?, ?, ?)`,
[username, password_hash, name || null, department || null, department_id || null, role || 'user']
`INSERT INTO sso_users (username, password_hash, name, department, department_id, role, hire_date)
VALUES (?, ?, ?, ?, ?, ?, ?)`,
[username, password_hash, name || null, department || null, department_id || null, role || 'user', hire_date || null]
);
return findById(result.insertId);
}
@@ -109,6 +109,7 @@ async function update(userId, data) {
if (data.system3_access !== undefined) { fields.push('system3_access = ?'); values.push(data.system3_access); }
if (data.is_active !== undefined) { fields.push('is_active = ?'); values.push(data.is_active); }
if (data.hire_date !== undefined) { fields.push('hire_date = ?'); values.push(data.hire_date || null); }
if (data.resigned_date !== undefined) { fields.push('resigned_date = ?'); values.push(data.resigned_date || null); }
if (data.password) {
fields.push('password_hash = ?');
values.push(await hashPassword(data.password));
@@ -126,7 +127,7 @@ async function update(userId, data) {
async function deleteUser(userId) {
const db = getPool();
await db.query('UPDATE sso_users SET is_active = FALSE WHERE user_id = ?', [userId]);
await db.query('UPDATE sso_users SET is_active = FALSE, resigned_date = COALESCE(resigned_date, CURDATE()) WHERE user_id = ?', [userId]);
}
module.exports = {