refactor(backend): 迁移基础设施,core,拆分models
This commit is contained in:
1 parent
b89d93d738
commit
053ea392f2
61 files changed
+3329
-3268
No files matched your search
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
backend/app/models/base.py
|
||||
|
||||
用途:SQLAlchemy 抽象基类与用户-Agent RBAC 关联表。
|
||||
依赖:app.extensions.db。
|
||||
逻辑:各域 model 模块继承 Base;User.agents / Agent.users 共用 user_agent_permissions。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy import ForeignKey
|
||||
|
||||
from app.extensions import db
|
||||
|
||||
|
||||
class Base(db.Model):
|
||||
"""抽象基类,所有业务模型继承此类。"""
|
||||
|
||||
__abstract__ = True
|
||||
|
||||
|
||||
# RBAC 关联表:用户与 Agent 的多对多关系
|
||||
user_agent_permissions = db.Table(
|
||||
'user_agent_permissions',
|
||||
db.Column('user_id', ForeignKey('users.id'), primary_key=True),
|
||||
db.Column('agent_id', ForeignKey('agents.id'), primary_key=True),
|
||||
)
|
||||
Reference in new issue
Block a user