Files
beabigegg 3108fe1dff 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>
2025-12-29 22:03:05 +08:00

45 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## MODIFIED Requirements
### Requirement: Audit Trail
系統 SHALL 記錄所有文件操作供稽核追溯,整合現有 audit-trail 模組。
#### Scenario: 操作日誌記錄
- **GIVEN** 使用者對附件執行任何操作(上傳、下載、刪除)
- **WHEN** 操作完成
- **THEN** 系統透過 AuditService 記錄操作至 `pjctrl_audit_logs`
- **AND** 使用 event_type: `attachment.upload`, `attachment.download`, `attachment.delete`
#### Scenario: 稽核查詢
- **GIVEN** 稽核人員需要查詢文件操作歷史
- **WHEN** 稽核人員透過 Audit API 執行查詢
- **THEN** 可依 resource_type=attachment 篩選
- **AND** 顯示完整操作歷史
## ADDED Requirements
### Requirement: File Size Limits
系統 SHALL 限制上傳檔案大小以確保系統穩定性。
#### Scenario: 檔案大小驗證
- **GIVEN** 使用者上傳檔案
- **WHEN** 檔案大小超過限制(預設 50MB
- **THEN** 系統拒絕上傳並回傳錯誤訊息
#### Scenario: 大小限制配置
- **GIVEN** 管理者需要調整檔案大小限制
- **WHEN** 設定環境變數 MAX_FILE_SIZE_MB
- **THEN** 系統使用新的限制值
### Requirement: Mime Type Validation
系統 SHALL 驗證上傳檔案類型以確保安全性。
#### Scenario: 允許的檔案類型
- **GIVEN** 使用者上傳附件
- **WHEN** 檔案類型為常見文件格式pdf, doc, xls, jpg, png, zip 等)
- **THEN** 系統接受上傳
#### Scenario: 危險檔案類型拒絕
- **GIVEN** 使用者上傳附件
- **WHEN** 檔案類型為可執行檔exe, bat, sh, dll 等)
- **THEN** 系統拒絕上傳並回傳錯誤訊息