feat:历史记录分享功能实现
This commit is contained in:
@@ -137,3 +137,34 @@ class UserAgent(Base):
|
||||
"agent_config": self.agent_config,
|
||||
"created_at": self.created_at.isoformat() if self.created_at else None,
|
||||
}
|
||||
|
||||
|
||||
class PlanShare(Base):
|
||||
"""任务分享记录模型"""
|
||||
__tablename__ = "plan_shares"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
share_token = Column(String(64), unique=True, index=True, nullable=False) # 唯一分享码
|
||||
extraction_code = Column(String(8), nullable=True) # 提取码(4位字母数字)
|
||||
task_id = Column(String(64), nullable=False, index=True) # 关联的任务ID
|
||||
task_data = Column(JSONB, nullable=False) # 完整的任务数据(脱敏后)
|
||||
created_at = Column(DateTime(timezone=True), default=utc_now)
|
||||
expires_at = Column(DateTime(timezone=True), nullable=True) # 过期时间
|
||||
view_count = Column(Integer, default=0) # 查看次数
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_plan_shares_token", "share_token"),
|
||||
)
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""转换为字典"""
|
||||
return {
|
||||
"id": self.id,
|
||||
"share_token": self.share_token,
|
||||
"extraction_code": self.extraction_code,
|
||||
"task_id": self.task_id,
|
||||
"task_data": self.task_data,
|
||||
"created_at": self.created_at.isoformat() if self.created_at else None,
|
||||
"expires_at": self.expires_at.isoformat() if self.expires_at else None,
|
||||
"view_count": self.view_count,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user