certflow.controllers.history_controller module¶ 打印历史控制器 封装打印历史的查询逻辑,隔离 View 层对 Model 的直接依赖。 class certflow.controllers.history_controller.HistoryController(session)[源代码]¶ 基类:object 打印历史控制器 为 HistoryView 提供数据查询能力,View 不直接操作 ORM。 参数: session (Session) get_recent_logs(limit=200)[源代码]¶ 获取最近的打印日志 参数: limit (int) -- 返回条数上限,默认 200 返回: PrintLog 列表,按 id 降序排列 返回类型: list[PrintLog] query_logs(filters=None, limit=2000)[源代码]¶ 按条件查询打印日志(日期区间 + 型号搜索,参数化防注入) 参数: filters (dict | None) -- 过滤条件字典(见 CertLogService.query_logs) limit (int) -- 返回条数上限,默认 2000 返回: PrintLog 列表,按 id 降序排列 返回类型: list[PrintLog] export_logs_csv(logs, file_path)[源代码]¶ 将打印日志导出为 CSV(UTF-8 BOM) 收口 View 对 handlers.csv_export 的直连调用,使导出动作 也经 Controller 统一分发,符合 M5「View→Controller 收口」架构约束。 参数: logs (Sequence[PrintLog]) -- PrintLog 序列 file_path (str) -- 输出文件路径 返回: 导出的数据行数(不含表头) 返回类型: int