企业微信

This commit is contained in:
super committed 2026-04-20 09:08:58 +08:00
1 parent 46ac70f4c5
commit a9fc852abb
33 files changed
+4875 -106

No files matched your search

+64
View File
@@ -274,7 +274,71 @@ class LoginAudit(Base):
source: Mapped[str] = mapped_column(String(20), default='password') # password / wecom
status: Mapped[str] = mapped_column(String(20), default='success') # success / failed
reason: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
error_code: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
match_rules: Mapped[Optional[str]] = mapped_column(String(128), nullable=True)
match_operator: Mapped[Optional[str]] = mapped_column(String(8), nullable=True)
match_result: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
wecom_userid: Mapped[Optional[str]] = mapped_column(String(128), nullable=True)
ip: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
user_agent: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, index=True)
class WecomNotifyAudit(Base):
"""
企业微信触达审计表
用途:记录企微消息发送结果与回流点击数据
"""
__tablename__ = 'wecom_notify_audits'
id: Mapped[int] = mapped_column(primary_key=True)
event_type: Mapped[str] = mapped_column(String(64), index=True)
status: Mapped[str] = mapped_column(String(20), default='sent', index=True) # sent / failed
trace_id: Mapped[str] = mapped_column(String(64), unique=True, index=True)
user_id: Mapped[Optional[int]] = mapped_column(ForeignKey('users.id'), nullable=True, index=True)
username: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
wecom_userid: Mapped[Optional[str]] = mapped_column(String(128), nullable=True)
title: Mapped[Optional[str]] = mapped_column(String(120), nullable=True)
content: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
jump_url: Mapped[Optional[str]] = mapped_column(String(512), nullable=True)
error_code: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
error_message: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, index=True)
opened_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True, index=True)
class AppSetting(Base):
"""
应用运行时配置表(Key/Value)
用途:将企业微信等管理员可编辑的配置长效保存到数据库,
避免容器/部署重建后写入 backend/.env 的修改丢失。
"""
__tablename__ = 'app_settings'
key: Mapped[str] = mapped_column(String(128), primary_key=True)
value: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
updated_at: Mapped[datetime] = mapped_column(
DateTime, default=datetime.utcnow, onupdate=datetime.utcnow
)
class WecomCallbackAudit(Base):
"""
企业微信回调审计表
用途:记录消息与事件回调(安全模式解密后的内容摘要)
"""
__tablename__ = 'wecom_callback_audits'
id: Mapped[int] = mapped_column(primary_key=True)
msg_signature: Mapped[Optional[str]] = mapped_column(String(128), nullable=True)
timestamp: Mapped[Optional[str]] = mapped_column(String(32), nullable=True)
nonce: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
encrypt_raw: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
decrypted_xml: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
msg_type: Mapped[Optional[str]] = mapped_column(String(32), nullable=True, index=True)
event: Mapped[Optional[str]] = mapped_column(String(64), nullable=True, index=True)
from_user: Mapped[Optional[str]] = mapped_column(String(128), nullable=True, index=True)
agent_id: Mapped[Optional[str]] = mapped_column(String(32), nullable=True)
msg_id: Mapped[Optional[str]] = mapped_column(String(64), nullable=True, index=True)
error_message: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, index=True)