feat: implement document management module

- Backend (FastAPI):
  - Attachment and AttachmentVersion models with migration
  - FileStorageService with SHA-256 checksum validation
  - File type validation (whitelist/blacklist)
  - Full CRUD API with version control support
  - Audit trail integration for upload/download/delete
  - Configurable upload directory and file size limit

- Frontend (React + Vite):
  - AttachmentUpload component with drag & drop
  - AttachmentList component with download/delete
  - TaskAttachments combined component
  - Attachments service for API calls

- Testing:
  - 12 tests for storage service and API endpoints

- OpenSpec:
  - add-document-management change archived

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beabigegg
2025-12-29 22:03:05 +08:00
parent 0ef78e13ff
commit 3108fe1dff
21 changed files with 2027 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
# Change: Add Document Management
## Why
專案管理系統需要文件附件功能,讓使用者能在任務層級上傳、下載、管理檔案。半導體產業對機密文件有特殊安全需求(加密存儲、浮水印追溯)。
## What Changes
- **新增 Attachment 模型** - 支援任務層級的檔案附件
- **新增 AttachmentVersion 模型** - 檔案版本控制
- **新增 File Storage Service** - 本地檔案存儲(可擴展至 NAS
- **新增 Attachment API** - 上傳、下載、刪除、版本管理
- **新增加密功能** - AES-256 加密存儲(機密專案)
- **新增浮水印功能** - 下載時動態加入使用者資訊
- **整合 Audit Trail** - 記錄所有文件操作
## Impact
- Affected specs: `document-management`, `audit-trail` (已實作)
- Affected code:
- `backend/app/models/` - 新增 attachment 相關模型
- `backend/app/api/` - 新增 attachments router
- `backend/app/services/` - 新增 file_service, encryption_service
- `frontend/src/components/` - 新增附件元件
- `backend/migrations/` - 新增資料表
## Implementation Phases
### Phase 1: Basic Attachments (MVP)
- 檔案上傳/下載/刪除
- 本地檔案存儲
- 基本 API 與前端整合
- Audit 日誌整合
### Phase 2: Version Control
- 同名檔案版本控制
- 版本歷史查看
- 版本回復
### Phase 3: Security Features (Optional)
- AES-256 加密存儲
- 動態浮水印(圖片/PDF
- 加密金鑰管理
## Dependencies
- audit-trail (已完成) - 用於文件操作日誌
- collaboration (已完成) - 可在評論中引用附件