feat(shipping-notice): 增强订单抽取功能,添加进度事件和诊断运行管理,优化数据模型和访问控制
This commit is contained in:
1 parent
ce26d6d0c4
commit
c4095b08da
175 files changed
+13064
-1814
No files matched your search
@@ -29,9 +29,20 @@ def serialize_agent(agent: Agent) -> dict:
|
||||
return serialize_agent_for_admin(agent)
|
||||
|
||||
|
||||
def list_agents() -> list[dict]:
|
||||
"""返回全部 Agent(按 id 升序)。"""
|
||||
agents = db.session.query(Agent).order_by(Agent.id.asc()).all()
|
||||
def list_agents(*, scope: str | None = None) -> list[dict]:
|
||||
"""按管理域返回 Agent;scope=applications/executors,缺省返回全部兼容旧客户端。"""
|
||||
query = db.session.query(Agent)
|
||||
if scope == 'applications':
|
||||
query = query.filter(Agent.exposure_mode == 'workspace')
|
||||
elif scope == 'executors':
|
||||
query = query.filter(Agent.exposure_mode == 'internal')
|
||||
elif scope not in (None, ''):
|
||||
raise ValidationError(
|
||||
'Invalid agent management scope',
|
||||
code='AGENT.ADMIN_SCOPE_INVALID',
|
||||
details={'scope': scope},
|
||||
)
|
||||
agents = query.order_by(Agent.id.asc()).all()
|
||||
return [serialize_agent(a) for a in agents]
|
||||
|
||||
|
||||
@@ -346,6 +357,11 @@ def update_agent_permissions(agent_id: int, user_ids: list[int]) -> None:
|
||||
agent = db.session.get(Agent, agent_id)
|
||||
if not agent:
|
||||
raise NotFoundError('Not found')
|
||||
if agent.exposure_mode == 'internal' and user_ids:
|
||||
raise ValidationError(
|
||||
'内部执行器不可授予用户权限',
|
||||
code='AGENT.INTERNAL_EXECUTOR_PERMISSION_FORBIDDEN',
|
||||
)
|
||||
current_users = db.session.query(User).filter(User.agents.contains(agent)).all()
|
||||
current_user_ids = {u.id for u in current_users}
|
||||
new_user_ids = set(user_ids)
|
||||
|
||||
Reference in new issue
Block a user