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:
26
backend/app/models/attachment_version.py
Normal file
26
backend/app/models/attachment_version.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import uuid
|
||||
from sqlalchemy import Column, String, Integer, BigInteger, DateTime, ForeignKey, Index
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class AttachmentVersion(Base):
|
||||
__tablename__ = "pjctrl_attachment_versions"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
attachment_id = Column(String(36), ForeignKey("pjctrl_attachments.id", ondelete="CASCADE"), nullable=False)
|
||||
version = Column(Integer, nullable=False)
|
||||
file_path = Column(String(1000), nullable=False)
|
||||
file_size = Column(BigInteger, nullable=False)
|
||||
checksum = Column(String(64), nullable=False) # SHA-256
|
||||
uploaded_by = Column(String(36), ForeignKey("pjctrl_users.id", ondelete="SET NULL"), nullable=True)
|
||||
created_at = Column(DateTime, server_default=func.now(), nullable=False)
|
||||
|
||||
# Relationships
|
||||
attachment = relationship("Attachment", back_populates="versions")
|
||||
uploader = relationship("User", foreign_keys=[uploaded_by])
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_version_attachment", "attachment_id", "version"),
|
||||
)
|
||||
Reference in New Issue
Block a user