- FastAPI 라우터에서 슬래시 문제로 인한 307 리다이렉트 수정 - Nginx 프록시 설정에서 경로 중복 문제 해결 - 계정 관리 시스템 구현 (로그인, 사용자 관리, 권한 설정) - 노트북 연결 기능 수정 (notebook_id 필드 추가) - 메모 트리 UI 개선 (수평 레이아웃, 드래그 기능 제거) - 헤더 UI 개선 및 고정 위치 설정 - 백업/복원 스크립트 추가 - PDF 미리보기 토큰 인증 지원
59 lines
2.8 KiB
Python
59 lines
2.8 KiB
Python
"""
|
|
노트 문서 링크 모델
|
|
"""
|
|
from sqlalchemy import Column, String, DateTime, Text, Integer, ForeignKey
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
import uuid
|
|
|
|
from ..core.database import Base
|
|
|
|
|
|
class NoteLink(Base):
|
|
"""노트 문서 링크 테이블"""
|
|
__tablename__ = "note_links"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
|
|
# 링크가 생성된 노트 (출발점) - 노트 문서 또는 일반 문서 가능
|
|
source_note_id = Column(UUID(as_uuid=True), ForeignKey('notes_documents.id'), nullable=True, index=True)
|
|
source_document_id = Column(UUID(as_uuid=True), ForeignKey('documents.id'), nullable=True, index=True)
|
|
|
|
# 링크 대상 노트 (도착점) - 노트 문서 또는 일반 문서 가능
|
|
target_note_id = Column(UUID(as_uuid=True), ForeignKey('notes_documents.id'), nullable=True, index=True)
|
|
target_document_id = Column(UUID(as_uuid=True), ForeignKey('documents.id'), nullable=True, index=True)
|
|
|
|
# 출발점 텍스트 정보
|
|
selected_text = Column(Text, nullable=False) # 선택된 텍스트
|
|
start_offset = Column(Integer, nullable=False) # 시작 위치
|
|
end_offset = Column(Integer, nullable=False) # 끝 위치
|
|
|
|
# 도착점 텍스트 정보
|
|
target_text = Column(Text, nullable=True) # 대상에서 선택된 텍스트
|
|
target_start_offset = Column(Integer, nullable=True) # 대상에서 시작 위치
|
|
target_end_offset = Column(Integer, nullable=True) # 대상에서 끝 위치
|
|
|
|
# 링크 메타데이터
|
|
link_text = Column(String(500), nullable=True) # 사용자 정의 링크 텍스트
|
|
description = Column(Text, nullable=True) # 링크 설명
|
|
|
|
# 링크 타입
|
|
link_type = Column(String(20), default="note", nullable=False) # "note", "document", "text_fragment"
|
|
|
|
# 생성자 정보
|
|
created_by = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
# 관계 설정
|
|
source_note = relationship("NoteDocument", foreign_keys=[source_note_id], backref="outgoing_note_links")
|
|
source_document = relationship("Document", foreign_keys=[source_document_id], backref="outgoing_note_links")
|
|
target_note = relationship("NoteDocument", foreign_keys=[target_note_id], backref="incoming_note_links")
|
|
target_document = relationship("Document", foreign_keys=[target_document_id], backref="incoming_note_links")
|
|
creator = relationship("User", backref="created_note_links")
|
|
|
|
def __repr__(self):
|
|
return f"<NoteLink(id={self.id}, source_note={self.source_note_id}, target_note={self.target_note_id})>"
|
|
|