Commit Graph

3 Commits

Author SHA1 Message Date
e71cdb2cda 완전한 약국 관리 및 사용자-약국 매칭 시스템 구현
🏥 약국 관리 API 구현:
- POST /api/pharmacy - 새 약국 생성 (모든 DB 칼럼 지원)
- PUT /api/pharmacy/<id> - 약국 정보 수정
- DELETE /api/pharmacy/<id>/delete - 약국 삭제
- 약국 관리 페이지 UI 완전 연동

👤 사용자-약국 매칭 시스템:
- POST /api/users/<user>/link-pharmacy - 사용자와 약국 연결
- 실시간 매칭 상태 표시 및 업데이트
- Headscale 사용자와 FARMQ 약국 간 완전한 연결

🔧 핵심 설계 원칙 100% 준수:
- Headscale CLI 기반 제어 (사용자 생성/삭제)
- 이중 사용자 구분 (Headscale ↔ FARMQ 약국)
- 느슨한 결합 (headscale_user_name 매핑)
- 실시간 동기화 (API 호출 즉시 반영)

 전체 시스템 통합 테스트 완료:
- 약국 생성 → 사용자 생성 → 매칭 → 실시간 확인
- DB 칼럼 구조와 완벽 일치
- UI/API 완전 연동

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 11:17:13 +09:00
1f0afd4cae Fix machine count display and pharmacy edit functionality
🔧 Machine Management Fixes:
- Fix duplicate machine counting (was showing 10 instead of 5)
- Update dashboard stats to use Headscale nodes instead of FARMQ profiles
- Fix JavaScript counting to only count active view (List/Card)
- Add view change listeners to update counters correctly

🏥 Pharmacy Management Fixes:
- Add API endpoint for individual pharmacy data retrieval
- Fix pharmacy edit modal to load existing data as form values
- Add proper form validation and error handling
- Implement edit vs add mode detection

📊 Database Integration:
- Improve machine counting logic using Headscale Node table
- Fix online/offline status calculation with 5-minute threshold
- Add debug logging for machine data retrieval

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 09:41:55 +09:00
ca61a89739 🏥 Add complete FARMQ Admin Flask application
## Features
- 한국어 Flask 관리 인터페이스 with Bootstrap 5
- Headscale과 분리된 독립 데이터베이스 구조
- 약국 관리 시스템 (pharmacy management)
- 머신 모니터링 및 상태 관리
- 실시간 대시보드 with 통계 및 알림
- Headscale 사용자명과 약국명 분리 관리

## Database Architecture
- 별도 FARMQ SQLite DB (farmq.sqlite)
- Headscale DB와 외래키 충돌 방지
- 느슨한 결합 설계 (ID 참조만 사용)

## UI Components
- 반응형 대시보드 with 실시간 통계
- 약국별 머신 상태 모니터링
- 한국어 지역화 및 사용자 친화적 인터페이스
- 머신 온라인/오프라인 상태 표시 (24시간 타임아웃)

## API Endpoints
- `/api/sync/machines` - Headscale 머신 동기화
- `/api/sync/users` - Headscale 사용자 동기화
- `/api/pharmacy/<id>/update` - 약국 정보 업데이트
- 대시보드 통계 및 알림 API

## Problem Resolution
- Fixed foreign key conflicts preventing Windows client connections
- Resolved machine online status detection with proper timeout handling
- Separated technical Headscale usernames from business pharmacy names

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 17:44:56 +09:00