init: 从 /root/zikai 根目录迁入

把原本散落在 /root/zikai 的 FastAPI 服务整理到 server/ 子目录,
开启独立 git 与 venv。运行时数据(config.yaml / keys / uploads)
按 .gitignore 留在工作目录但不入仓。
This commit is contained in:
zikai
2026-06-23 16:17:31 +00:00
commit 80b96d236f
31 changed files with 1491 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
"""UploadedFile 实体。"""
from __future__ import annotations
from datetime import datetime
from sqlalchemy import BigInteger, DateTime, String, func
from sqlalchemy.orm import Mapped, mapped_column
from ..database import Base
class UploadedFile(Base):
__tablename__ = "uploaded_file"
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
# upload_dir 下的相对路径,例如 2026/06/<uuid>.bin
storage_path: Mapped[str] = mapped_column(String(512), nullable=False)
original_filename: Mapped[str] = mapped_column(String(512), nullable=False)
content_type: Mapped[str] = mapped_column(String(255), nullable=False, default="")
size_bytes: Mapped[int] = mapped_column(BigInteger, nullable=False, default=0)
sha256: Mapped[str] = mapped_column(String(64), nullable=False, default="")
source: Mapped[str] = mapped_column(String(32), nullable=False, default="http") # http / sftp
uploaded_by: Mapped[str] = mapped_column(String(128), nullable=False, default="")
uploaded_at: Mapped[datetime] = mapped_column(
DateTime, server_default=func.now(), nullable=False
)
def __repr__(self) -> str: # pragma: no cover
return f"<UploadedFile id={self.id} name={self.original_filename!r} size={self.size_bytes}>"