data.model.models ================= .. py:module:: data.model.models .. autoapi-nested-parse:: SQLAlchemy ORM 模型定义。 Classes ------- .. autoapisummary:: data.model.models.HistoryRecord Module Contents --------------- .. py:class:: HistoryRecord Bases: :py:obj:`backend.data.model.database.Base` 历史记录 ORM 模型,存储完整规划结果至 PostgreSQL。 设计说明: - plan_result 使用 JSONB 而非关系化展开——前端展示「分享站」时按 ID 整条读取, 无需对 plan 内容做字段级查询;全量 JSONB 写入简单,读取仅一次,适合此场景。 - 单条 plan_result 体积可达数百 KB(含 polylines/cost_matrix), 分页列表只返回摘要字段(id/city/n_days/cost 等),不加载 JSONB 列。 - device_id 由前端 localStorage 自动生成,仅用于删除鉴权——软鉴权设计, 不引入真实用户系统,对访客零门槛。 .. py:attribute:: __tablename__ :value: 'history_records' .. py:attribute:: id .. py:attribute:: device_id .. py:attribute:: note .. py:attribute:: city .. py:attribute:: hotel .. py:attribute:: n_days .. py:attribute:: cost .. py:attribute:: spot_count .. py:attribute:: plan_result .. py:attribute:: request_params .. py:attribute:: created_at