Commit Graph

9 Commits

Author SHA1 Message Date
Hyungi Ahn
f27728b168 feat: 작업장 관리 기능 추가 (공장-작업장 계층 구조)
- 공장(카테고리) 및 작업장 CRUD API 구현
- 탭 기반 UI로 공장별 작업장 필터링
- 터치 최적화된 관리자 페이지
- DB 테이블: workplace_categories, workplaces
- 관리자 메뉴에 작업장 관리 추가

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-26 14:31:58 +09:00
Hyungi Ahn
35aa4a840e fix: 로그인 실패 시 500 에러 → 401 에러로 수정
## 문제
- 로그인 실패 시 401 에러를 반환해야 하는데 500 에러 반환
- 원인: ApiError(utils/errorHandler.js)와 AppError(utils/errors.js) 클래스 불일치
- errorHandler 미들웨어가 ApiError를 인식하지 못해 500으로 변환

## 수정사항
1. authController.js:
   - ApiError 대신 AuthenticationError, ValidationError 사용
   - 로그인 실패 → AuthenticationError 던짐 (401)
   - 유효성 검증 실패 → ValidationError 던짐 (400)

2. db/connection.js 추가:
   - TBM 모델의 콜백 방식 DB 쿼리 지원
   - dbPool을 래핑하여 레거시 코드 호환

3. routes.js:
   - TBM 라우트 임시 비활성화 (db/connection 볼륨 마운트 문제)
   - Docker 볼륨 재설정 후 재활성화 예정

## 테스트 결과
```bash
# Before: 500 Internal Server Error
# After: 401 Unauthorized

curl -X POST http://localhost:20005/api/auth/login \
  -d '{"username":"wrong","password":"wrong"}'

# Response:
{
  "success": false,
  "error": {
    "message": "아이디 또는 비밀번호가 올바르지 않습니다.",
    "code": "AUTHENTICATION_ERROR"  // ← 정상!
  }
}
```

## TODO
- [ ] Docker 볼륨 설정에 db 디렉토리 전체 추가
- [ ] TBM 라우트 재활성화
- [ ] 중복 에러 처리 시스템 통합 (ApiError 제거)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-26 12:42:00 +09:00
Hyungi Ahn
4d0c4c0801 feat: TBM 시스템 구축 및 페이지 권한 관리 기능 추가
## 주요 변경사항

### 1. TBM (Tool Box Meeting) 시스템 구축
- **데이터베이스 스키마** (5개 테이블 생성)
  - tbm_sessions: TBM 세션 관리
  - tbm_team_assignments: 팀 구성 관리
  - tbm_safety_checks: 안전 체크리스트 마스터 (17개 항목)
  - tbm_safety_records: 안전 체크 기록
  - team_handovers: 작업 인계 관리

- **API 엔드포인트** (17개)
  - TBM 세션 CRUD
  - 팀 구성 관리
  - 안전 체크리스트
  - 작업 인계
  - 통계 및 리포트

- **프론트엔드**
  - TBM 관리 페이지 (/pages/work/tbm.html)
  - 모달 기반 UI (세션 생성, 팀 구성, 안전 체크)

### 2. 페이지 권한 관리 시스템
- 페이지별 접근 권한 설정 기능
- 관리자 페이지 (/pages/admin/page-access.html)
- 사용자별 페이지 권한 부여/회수
- TBM 페이지 등록 및 권한 연동

### 3. 네비게이션 role 표시 버그 수정
- load-navbar.js: case-insensitive role 매칭 적용
- JWT의 "Admin" role이 "관리자"로 정상 표시
- admin-only 메뉴 항목 정상 표시

### 4. 대시보드 개선
- 작업 현황 테이블 가독성 향상
- 고대비 색상 및 명확한 구분선 적용
- 이모지 제거 및 SVG 아이콘 적용

### 5. 문서화
- TBM 배포 가이드 작성 (docs/TBM_DEPLOYMENT_GUIDE.md)
- 데이터베이스 스키마 상세 기록
- 배포 절차 및 체크리스트 제공

## 기술 스택
- Backend: Node.js, Express, MySQL
- Frontend: Vanilla JavaScript, HTML5, CSS3
- Database: MySQL (InnoDB)

## 파일 변경사항

### 신규 파일
- api.hyungi.net/db/migrations/20260120000000_create_tbm_system.js
- api.hyungi.net/db/migrations/20260120000001_add_tbm_page.js
- api.hyungi.net/models/tbmModel.js
- api.hyungi.net/models/pageAccessModel.js
- api.hyungi.net/controllers/tbmController.js
- api.hyungi.net/controllers/pageAccessController.js
- api.hyungi.net/routes/tbmRoutes.js
- web-ui/pages/work/tbm.html
- web-ui/pages/admin/page-access.html
- web-ui/js/page-access-management.js
- docs/TBM_DEPLOYMENT_GUIDE.md

### 수정 파일
- api.hyungi.net/config/routes.js (TBM 라우트 추가)
- web-ui/js/load-navbar.js (role 매칭 버그 수정)
- web-ui/pages/admin/workers.html (HTML 구조 수정)
- web-ui/pages/dashboard.html (이모지 제거)
- web-ui/css/design-system.css (색상 팔레트 추가)
- web-ui/css/modern-dashboard.css (가독성 개선)
- web-ui/js/modern-dashboard.js (SVG 아이콘 적용)

## 배포 시 주의사항
⚠️ 본 서버 배포 시 반드시 마이그레이션 실행 필요:
```bash
npm run db:migrate
```

상세한 배포 절차는 docs/TBM_DEPLOYMENT_GUIDE.md 참조

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-20 15:38:17 +09:00
Hyungi Ahn
4ac0605887 refactor: 네비게이션 헤더 최신 디자인으로 전면 개편 및 로그인 버그 수정
- fix: 로그인 API에서 user.role_name 필드 올바르게 사용 (auth.service.js)
- refactor: navbar 컴포넌트를 최신 dashboard-header 스타일로 전환
- refactor: 구버전 work-report-header 제거 (6개 페이지)
- refactor: load-navbar.js를 최신 헤더 구조에 맞게 업데이트
- style: 파란색 그라데이션 헤더, 실시간 시계, 향상된 프로필 메뉴
- docs: 2026-01-20 개발 로그 추가

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-20 08:40:19 +09:00
Hyungi Ahn
bea62dfdee refactor: 작업자 관리 개선 - 계정 연동 기능으로 변경
작업 보고서 표시 여부 대신 계정 연동 기능으로 개선했습니다.

## 주요 변경사항

### 개념 변경
- **이전**: 작업 보고서 표시 여부 (show_in_work_reports)
- **이후**: 계정 생성/연동 기능

### 데이터베이스
- **마이그레이션**: 20260119095549_add_worker_display_fields.js
  - show_in_work_reports 컬럼 제거
  - employment_status만 유지 (employed/resigned)

- **workerModel**:
  - getAll, getById에서 users 테이블 JOIN하여 user_id 조회
  - create, update에서 show_in_work_reports 필드 제거

### 백엔드 API
- **workerController.js**:
  - createWorker: create_account 체크 시 자동으로 users 테이블에 계정 생성
    - username: hangulToRoman으로 한글 이름 변환
    - password: 초기 비밀번호 '1234' (bcrypt 해시)
    - role: User 역할 자동 할당
  - updateWorker:
    - create_account=true & 계정 없음 → 계정 생성
    - create_account=false & 계정 있음 → 계정 연동 해제 (users.worker_id=NULL)

### 프론트엔드
- **worker-management.html**:
  - "작업 보고서 표시" → "🔐 계정 생성/연동"으로 변경
  - 체크 시 로그인 계정 자동 생성 안내

- **worker-management.js**:
  - 카드 렌더링: user_id 존재 여부로 계정 연동 상태 표시 (🔐 아이콘)
  - saveWorker: create_account 필드 전송
  - show_in_work_reports 관련 로직 모두 제거

- **daily-work-report.js**:
  - 필터링 조건 단순화: 퇴사자만 제외 (employment_status≠resigned)
  - 계정 여부와 무관하게 모든 재직자 표시

## 사용 방법
1. 작업자 등록/수정 시 "계정 생성/연동" 체크
2. 자동으로 로그인 계정 생성 (초기 비밀번호: 1234)
3. 계정이 있는 작업자는 나의 대시보드, 연차/출퇴근 관리 가능

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-19 10:17:31 +09:00
Hyungi Ahn
25cca1482e feat: 작업자 관리 개선 - 작업보고서 표시/현장직 구분/퇴사 처리
작업자 관리 페이지에 3가지 상태 관리 기능을 추가했습니다:
1. 작업 보고서 표시 여부 (관리자 등은 작업보고서에 표시 안함)
2. 현장직/사무직 구분 (사무직은 출퇴근 관리 불필요)
3. 퇴사 처리 (퇴사자 별도 표시)

## 주요 변경사항

### 데이터베이스
- **마이그레이션**: 20260119095549_add_worker_display_fields.js
  - workers 테이블에 show_in_work_reports (BOOLEAN) 추가
  - workers 테이블에 employment_status (ENUM: employed, resigned) 추가

### 백엔드
- **workerModel.js**: create, update 함수에 새로운 필드 처리 로직 추가

### 프론트엔드
- **worker-management.html**: 작업자 모달에 3가지 체크박스 추가
  - 작업 보고서에 표시
  - 현장직 (활성화) - 사무직과 구분
  - 퇴사 처리
- **worker-management.js**:
  - 퇴사자 카드 렌더링 시 별도 스타일 적용
  - 새 필드 값 로드 및 저장 처리
- **daily-work-report.js**:
  - 작업 보고서 작성 시 show_in_work_reports=true이고 퇴사하지 않은 작업자만 표시

## 배포 절차
```bash
cd api.hyungi.net
npm run db:migrate
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-19 10:02:32 +09:00
Hyungi Ahn
70630b380a feat: 작업자-계정 통합 및 연차/출근 관리 시스템 구축
모든 작업자가 개인 계정으로 로그인하여 본인의 연차와 출근 기록을 확인할 수 있는 시스템을 구축했습니다.

주요 기능:
- 작업자-계정 1:1 통합 (기존 작업자 자동 계정 생성)
- 연차 관리 시스템 (연도별 잔액 관리)
- 출근 기록 시스템 (일일 근태 기록)
- 나의 대시보드 페이지 (개인 정보 조회)

데이터베이스:
- workers 테이블에 salary, base_annual_leave 컬럼 추가
- work_attendance_types, vacation_types 테이블 생성
- daily_attendance_records 테이블 생성
- worker_vacation_balance 테이블 생성
- 기존 작업자 자동 계정 생성 (username: 이름 기반)
- Guest 역할 추가

백엔드 API:
- 한글→영문 변환 유틸리티 (hangulToRoman.js)
- UserRoutes에 개인 정보 조회 API 추가
  - GET /api/users/me (내 정보)
  - GET /api/users/me/attendance-records (출근 기록)
  - GET /api/users/me/vacation-balance (연차 잔액)
  - GET /api/users/me/work-reports (작업 보고서)
  - GET /api/users/me/monthly-stats (월별 통계)

프론트엔드:
- 나의 대시보드 페이지 (my-dashboard.html)
- 연차 정보 위젯 (총/사용/잔여)
- 월별 출근 캘린더
- 근무 시간 통계
- 최근 작업 보고서 목록
- 네비게이션 바에 "나의 대시보드" 메뉴 추가

배포 시 주의사항:
- 마이그레이션 실행 필요
- 자동 생성된 계정 초기 비밀번호: 1234
- 작업자들에게 첫 로그인 후 비밀번호 변경 안내 필요

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-19 09:49:48 +09:00
Hyungi Ahn
bc5df77595 refactor(db): Replace SELECT * with explicit columns in models
Replaced `SELECT *` statements across multiple data models with explicit column lists to improve query performance, reduce data transfer, and increase code clarity. This is part of the Phase 2 refactoring plan.

- Refactored queries in the following models:
  - projectModel
  - toolsModel
  - attendanceModel
  - dailyIssueReportModel
  - issueTypeModel
  - workReportModel
  - userModel
  - dailyWorkReportModel

fix(api): Add missing volume mounts to docker-compose

Modified docker-compose.yml to mount the `config`, `middlewares`, `utils`, and `services` directories into the API container. This fixes a `MODULE_NOT_FOUND` error that caused the container to crash on startup.

feat(db): Add migration for missing project columns

Created a new database migration to add `is_active`, `project_status`, and `completed_date` columns to the `projects` table, resolving an inconsistency between the model code and the schema.

docs: Add deployment notes

Added a new markdown file to document the testing (macOS, Docker Desktop) and production (Synology NAS, Container Manager) environments.
2025-12-19 10:33:29 +09:00
Hyungi Ahn
b67362a733 feat: Introduce knex for database migrations
- Adds knex.js to manage database schema changes systematically.
- Creates an initial migration file based on `hyungi_schema_v2.sql` to represent the current database state.
- Adds npm scripts (`db:migrate`, `db:rollback`, etc.) for easy execution of migration tasks.
- Archives legacy SQL files and old migration scripts into the `db_archive/` directory to prevent confusion and clean up the project structure.
2025-12-19 09:43:09 +09:00