feat: 实现起卦、设置与积分系统

This commit is contained in:
qzl
2026-04-03 16:56:47 +08:00
parent 31594558eb
commit f245eec5f6
170 changed files with 20728 additions and 328 deletions
+35
View File
@@ -0,0 +1,35 @@
from __future__ import annotations
import uuid
from sqlalchemy import CheckConstraint, ForeignKey, Index, JSON, String, Text, text
from sqlalchemy.dialects.postgresql import JSONB, UUID
from sqlalchemy.orm import Mapped, mapped_column
from core.db.base import Base, SoftDeleteMixin, TimestampMixin
class Profile(TimestampMixin, SoftDeleteMixin, Base):
__tablename__ = "profiles"
__table_args__ = (
CheckConstraint(
"char_length(username) >= 1", name="ck_profiles_username_non_empty"
),
Index("ix_profiles_username", "username"),
Index("ix_profiles_settings_gin", "settings", postgresql_using="gin"),
)
id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
ForeignKey("auth.users.id", ondelete="CASCADE"),
primary_key=True,
)
username: Mapped[str] = mapped_column(String(30), nullable=False)
avatar_url: Mapped[str | None] = mapped_column(Text, nullable=True)
bio: Mapped[str | None] = mapped_column(String(200), nullable=True)
settings: Mapped[dict[str, object]] = mapped_column(
JSON().with_variant(JSONB, "postgresql"),
nullable=False,
server_default=text("'{}'::jsonb"),
default=dict,
)