1
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"""用户操作日志:用于排查 bug 时还原用户行为时间线(仅特定账号开启上报)"""
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, Index, String, func
|
||||
from sqlalchemy.dialects.mysql import BIGINT
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class UserActionLog(Base):
|
||||
__tablename__ = "user_action_logs"
|
||||
|
||||
id: Mapped[int] = mapped_column(BIGINT(unsigned=True), primary_key=True, autoincrement=True)
|
||||
user_id: Mapped[int] = mapped_column(BIGINT(unsigned=True))
|
||||
action: Mapped[str] = mapped_column(String(50), comment="route_push/player_stopall/api_error/...")
|
||||
page: Mapped[str] = mapped_column(String(100), default="", comment="路由路径或页面标识")
|
||||
detail: Mapped[str] = mapped_column(String(1000), default="", comment="行为上下文(JSON 字符串)")
|
||||
device_info: Mapped[str] = mapped_column(String(200), default="", comment="机型/系统/版本")
|
||||
app_version: Mapped[str] = mapped_column(String(20), default="", comment="1.3.26+42")
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_user_created", "user_id", "created_at"),
|
||||
Index("idx_action_created", "action", "created_at"),
|
||||
)
|
||||
Reference in New Issue
Block a user