65 lines
3.0 KiB
Python
65 lines
3.0 KiB
Python
"""通用域:notifications / reports / sensitive_words / system_configs"""
|
||
from datetime import datetime
|
||
|
||
from sqlalchemy import DateTime, Index, SmallInteger, String, func
|
||
from sqlalchemy.dialects.mysql import BIGINT, INTEGER
|
||
from sqlalchemy.orm import Mapped, mapped_column
|
||
|
||
from app.models.base import Base
|
||
|
||
|
||
class Notification(Base):
|
||
__tablename__ = "notifications"
|
||
|
||
id: Mapped[int] = mapped_column(BIGINT(unsigned=True), primary_key=True, autoincrement=True)
|
||
user_id: Mapped[int] = mapped_column(BIGINT(unsigned=True), comment="接收人")
|
||
type: Mapped[int] = mapped_column(SmallInteger, comment="1审核结果 2提现进度 3系统公告 4评论回复")
|
||
title: Mapped[str] = mapped_column(String(100), default="")
|
||
content: Mapped[str] = mapped_column(String(500), default="")
|
||
biz_id: Mapped[str] = mapped_column(String(64), default="")
|
||
is_read: Mapped[int] = mapped_column(SmallInteger, default=0)
|
||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
||
|
||
__table_args__ = (Index("idx_user_read", "user_id", "is_read", "id"),)
|
||
|
||
|
||
class Report(Base):
|
||
__tablename__ = "reports"
|
||
|
||
id: Mapped[int] = mapped_column(BIGINT(unsigned=True), primary_key=True, autoincrement=True)
|
||
user_id: Mapped[int] = mapped_column(BIGINT(unsigned=True), comment="举报人")
|
||
target_type: Mapped[int] = mapped_column(SmallInteger, comment="1视频 2评论")
|
||
target_id: Mapped[int] = mapped_column(BIGINT(unsigned=True))
|
||
reason_type: Mapped[int] = mapped_column(SmallInteger, comment="1色情低俗 2暴力血腥 3侵权 4广告营销 5其他")
|
||
remark: Mapped[str] = mapped_column(String(200), default="")
|
||
status: Mapped[int] = mapped_column(SmallInteger, default=0, comment="0待处理 1已处理 2已驳回")
|
||
handle_result: Mapped[str] = mapped_column(String(50), default="")
|
||
admin_id: Mapped[int | None] = mapped_column(BIGINT(unsigned=True))
|
||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
||
handled_at: Mapped[datetime | None] = mapped_column(DateTime)
|
||
|
||
__table_args__ = (
|
||
Index("uk_user_target", "user_id", "target_type", "target_id", unique=True),
|
||
Index("idx_status", "status", "created_at"),
|
||
)
|
||
|
||
|
||
class SensitiveWord(Base):
|
||
__tablename__ = "sensitive_words"
|
||
|
||
id: Mapped[int] = mapped_column(INTEGER(unsigned=True), primary_key=True, autoincrement=True)
|
||
word: Mapped[str] = mapped_column(String(50), unique=True)
|
||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
||
|
||
|
||
class SystemConfig(Base):
|
||
"""平台配置键值对(后台可改,Redis 缓存 60s)"""
|
||
|
||
__tablename__ = "system_configs"
|
||
|
||
config_key: Mapped[str] = mapped_column(String(50), primary_key=True)
|
||
config_value: Mapped[str] = mapped_column(String(500), default="")
|
||
description: Mapped[str] = mapped_column(String(200), default="")
|
||
updated_by: Mapped[int | None] = mapped_column(BIGINT(unsigned=True))
|
||
updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())
|