前后端更新
This commit is contained in:
1 parent
a0c8721fbb
commit
24da604727
33 files changed
+1951
-580
No files matched your search
+22
-5
@@ -4,6 +4,7 @@ from typing import Optional, List
|
||||
from sqlalchemy import String, Text, Integer, ForeignKey, JSON, DateTime, Index
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from app import db
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
|
||||
class Base(db.Model):
|
||||
"""
|
||||
@@ -19,8 +20,6 @@ user_agent_permissions = db.Table(
|
||||
db.Column('agent_id', ForeignKey('agents.id'), primary_key=True)
|
||||
)
|
||||
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
|
||||
class ZlLanguage(Base):
|
||||
"""
|
||||
多语言配置表
|
||||
@@ -123,6 +122,10 @@ class User(Base):
|
||||
secondary=user_agent_permissions,
|
||||
back_populates="users"
|
||||
)
|
||||
|
||||
# 密码重置 Token
|
||||
reset_token: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||
reset_token_expiry: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
def set_password(self, password):
|
||||
self.password_hash = generate_password_hash(password)
|
||||
@@ -183,9 +186,9 @@ class ChatLog(Base):
|
||||
agent_id: Mapped[int] = mapped_column(ForeignKey('agents.id'))
|
||||
query: Mapped[str] = mapped_column(Text)
|
||||
answer: Mapped[str] = mapped_column(Text)
|
||||
latency: Mapped[float] = mapped_column(default=0.0) # 响应耗时
|
||||
conversation_id: Mapped[Optional[str]] = mapped_column(String(100)) # Dify 会话 ID
|
||||
tokens_used: Mapped[Optional[int]] = mapped_column(Integer, default=0) # 消耗 token 数
|
||||
latency: Mapped[int] = mapped_column(default=0)
|
||||
conversation_id: Mapped[Optional[str]] = mapped_column(String(100))
|
||||
tokens_used: Mapped[int] = mapped_column(default=0)
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow)
|
||||
|
||||
# 关联 Feedback
|
||||
@@ -235,3 +238,17 @@ class QuickQuestion(Base):
|
||||
question: Mapped[str] = mapped_column(Text)
|
||||
sort_order: Mapped[int] = mapped_column(default=0)
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow)
|
||||
|
||||
class Announcement(Base):
|
||||
"""
|
||||
公告表
|
||||
用途:存储系统公告
|
||||
"""
|
||||
__tablename__ = 'announcements'
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
title: Mapped[str] = mapped_column(String(200))
|
||||
content: Mapped[str] = mapped_column(Text)
|
||||
is_active: Mapped[bool] = mapped_column(default=True)
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow)
|
||||
updated_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
Reference in new issue
Block a user