feat: 페이지 구조 재구성 및 사이드바 네비게이션 구현

- 페이지 폴더 재구성: safety/, attendance/ 폴더 신규 생성
  - work/ → safety/: 이슈 신고, 출입 신청 관련 페이지 이동
  - common/ → attendance/: 근태/휴가 관련 페이지 이동
  - admin/ 정리: safety-* 파일들을 safety/로 이동

- 사이드바 네비게이션 메뉴 구현
  - 카테고리별 메뉴: 작업관리, 안전관리, 근태관리, 시스템관리
  - 접기/펼치기 기능 및 상태 저장
  - 관리자 전용 메뉴 자동 표시/숨김

- 날씨 API 연동 (기상청 단기예보)
  - TBM 및 navbar에 현재 날씨 표시
  - weatherService.js 추가

- 안전 체크리스트 확장
  - 기본/날씨별/작업별 체크 유형 추가
  - checklist-manage.html 페이지 추가

- 이슈 신고 시스템 구현
  - workIssueController, workIssueModel, workIssueRoutes 추가

- DB 마이그레이션 파일 추가 (실행 대기)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-02-02 14:27:22 +09:00
parent b6485e3140
commit 74d3a78aa3
116 changed files with 23117 additions and 294 deletions

View File

@@ -218,7 +218,7 @@ const updateUser = asyncHandler(async (req, res) => {
checkAdminPermission(req.user);
const { id } = req.params;
const { username, name, email, phone, role, role_id, password } = req.body;
const { username, name, email, role, role_id, password } = req.body;
if (!id || isNaN(id)) {
throw new ValidationError('유효하지 않은 사용자 ID입니다');
@@ -227,7 +227,7 @@ const updateUser = asyncHandler(async (req, res) => {
logger.info('사용자 수정 요청', { userId: id, body: req.body });
// 최소 하나의 수정 필드가 필요
if (!username && !name && email === undefined && phone === undefined && !role && !role_id && !password) {
if (!username && !name && email === undefined && !role && !role_id && !password) {
throw new ValidationError('수정할 필드가 없습니다');
}
@@ -278,11 +278,6 @@ const updateUser = asyncHandler(async (req, res) => {
values.push(email || null);
}
if (phone !== undefined) {
updates.push('phone = ?');
values.push(phone || null);
}
// role_id 또는 role 문자열 처리
if (role_id) {
// role_id가 유효한지 확인
@@ -497,6 +492,7 @@ const getUserPageAccess = asyncHandler(async (req, res) => {
const db = await getDb();
try {
// 권한 조회: user_page_access에 명시적 권한이 있으면 사용, 없으면 is_default_accessible 사용
const query = `
SELECT
p.id as page_id,
@@ -504,10 +500,10 @@ const getUserPageAccess = asyncHandler(async (req, res) => {
p.page_name,
p.page_path,
p.category,
COALESCE(upa.can_access, 0) as can_access
p.is_default_accessible,
COALESCE(upa.can_access, p.is_default_accessible) as can_access
FROM pages p
LEFT JOIN user_page_access upa ON p.id = upa.page_id AND upa.user_id = ?
WHERE p.is_active = 1
ORDER BY p.category, p.display_order
`;
@@ -595,6 +591,55 @@ const updateUserPageAccess = asyncHandler(async (req, res) => {
}
});
/**
* 사용자 비밀번호 초기화 (000000)
*/
const resetUserPassword = asyncHandler(async (req, res) => {
checkAdminPermission(req.user);
const { id } = req.params;
if (!id || isNaN(id)) {
throw new ValidationError('유효하지 않은 사용자 ID입니다');
}
const { getDb } = require('../dbPool');
const db = await getDb();
try {
// 사용자 존재 확인
const [existing] = await db.execute('SELECT user_id, username FROM users WHERE user_id = ?', [id]);
if (existing.length === 0) {
throw new NotFoundError('사용자를 찾을 수 없습니다');
}
// 비밀번호를 000000으로 초기화
const hashedPassword = await bcrypt.hash('000000', 10);
await db.execute(
'UPDATE users SET password = ?, password_changed_at = NULL, updated_at = NOW() WHERE user_id = ?',
[hashedPassword, id]
);
logger.info('사용자 비밀번호 초기화 성공', {
userId: id,
username: existing[0].username,
resetBy: req.user.username
});
res.json({
success: true,
message: '비밀번호가 000000으로 초기화되었습니다'
});
} catch (error) {
if (error instanceof NotFoundError || error instanceof ValidationError) {
throw error;
}
logger.error('비밀번호 초기화 실패', { userId: id, error: error.message });
throw new DatabaseError('비밀번호 초기화에 실패했습니다');
}
});
module.exports = {
getAllUsers,
getUserById,
@@ -603,5 +648,6 @@ module.exports = {
updateUserStatus,
deleteUser,
getUserPageAccess,
updateUserPageAccess
updateUserPageAccess,
resetUserPassword
};