feat: add models for physical files, policies, and user management
- Implement PhysicalFile model to manage physical file references and reference counting. - Create Policy model with associated options and group links for storage policies. - Introduce Redeem and Report models for handling redeem codes and reports. - Add Settings model for site configuration and user settings management. - Develop Share model for sharing objects with unique codes and associated metadata. - Implement SourceLink model for managing download links associated with objects. - Create StoragePack model for managing user storage packages. - Add Tag model for user-defined tags with manual and automatic types. - Implement Task model for managing background tasks with status tracking. - Develop User model with comprehensive user management features including authentication. - Introduce UserAuthn model for managing WebAuthn credentials. - Create WebDAV model for managing WebDAV accounts associated with users.
This commit is contained in:
50
sqlmodels/tag.py
Normal file
50
sqlmodels/tag.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from enum import StrEnum
|
||||
from typing import TYPE_CHECKING
|
||||
from uuid import UUID
|
||||
from datetime import datetime
|
||||
|
||||
from sqlmodel import Field, Relationship, UniqueConstraint, Column, func, DateTime
|
||||
|
||||
from .base import SQLModelBase
|
||||
from .mixin import TableBaseMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .user import User
|
||||
|
||||
|
||||
class TagType(StrEnum):
|
||||
"""标签类型枚举"""
|
||||
MANUAL = "manual"
|
||||
"""手动标签"""
|
||||
AUTOMATIC = "automatic"
|
||||
"""自动标签"""
|
||||
|
||||
|
||||
class Tag(SQLModelBase, TableBaseMixin):
|
||||
"""标签模型"""
|
||||
|
||||
__table_args__ = (UniqueConstraint("name", "user_id", name="uq_tag_name_user"),)
|
||||
|
||||
name: str = Field(max_length=255)
|
||||
"""标签名称"""
|
||||
|
||||
icon: str | None = Field(default=None, max_length=255)
|
||||
"""标签图标"""
|
||||
|
||||
color: str | None = Field(default=None, max_length=255)
|
||||
"""标签颜色"""
|
||||
|
||||
type: TagType = Field(default=TagType.MANUAL)
|
||||
"""标签类型"""
|
||||
expression: str | None = Field(default=None, description="自动标签的匹配表达式")
|
||||
|
||||
# 外键
|
||||
user_id: UUID = Field(
|
||||
foreign_key="user.id",
|
||||
index=True,
|
||||
ondelete="CASCADE"
|
||||
)
|
||||
"""所属用户UUID"""
|
||||
|
||||
# 关系
|
||||
user: "User" = Relationship(back_populates="tags")
|
||||
Reference in New Issue
Block a user