mirror of
https://github.com/insistence/RuoYi-Vue3-FastAPI.git
synced 2026-10-06 01:28:02 +00:00
* feat: 初始化插件系统 * refactor: 收口插件系统运行时重构 * perf: 优化插件系统类型提示 * fix&perf: 修复和优化插件系统 * fix: 修复gitignore规则误忽略插件文件的问题 * fix: 修复运行时插件根路径算错的问题 * fix: 加强插件发现和路由注册的防护措施 * revert: 回滚定时任务白名单 * fix: 移除未使用的应用路由注册探测 * revert: 恢复部分代码 * perf: 优化插件系统 * docs: 新增插件开发文档 * perf: 优化插件管理模块 * perf: 提升插件系统核心能力 * refactor: 重构生命周期 step runner * fix: 修复lint错误 * test: 清理测试用例 * test: 调整测试目录名称 * fix: 修复前后端目录硬编码的问题 * fix: 修复插件系统安全性缺口 * refactor: 重新设计插件生命周期 Migration 事务与回滚 * perf: 优化插件系统边界问题 * refactor: 重构当前插件系统的依赖体系设计 * perf: 优化代码 * perf: 优化代码 * fix: 修复代码合并问题 * fix: 修复bug * perf: 优化代码 * perf&fix: 优化代码和修复bug * docs: 优化文档格式 * feat: 适配Vue2版本 * docs: 更新README文档 * fix: 修复ruff lint错误 * chore: 更新后端依赖文件
71 lines
2.1 KiB
Python
71 lines
2.1 KiB
Python
from collections.abc import Mapping
|
|
|
|
from plugins.core.runtime.support import PluginRuntimePayloadBuilder
|
|
from utils.log_util import logger
|
|
|
|
from .dependency_container import PluginRuntimeDependencies
|
|
|
|
|
|
class PluginAuditUseCase:
|
|
"""
|
|
插件操作审计和失败状态记录 use case。
|
|
"""
|
|
|
|
def __init__(self, dependencies: PluginRuntimeDependencies) -> None:
|
|
"""
|
|
初始化插件审计 use case。
|
|
|
|
:param dependencies: 插件运行时依赖容器
|
|
"""
|
|
self.dependencies = dependencies
|
|
|
|
async def record_plugin_operation_log(
|
|
self,
|
|
payload: Mapping[str, object],
|
|
*,
|
|
dry_run: bool,
|
|
continue_on_error: bool,
|
|
) -> None:
|
|
"""
|
|
记录插件操作审计日志。
|
|
|
|
dry-run 不调用该方法,保持预演无写入语义。
|
|
|
|
:param payload: 插件操作结果负载
|
|
:param dry_run: 是否预演
|
|
:param continue_on_error: 失败后是否继续执行后续插件
|
|
:return: None
|
|
"""
|
|
await self.dependencies.audit_gateway.add_plugin_operation_log(
|
|
dict(payload),
|
|
dry_run=dry_run,
|
|
continue_on_error=continue_on_error,
|
|
)
|
|
|
|
async def record_plugin_failure_state(
|
|
self,
|
|
payload: Mapping[str, object],
|
|
default_message: str,
|
|
) -> None:
|
|
"""
|
|
记录插件操作失败状态。
|
|
|
|
失败状态写入仅作为可恢复运行状态提示,不改变原始操作返回结果。
|
|
|
|
:param payload: 插件操作返回负载
|
|
:param default_message: 缺省失败信息
|
|
:return: None
|
|
"""
|
|
if payload.get('ok') is not False:
|
|
return
|
|
plugin_id = payload.get('pluginId')
|
|
if not isinstance(plugin_id, str) or not plugin_id:
|
|
return
|
|
|
|
error_message = PluginRuntimePayloadBuilder.build_failure_state_message(payload, default_message)
|
|
try:
|
|
await self.dependencies.audit_gateway.mark_plugin_error(plugin_id, error_message)
|
|
except Exception:
|
|
logger.exception('记录插件失败状态失败:plugin_id=%s', plugin_id)
|
|
return
|