feat(tkuser): 부서 마스터 + 개인 추가 부여 권한 시스템 구현

부서 권한을 바닥(마스터)으로 설정하고 개인은 추가 부여만 가능하도록 변경.
부서 허용 항목은 개인 페이지에서 잠금(해제 불가) 표시되며,
부서 이동 시 기존 개인 권한이 자동 초기화됨.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-16 11:49:25 +09:00
parent f711a721ec
commit 4108a6e64a
5 changed files with 130 additions and 39 deletions

View File

@@ -5,6 +5,7 @@
*/
const userModel = require('../models/userModel');
const permissionModel = require('../models/permissionModel');
/**
* GET /api/users - 전체 사용자 목록
@@ -62,6 +63,14 @@ async function updateUser(req, res, next) {
delete data.full_name;
}
// 부서 변경 감지 → 개인 권한 초기화
if (data.department_id !== undefined) {
const existingUser = await userModel.findById(userId);
if (existingUser && existingUser.department_id !== data.department_id) {
await permissionModel.clearUserPermissionsForDepartmentChange(userId);
}
}
const user = await userModel.update(userId, data);
if (!user) {
return res.status(404).json({ success: false, error: '사용자를 찾을 수 없습니다' });