task: add send common mail task
All checks were successful
Gitea Actions Demo / deploy (push) Successful in 11s
All checks were successful
Gitea Actions Demo / deploy (push) Successful in 11s
This commit is contained in:
2
models/__init__.py
Normal file
2
models/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from models.source_content import SourceContent
|
||||
from models.article import Article
|
||||
50
models/article.py
Normal file
50
models/article.py
Normal file
@ -0,0 +1,50 @@
|
||||
from datetime import datetime
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
from sqlalchemy import String, Text, Integer, DateTime, func
|
||||
from models.base import Base
|
||||
|
||||
|
||||
class Article(Base):
|
||||
__tablename__ = "t_article"
|
||||
|
||||
id: Mapped[int] = mapped_column(
|
||||
Integer,
|
||||
primary_key=True,
|
||||
autoincrement=True,
|
||||
comment="自动递增的唯一内容ID"
|
||||
)
|
||||
|
||||
title: Mapped[str] = mapped_column(
|
||||
String(256),
|
||||
nullable=False,
|
||||
index=True,
|
||||
comment="标题"
|
||||
)
|
||||
|
||||
keywords: Mapped[str | None] = mapped_column(
|
||||
Text,
|
||||
nullable=True,
|
||||
comment="关键词"
|
||||
)
|
||||
|
||||
content: Mapped[str | None] = mapped_column(
|
||||
Text,
|
||||
nullable=True,
|
||||
comment="内容"
|
||||
)
|
||||
|
||||
create_time: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
server_default=func.now(),
|
||||
nullable=False,
|
||||
comment="创建时间"
|
||||
)
|
||||
|
||||
used: Mapped[bool] = mapped_column(
|
||||
default=False,
|
||||
nullable=False,
|
||||
comment="是否已被使用"
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Article id={self.id} title={self.title!r} used={self.used!r}>"
|
||||
4
models/base.py
Normal file
4
models/base.py
Normal file
@ -0,0 +1,4 @@
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
57
models/source_content.py
Normal file
57
models/source_content.py
Normal file
@ -0,0 +1,57 @@
|
||||
from datetime import datetime
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
from sqlalchemy import String, Text, Integer, DateTime, Index, func
|
||||
from models.base import Base
|
||||
|
||||
|
||||
class SourceContent(Base):
|
||||
__tablename__ = "t_source_content"
|
||||
|
||||
id: Mapped[int] = mapped_column(
|
||||
Integer,
|
||||
primary_key=True,
|
||||
autoincrement=True,
|
||||
comment="自动递增的唯一内容ID"
|
||||
)
|
||||
|
||||
link: Mapped[str] = mapped_column(
|
||||
String(2048),
|
||||
nullable=False,
|
||||
index=True,
|
||||
comment="链接"
|
||||
)
|
||||
|
||||
platform: Mapped[str] = mapped_column(
|
||||
String(32),
|
||||
nullable=False,
|
||||
comment="平台"
|
||||
)
|
||||
|
||||
content: Mapped[str | None] = mapped_column(
|
||||
Text,
|
||||
nullable=True,
|
||||
comment="内容"
|
||||
)
|
||||
|
||||
create_time: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
server_default=func.now(),
|
||||
nullable=False,
|
||||
comment="创建时间"
|
||||
)
|
||||
|
||||
update_time: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
server_default=func.now(),
|
||||
onupdate=func.now(),
|
||||
nullable=False,
|
||||
comment="更新时间"
|
||||
)
|
||||
|
||||
# ——可选优化:添加 项目 + 主题 联合唯一索引——
|
||||
__table_args__ = (
|
||||
Index("link", "link", unique=True),
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<SourceContent id={self.id} link={self.link!r} platform={self.platform!r}>"
|
||||
Reference in New Issue
Block a user