Some checks failed
Test / test (push) Failing after 3m47s
- 替换 Field(max_length=X) 为 StrX/TextX 类型别名(21 个 sqlmodels 文件) - 替换 get + 404 检查为 get_exist_one()(17 个路由文件,约 50 处) - 替换 save + session.refresh 为 save(load=...) - 替换 session.add + commit 为 save()(dav/provider.py) - 更新所有依赖至最新版本 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
841 B
Python
36 lines
841 B
Python
|
||
from typing import TYPE_CHECKING
|
||
from uuid import UUID
|
||
|
||
from sqlmodel import Field, Relationship, Index
|
||
|
||
from sqlmodel_ext import SQLModelBase, TableBaseMixin, Str255
|
||
|
||
if TYPE_CHECKING:
|
||
from .object import Object
|
||
|
||
|
||
class SourceLink(SQLModelBase, TableBaseMixin):
|
||
"""链接模型"""
|
||
|
||
__table_args__ = (
|
||
Index("ix_sourcelink_object_name", "object_id", "name"),
|
||
)
|
||
|
||
name: Str255
|
||
"""链接名称"""
|
||
|
||
downloads: int = Field(default=0, sa_column_kwargs={"server_default": "0"})
|
||
"""通过此链接的下载次数"""
|
||
|
||
# 外键
|
||
object_id: UUID = Field(
|
||
foreign_key="object.id",
|
||
index=True,
|
||
ondelete="CASCADE"
|
||
)
|
||
"""关联的对象UUID(必须是文件类型)"""
|
||
|
||
# 关系
|
||
object: "Object" = Relationship(back_populates="source_links")
|
||
"""关联的对象""" |