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>
This commit is contained in:
@@ -4,20 +4,14 @@
|
||||
*/
|
||||
exports.up = async function(knex) {
|
||||
await knex.schema.alterTable('workers', (table) => {
|
||||
// 작업 보고서 표시 여부 (기본값: true, 작업자는 표시, 관리자는 선택 가능)
|
||||
table.boolean('show_in_work_reports')
|
||||
.defaultTo(true)
|
||||
.notNullable()
|
||||
.comment('작업 보고서에 표시 여부');
|
||||
|
||||
// 재직 상태 (employed: 재직, resigned: 퇴사)
|
||||
table.enum('employment_status', ['employed', 'resigned'])
|
||||
.defaultTo('employed')
|
||||
.notNullable()
|
||||
.comment('재직 상태');
|
||||
.comment('재직 상태 (employed: 재직, resigned: 퇴사)');
|
||||
});
|
||||
|
||||
console.log('✅ workers 테이블에 show_in_work_reports, employment_status 컬럼 추가 완료');
|
||||
console.log('✅ workers 테이블에 employment_status 컬럼 추가 완료');
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -26,9 +20,8 @@ exports.up = async function(knex) {
|
||||
*/
|
||||
exports.down = async function(knex) {
|
||||
await knex.schema.alterTable('workers', (table) => {
|
||||
table.dropColumn('show_in_work_reports');
|
||||
table.dropColumn('employment_status');
|
||||
});
|
||||
|
||||
console.log('✅ workers 테이블에서 show_in_work_reports, employment_status 컬럼 삭제 완료');
|
||||
console.log('✅ workers 테이블에서 employment_status 컬럼 삭제 완료');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user