
学生生活日常记录学生每天的睡眠、运动、饮食、屏幕使用、情绪和压力,是班主任观察学生状态波动的重要依据。它与稳定生活画像不同,关注的是按日期持续更新的过程数据。
本文基于 StudentLifeDaily 的模型、视图和 fast-crud 页面,把学生选择、日期筛选、抽屉回显和数据维护转换为 Codex 可执行任务。
文章目录
设计与需求
学生生活日常不能只按普通 CRUD 理解。StudentLifeDaily 模型以 id_student + stat_date 作为唯一约束,保存同一学生某一天的生活快照。字段覆盖 sleep_hours、sleep_start_time、wake_time、sleep_quality_score、daytime_sleepiness、exercise_minutes、breakfast_flag、water_intake_level、daily_screen_time、short_video_minutes、gaming_minutes、night_device_use_flag、mood_score、stress_level、anxiety_flag、daily_note,这些字段会被学生画像抽屉用于生活节律分和趋势图。
Codex 接收任务时,需要把"每日记录"这个时间粒度写进设计。它不能生成只按学生覆盖保存的画像表,也不能把 stat_date 当成普通备注字段。前端独立页面用于维护全量记录,学生管理抽屉通过 studentRef 带入当前学生,只查看或维护该学生的日常快照。
#mermaid-svg-BH9IGD7MMzhWwhBb{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-BH9IGD7MMzhWwhBb .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-BH9IGD7MMzhWwhBb .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-BH9IGD7MMzhWwhBb .error-icon{fill:#552222;}#mermaid-svg-BH9IGD7MMzhWwhBb .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-BH9IGD7MMzhWwhBb .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-BH9IGD7MMzhWwhBb .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-BH9IGD7MMzhWwhBb .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-BH9IGD7MMzhWwhBb .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-BH9IGD7MMzhWwhBb .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-BH9IGD7MMzhWwhBb .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-BH9IGD7MMzhWwhBb .marker{fill:#333333;stroke:#333333;}#mermaid-svg-BH9IGD7MMzhWwhBb .marker.cross{stroke:#333333;}#mermaid-svg-BH9IGD7MMzhWwhBb svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-BH9IGD7MMzhWwhBb p{margin:0;}#mermaid-svg-BH9IGD7MMzhWwhBb .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-BH9IGD7MMzhWwhBb .cluster-label text{fill:#333;}#mermaid-svg-BH9IGD7MMzhWwhBb .cluster-label span{color:#333;}#mermaid-svg-BH9IGD7MMzhWwhBb .cluster-label span p{background-color:transparent;}#mermaid-svg-BH9IGD7MMzhWwhBb .label text,#mermaid-svg-BH9IGD7MMzhWwhBb span{fill:#333;color:#333;}#mermaid-svg-BH9IGD7MMzhWwhBb .node rect,#mermaid-svg-BH9IGD7MMzhWwhBb .node circle,#mermaid-svg-BH9IGD7MMzhWwhBb .node ellipse,#mermaid-svg-BH9IGD7MMzhWwhBb .node polygon,#mermaid-svg-BH9IGD7MMzhWwhBb .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-BH9IGD7MMzhWwhBb .rough-node .label text,#mermaid-svg-BH9IGD7MMzhWwhBb .node .label text,#mermaid-svg-BH9IGD7MMzhWwhBb .image-shape .label,#mermaid-svg-BH9IGD7MMzhWwhBb .icon-shape .label{text-anchor:middle;}#mermaid-svg-BH9IGD7MMzhWwhBb .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-BH9IGD7MMzhWwhBb .rough-node .label,#mermaid-svg-BH9IGD7MMzhWwhBb .node .label,#mermaid-svg-BH9IGD7MMzhWwhBb .image-shape .label,#mermaid-svg-BH9IGD7MMzhWwhBb .icon-shape .label{text-align:center;}#mermaid-svg-BH9IGD7MMzhWwhBb .node.clickable{cursor:pointer;}#mermaid-svg-BH9IGD7MMzhWwhBb .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-BH9IGD7MMzhWwhBb .arrowheadPath{fill:#333333;}#mermaid-svg-BH9IGD7MMzhWwhBb .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-BH9IGD7MMzhWwhBb .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-BH9IGD7MMzhWwhBb .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-BH9IGD7MMzhWwhBb .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-BH9IGD7MMzhWwhBb .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-BH9IGD7MMzhWwhBb .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-BH9IGD7MMzhWwhBb .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-BH9IGD7MMzhWwhBb .cluster text{fill:#333;}#mermaid-svg-BH9IGD7MMzhWwhBb .cluster span{color:#333;}#mermaid-svg-BH9IGD7MMzhWwhBb div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-BH9IGD7MMzhWwhBb .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-BH9IGD7MMzhWwhBb rect.text{fill:none;stroke-width:0;}#mermaid-svg-BH9IGD7MMzhWwhBb .icon-shape,#mermaid-svg-BH9IGD7MMzhWwhBb .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-BH9IGD7MMzhWwhBb .icon-shape p,#mermaid-svg-BH9IGD7MMzhWwhBb .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-BH9IGD7MMzhWwhBb .icon-shape .label rect,#mermaid-svg-BH9IGD7MMzhWwhBb .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-BH9IGD7MMzhWwhBb .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-BH9IGD7MMzhWwhBb .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-BH9IGD7MMzhWwhBb :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-svg-BH9IGD7MMzhWwhBb .input>*{fill:#EEF4FF!important;stroke:#5B8FF9!important;color:#1D39C4!important;stroke-width:1.2px!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .input span{fill:#EEF4FF!important;stroke:#5B8FF9!important;color:#1D39C4!important;stroke-width:1.2px!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .input tspan{fill:#1D39C4!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .design>*{fill:#F6FFED!important;stroke:#52C41A!important;color:#237804!important;stroke-width:1.2px!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .design span{fill:#F6FFED!important;stroke:#52C41A!important;color:#237804!important;stroke-width:1.2px!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .design tspan{fill:#237804!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .process>*{fill:#FFF7E6!important;stroke:#FA8C16!important;color:#AD4E00!important;stroke-width:1.2px!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .process span{fill:#FFF7E6!important;stroke:#FA8C16!important;color:#AD4E00!important;stroke-width:1.2px!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .process tspan{fill:#AD4E00!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .check>*{fill:#F9F0FF!important;stroke:#722ED1!important;color:#531DAB!important;stroke-width:1.2px!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .check span{fill:#F9F0FF!important;stroke:#722ED1!important;color:#531DAB!important;stroke-width:1.2px!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .check tspan{fill:#531DAB!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .output>*{fill:#E6FFFB!important;stroke:#13C2C2!important;color:#006D75!important;stroke-width:1.2px!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .output span{fill:#E6FFFB!important;stroke:#13C2C2!important;color:#006D75!important;stroke-width:1.2px!important;}#mermaid-svg-BH9IGD7MMzhWwhBb .output tspan{fill:#006D75!important;} 教育管理需求
学生生活日常设计
页面结构
数据模型
接口规则
权限验收
Codex生成代码
| 需求层描述 | 设计层转换 | Codex 代码生成方向 |
|---|---|---|
| 学生身份 | 通过 id_student、name_student、username_student 关联学生 | 生成学生远程搜索和只读回显 |
| 业务记录 | stat_date、sleep_hours、sleep_start_time、wake_time、sleep_quality_score、daytime_sleepiness、exercise_minutes、breakfast_flag、water_intake_level、daily_screen_time、short_video_minutes、gaming_minutes、night_device_use_flag、mood_score、stress_level、anxiety_flag、daily_note | 生成对应字段表单、列表列和基础校验 |
| 日期筛选 | stat_date 支持范围查询 | 生成 range_fields 与前端查询参数 |
| 学生抽屉 | 学生管理页打开子模块时带入当前学生 | 生成 inStudentDrawer、studentRef 和自动刷新 |
| 唯一快照 | id_student + stat_date 唯一 |
生成重复日期保存校验和编辑回显 |
| 画像统计 | 日常数据参与学生画像抽屉趋势计算 | 生成可追溯的生活分输入 |
可以直接使用下面的Prompt进行模块功能的设计
text
请基于教育管理系统源码设计 学生生活日常 模块,不要编造代码中不存在的能力。
业务范围:记录学生每日睡眠、运动、早餐、饮水、屏幕时间、情绪、压力和备注,用于形成学生生活状态快照。
后端路径:server_backend/modules/User/views_app/StudentLifeDaily.py
前端路径:server_vue3/src/views/modules/User/StudentLifeDaily/index.vue、crud.tsx
接口入口:/api/User/StudentLifeDaily/
核心字段:stat_date、sleep_hours、sleep_start_time、wake_time、sleep_quality_score、daytime_sleepiness、exercise_minutes、breakfast_flag、water_intake_level、daily_screen_time、short_video_minutes、gaming_minutes、night_device_use_flag、mood_score、stress_level、anxiety_flag、daily_note
扩展能力:数据联动
请输出模块设计方案,包含页面结构、数据模型、接口规则、权限验收、异常边界和 Codex 分阶段生成项目代码的任务拆分。扩展能力只允许使用源码中已经存在的能力。
后端设计
后端设计重点不是堆接口,而是把学生生活日常沉淀成可复用的数据底座。StudentLifeDailyViewSet 位于 server_backend/modules/User/views_app/StudentLifeDaily.py,开放 get/post/put/delete,使用 CustomModelRefSerializer,并把 id_student、name_student、username_student 设置为只读字段。模型层通过唯一约束避免同一学生同一天出现多条互相冲突的日常记录。
筛选层使用 CustomModelInFilter.create_for_model,icontains_fields 覆盖学号、姓名、用户名、行政班和 daily_note,range_fields=['stat_date'] 支持按日期区间查询。这个范围筛选要同时服务独立页面列表和学生抽屉数据加载。
| 后端设计项 | 设计重点 | Codex 生成方向 |
|---|---|---|
| 模型字段 | 使用 CustomModelRefSerializer 按模型生成序列化规则 |
保留只读学生身份字段和业务字段类型 |
| 查询筛选 | 使用 SearchFilter 与 CustomModelInFilter |
支持姓名、学号、班级和日期范围查询 |
| 路由注册 | 在 modules/User/urls.py 通过 DefaultRouter 注册 |
保持 /api/User/模块名/ 接口风格 |
| 权限边界 | 依赖系统登录态和管理范围 | 避免跨学生、跨班级访问敏感数据 |
| 唯一约束 | id_student + stat_date 限制每日一条 |
生成重复数据错误处理 |
| 日期范围 | range_fields=['stat_date'] |
生成开始日期、结束日期查询参数 |
可以直接使用下面的Prompt进行后端代码的设计
text
请按 学生生活日常 的真实业务补齐或重构后端代码。
需要读取并遵守:
- server_backend/modules/User/views_app/StudentLifeDaily.py
- server_backend/modules/User/models.py
- server_backend/modules/User/urls.py
生成要求:
- 按 StudentLifeDaily 模型字段设计序列化规则,不要新增无来源字段。
- 使用 CustomModelViewSet、CustomModelRefSerializer 和 CustomModelInFilter 保持项目风格。
- 补齐列表查询、详情、新增、编辑、删除或只读接口边界。
- 保留 read_only_fields、search_fields、range_fields 和权限校验逻辑。
- 扩展能力只实现:数据联动。
- 输出需要包含模型字段说明、接口清单、路由注册、筛选规则、权限规则和异常处理。
前端设计
前端设计重点不是把字段堆到页面上,而是让管理人员能高效录入和查看某名学生每天的状态。StudentLifeDaily/crud.tsx 将表单分成学生信息、睡眠情绪、生活行为三组:学生信息包含 id_student、name_student、class_administrative、stat_date;睡眠情绪包含睡眠时长、入睡时间、起床时间、睡眠质量、白天困倦、情绪、压力、焦虑标记;生活行为包含运动、早餐、饮水、屏幕、短视频、游戏、夜间设备使用和备注。
学生管理抽屉复用同一套 crud 配置,并通过 inStudentDrawer 与 studentRef 把当前学生带入查询和新增表单。Codex 生成时要保留这种复用关系,避免复制出一套与独立页面不一致的抽屉表格。
| 前端设计项 | 设计重点 | Codex 生成方向 |
|---|---|---|
| 列表配置 | 使用 fs-crud 组织分页、搜索和列展示 |
生成 crud.tsx 的 columns、request、rowHandle |
| 表单结构 | 学生身份字段只读,业务字段按类型输入 | 生成新增、编辑、回显和校验规则 |
| 接口封装 | api.ts 统一封装 GetList/AddObj/UpdateObj/DelObj |
保持项目 request 调用规范 |
| 抽屉场景 | 学生详情页打开子模块时自动带入学生信息 | 支持 inStudentDrawer、studentRef 和列表刷新 |
| 表单分组 | 学生信息、睡眠情绪、生活行为分组 | 生成清晰的 tabs 或分组布局 |
| 日期控件 | stat_date 是快照日期 |
生成日期选择、范围查询和回显 |
可以直接使用下面的Prompt进行前端代码的设计
text
请按 学生生活日常 的真实业务生成或补齐前端代码。
需要读取并遵守:
- server_vue3/src/views/modules/User/StudentLifeDaily/index.vue、crud.tsx
- server_vue3/src/views/modules/User/StudentLifeDaily/api.ts
生成要求:
- 使用项目现有 fs-crud、Element Plus、request 封装和 api.ts 风格。
- 生成列表查询、筛选区域、新增编辑表单、详情或抽屉交互、权限按钮和保存回显。
- 处理字段转换:学生远程搜索回填 id_student/name_student/username_student,抽屉模式自动注入当前学生,日期字段按 range_fields 支持范围查询
- 扩展交互只实现:数据联动。
- 不要添加源码中未实现的扩展入口。
扩展功能
学生生活日常的扩展能力是学生上下文联动。它既能作为独立列表维护,也能在学生管理抽屉中按当前学生过滤和回显。
| 扩展功能 | 主要用途 | 落地重点 |
|---|---|---|
| 数据联动 | 独立列表与学生抽屉共用同一套接口 | 按 id_student 自动筛选并补齐学生身份字段 |
数据联动
学生生活日常的数据联动体现在 id_student、name_student、username_student、class_administrative、stat_date。独立页面中,学生远程搜索回填身份字段;抽屉模式中,studentRef 注入当前学生,新增记录时自动带入学号、姓名、用户名和行政班。查询时,id_student 与 stat_date 范围共同决定列表数据。
保存边界也要明确:stat_date 缺失时不能保存每日快照;同一学生同一天重复保存时应进入编辑路径或给出重复提示;生活日常不应反向修改学生主档。
在学生画像抽屉中,生活日常不是简单列表展示。StudentProfileLifeDrawer/index.vue 会读取日常记录,按睡眠质量、情绪、压力、运动、早餐、夜间设备使用和屏幕时长计算生活节律分,并把多天数据聚合到趋势图。Codex 生成该模块时,独立页面的字段类型要和抽屉统计函数保持一致,例如 sleep_quality_score、daytime_sleepiness、water_intake_level 使用数值等级,breakfast_flag、night_device_use_flag、anxiety_flag 使用布尔值。
独立页面和抽屉复用时还要注意查询参数。独立页面可以按学生、班级和日期范围检索;抽屉模式必须强制带入当前 id_student,不能让用户在抽屉里看到其他学生记录。新增时如果 studentRef 已存在,应自动填充学生身份字段,减少重复录入。
#mermaid-svg-053GOsLEHmyzP5hy{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-053GOsLEHmyzP5hy .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-053GOsLEHmyzP5hy .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-053GOsLEHmyzP5hy .error-icon{fill:#552222;}#mermaid-svg-053GOsLEHmyzP5hy .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-053GOsLEHmyzP5hy .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-053GOsLEHmyzP5hy .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-053GOsLEHmyzP5hy .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-053GOsLEHmyzP5hy .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-053GOsLEHmyzP5hy .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-053GOsLEHmyzP5hy .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-053GOsLEHmyzP5hy .marker{fill:#333333;stroke:#333333;}#mermaid-svg-053GOsLEHmyzP5hy .marker.cross{stroke:#333333;}#mermaid-svg-053GOsLEHmyzP5hy svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-053GOsLEHmyzP5hy p{margin:0;}#mermaid-svg-053GOsLEHmyzP5hy .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-053GOsLEHmyzP5hy .cluster-label text{fill:#333;}#mermaid-svg-053GOsLEHmyzP5hy .cluster-label span{color:#333;}#mermaid-svg-053GOsLEHmyzP5hy .cluster-label span p{background-color:transparent;}#mermaid-svg-053GOsLEHmyzP5hy .label text,#mermaid-svg-053GOsLEHmyzP5hy span{fill:#333;color:#333;}#mermaid-svg-053GOsLEHmyzP5hy .node rect,#mermaid-svg-053GOsLEHmyzP5hy .node circle,#mermaid-svg-053GOsLEHmyzP5hy .node ellipse,#mermaid-svg-053GOsLEHmyzP5hy .node polygon,#mermaid-svg-053GOsLEHmyzP5hy .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-053GOsLEHmyzP5hy .rough-node .label text,#mermaid-svg-053GOsLEHmyzP5hy .node .label text,#mermaid-svg-053GOsLEHmyzP5hy .image-shape .label,#mermaid-svg-053GOsLEHmyzP5hy .icon-shape .label{text-anchor:middle;}#mermaid-svg-053GOsLEHmyzP5hy .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-053GOsLEHmyzP5hy .rough-node .label,#mermaid-svg-053GOsLEHmyzP5hy .node .label,#mermaid-svg-053GOsLEHmyzP5hy .image-shape .label,#mermaid-svg-053GOsLEHmyzP5hy .icon-shape .label{text-align:center;}#mermaid-svg-053GOsLEHmyzP5hy .node.clickable{cursor:pointer;}#mermaid-svg-053GOsLEHmyzP5hy .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-053GOsLEHmyzP5hy .arrowheadPath{fill:#333333;}#mermaid-svg-053GOsLEHmyzP5hy .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-053GOsLEHmyzP5hy .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-053GOsLEHmyzP5hy .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-053GOsLEHmyzP5hy .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-053GOsLEHmyzP5hy .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-053GOsLEHmyzP5hy .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-053GOsLEHmyzP5hy .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-053GOsLEHmyzP5hy .cluster text{fill:#333;}#mermaid-svg-053GOsLEHmyzP5hy .cluster span{color:#333;}#mermaid-svg-053GOsLEHmyzP5hy div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-053GOsLEHmyzP5hy .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-053GOsLEHmyzP5hy rect.text{fill:none;stroke-width:0;}#mermaid-svg-053GOsLEHmyzP5hy .icon-shape,#mermaid-svg-053GOsLEHmyzP5hy .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-053GOsLEHmyzP5hy .icon-shape p,#mermaid-svg-053GOsLEHmyzP5hy .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-053GOsLEHmyzP5hy .icon-shape .label rect,#mermaid-svg-053GOsLEHmyzP5hy .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-053GOsLEHmyzP5hy .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-053GOsLEHmyzP5hy .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-053GOsLEHmyzP5hy :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-svg-053GOsLEHmyzP5hy .input>*{fill:#EEF4FF!important;stroke:#5B8FF9!important;color:#1D39C4!important;stroke-width:1.2px!important;}#mermaid-svg-053GOsLEHmyzP5hy .input span{fill:#EEF4FF!important;stroke:#5B8FF9!important;color:#1D39C4!important;stroke-width:1.2px!important;}#mermaid-svg-053GOsLEHmyzP5hy .input tspan{fill:#1D39C4!important;}#mermaid-svg-053GOsLEHmyzP5hy .process>*{fill:#FFF7E6!important;stroke:#FA8C16!important;color:#AD4E00!important;stroke-width:1.2px!important;}#mermaid-svg-053GOsLEHmyzP5hy .process span{fill:#FFF7E6!important;stroke:#FA8C16!important;color:#AD4E00!important;stroke-width:1.2px!important;}#mermaid-svg-053GOsLEHmyzP5hy .process tspan{fill:#AD4E00!important;}#mermaid-svg-053GOsLEHmyzP5hy .output>*{fill:#E6FFFB!important;stroke:#13C2C2!important;color:#006D75!important;stroke-width:1.2px!important;}#mermaid-svg-053GOsLEHmyzP5hy .output span{fill:#E6FFFB!important;stroke:#13C2C2!important;color:#006D75!important;stroke-width:1.2px!important;}#mermaid-svg-053GOsLEHmyzP5hy .output tspan{fill:#006D75!important;} 结果阶段
处理阶段
输入阶段
筛选条件
表单选择
抽屉打开
生成参数
请求接口
字段转换
刷新列表
表单回显
状态更新
交给 Codex 生成时,要明确联动边界:只处理源码中存在的字段和接口,不把其他学生画像、考试分析或 AI 评估能力塞进本模块。保存动作必须保证 抽屉内只显示当前学生记录,保存时自动补齐学生身份字段。
可以直接使用下面的Prompt进行数据联动设计
text
请为 学生生活日常 设计数据联动实现。
联动字段:id_student、name_student、username_student、class_administrative、stat_date
接口参数:id_student、stat_date 范围、学生搜索关键词
结果回填:抽屉内只显示当前学生记录,保存时自动补齐学生身份字段
源码边界:只使用当前模块已经存在的模型字段、api.ts 请求和页面组件,不新增未实现的业务能力。
请输出联动流程、字段映射表、异常处理、保存回显规则和需要修改的文件路径。
Codex开发标准
使用 Codex 开发学生生活日常时,不能直接让模型自由写代码。PDD 定义业务边界和验收口径,SOP 约束目录、文件职责和开发顺序,接口权限规则保证生成代码能进入现有系统。
#mermaid-svg-AimW89SQSGd4HOM6{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-AimW89SQSGd4HOM6 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-AimW89SQSGd4HOM6 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-AimW89SQSGd4HOM6 .error-icon{fill:#552222;}#mermaid-svg-AimW89SQSGd4HOM6 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-AimW89SQSGd4HOM6 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-AimW89SQSGd4HOM6 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-AimW89SQSGd4HOM6 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-AimW89SQSGd4HOM6 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-AimW89SQSGd4HOM6 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-AimW89SQSGd4HOM6 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-AimW89SQSGd4HOM6 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-AimW89SQSGd4HOM6 .marker.cross{stroke:#333333;}#mermaid-svg-AimW89SQSGd4HOM6 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-AimW89SQSGd4HOM6 p{margin:0;}#mermaid-svg-AimW89SQSGd4HOM6 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-AimW89SQSGd4HOM6 .cluster-label text{fill:#333;}#mermaid-svg-AimW89SQSGd4HOM6 .cluster-label span{color:#333;}#mermaid-svg-AimW89SQSGd4HOM6 .cluster-label span p{background-color:transparent;}#mermaid-svg-AimW89SQSGd4HOM6 .label text,#mermaid-svg-AimW89SQSGd4HOM6 span{fill:#333;color:#333;}#mermaid-svg-AimW89SQSGd4HOM6 .node rect,#mermaid-svg-AimW89SQSGd4HOM6 .node circle,#mermaid-svg-AimW89SQSGd4HOM6 .node ellipse,#mermaid-svg-AimW89SQSGd4HOM6 .node polygon,#mermaid-svg-AimW89SQSGd4HOM6 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-AimW89SQSGd4HOM6 .rough-node .label text,#mermaid-svg-AimW89SQSGd4HOM6 .node .label text,#mermaid-svg-AimW89SQSGd4HOM6 .image-shape .label,#mermaid-svg-AimW89SQSGd4HOM6 .icon-shape .label{text-anchor:middle;}#mermaid-svg-AimW89SQSGd4HOM6 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-AimW89SQSGd4HOM6 .rough-node .label,#mermaid-svg-AimW89SQSGd4HOM6 .node .label,#mermaid-svg-AimW89SQSGd4HOM6 .image-shape .label,#mermaid-svg-AimW89SQSGd4HOM6 .icon-shape .label{text-align:center;}#mermaid-svg-AimW89SQSGd4HOM6 .node.clickable{cursor:pointer;}#mermaid-svg-AimW89SQSGd4HOM6 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-AimW89SQSGd4HOM6 .arrowheadPath{fill:#333333;}#mermaid-svg-AimW89SQSGd4HOM6 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-AimW89SQSGd4HOM6 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-AimW89SQSGd4HOM6 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-AimW89SQSGd4HOM6 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-AimW89SQSGd4HOM6 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-AimW89SQSGd4HOM6 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-AimW89SQSGd4HOM6 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-AimW89SQSGd4HOM6 .cluster text{fill:#333;}#mermaid-svg-AimW89SQSGd4HOM6 .cluster span{color:#333;}#mermaid-svg-AimW89SQSGd4HOM6 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-AimW89SQSGd4HOM6 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-AimW89SQSGd4HOM6 rect.text{fill:none;stroke-width:0;}#mermaid-svg-AimW89SQSGd4HOM6 .icon-shape,#mermaid-svg-AimW89SQSGd4HOM6 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-AimW89SQSGd4HOM6 .icon-shape p,#mermaid-svg-AimW89SQSGd4HOM6 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-AimW89SQSGd4HOM6 .icon-shape .label rect,#mermaid-svg-AimW89SQSGd4HOM6 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-AimW89SQSGd4HOM6 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-AimW89SQSGd4HOM6 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-AimW89SQSGd4HOM6 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-svg-AimW89SQSGd4HOM6 .input>*{fill:#EEF4FF!important;stroke:#5B8FF9!important;color:#1D39C4!important;stroke-width:1.2px!important;}#mermaid-svg-AimW89SQSGd4HOM6 .input span{fill:#EEF4FF!important;stroke:#5B8FF9!important;color:#1D39C4!important;stroke-width:1.2px!important;}#mermaid-svg-AimW89SQSGd4HOM6 .input tspan{fill:#1D39C4!important;}#mermaid-svg-AimW89SQSGd4HOM6 .design>*{fill:#F6FFED!important;stroke:#52C41A!important;color:#237804!important;stroke-width:1.2px!important;}#mermaid-svg-AimW89SQSGd4HOM6 .design span{fill:#F6FFED!important;stroke:#52C41A!important;color:#237804!important;stroke-width:1.2px!important;}#mermaid-svg-AimW89SQSGd4HOM6 .design tspan{fill:#237804!important;}#mermaid-svg-AimW89SQSGd4HOM6 .dev>*{fill:#FFF7E6!important;stroke:#FA8C16!important;color:#AD4E00!important;stroke-width:1.2px!important;}#mermaid-svg-AimW89SQSGd4HOM6 .dev span{fill:#FFF7E6!important;stroke:#FA8C16!important;color:#AD4E00!important;stroke-width:1.2px!important;}#mermaid-svg-AimW89SQSGd4HOM6 .dev tspan{fill:#AD4E00!important;}#mermaid-svg-AimW89SQSGd4HOM6 .check>*{fill:#F9F0FF!important;stroke:#722ED1!important;color:#531DAB!important;stroke-width:1.2px!important;}#mermaid-svg-AimW89SQSGd4HOM6 .check span{fill:#F9F0FF!important;stroke:#722ED1!important;color:#531DAB!important;stroke-width:1.2px!important;}#mermaid-svg-AimW89SQSGd4HOM6 .check tspan{fill:#531DAB!important;} 验收交付
Codex开发
模块设计
输入约束
需求边界
PDD设计
SOP目录
接口权限
后端设计
前端设计
扩展功能
读取上下文
生成后端
生成前端
补齐扩展
功能自检
PDD验收
问题修复
模块交付
SOP 标准
SOP 用来约束代码目录、文件职责和开发顺序。学生生活日常的目录结构需要贴合现有 User 模块,不应为单篇文章另起一套风格。
text
server_backend/modules/User/
models.py
views_app/StudentLifeDaily.py
urls.py
server_vue3/src/views/modules/User/StudentLifeDaily/
index.vue
crud.tsx
api.ts
server_vue3/src/views/modules/User/StudentManage/Drawers/
StudentLifeDailyDrawer/index.vue
StudentLifeDailyDrawer/crud.tsx
docs/modules/学生生活日常/
pdd.md
api.md
test-cases.md
codex-sop.md
| 开发阶段 | Codex 执行目标 | 输出结果 |
|---|---|---|
| 模块设计 | 读取模型、视图、路由和前端页面 | pdd.md 明确业务边界 |
| 目录规划 | 对齐后端 views_app、前端模块目录和接口封装 | codex-sop.md 明确文件职责 |
| 后端实现 | 生成模型序列化、视图接口、筛选和权限校验 | 后端接口可被前端稳定调用 |
| 前端实现 | 生成列表、表单、抽屉、按钮和接口调用 | 页面操作闭环可运行 |
| 功能补齐 | 按真实扩展能力补齐联动、批量、文件或生成逻辑 | 扩展能力与源码一致 |
| 验收修复 | 根据 PDD 和测试用例修复偏差 | test-cases.md 与代码一致 |
可以直接使用下面的Prompt进行SOP撰写
text
请为 学生生活日常 编写 Codex 开发 SOP。
要求:
- 先输出目录结构,不要直接写代码。
- 先生成 docs/modules/学生生活日常/pdd.md、api.md、test-cases.md 和 codex-sop.md。
- 目录必须贴合现有路径:server_backend/modules/User/views_app/StudentLifeDaily.py、server_vue3/src/views/modules/User/StudentLifeDaily/index.vue、crud.tsx。
- SOP 需要约束模型字段、接口视图、路由注册、前端 crud 配置、接口封装、权限按钮、保存回显和扩展能力。
- 扩展能力只包含:数据联动。
- 文档完成后,再按 SOP 分阶段生成项目代码。
PDD 标准
PDD 是学生生活日常的设计与验收文档,用于判断 Codex 输出是否符合真实业务。验收不能只看页面能否打开,还要检查字段、接口、权限、筛选、联动和扩展能力是否匹配源码。
| 验收维度 | 验收重点 | 通过标准 |
|---|---|---|
| 业务目标 | 记录学生每日睡眠、运动、早餐、饮水、屏幕时间、情绪、压力和备注,用于形成学生生活状态快照。 | 页面和接口能支撑模块业务闭环 |
| 页面结构 | server_vue3/src/views/modules/User/StudentLifeDaily/index.vue、crud.tsx | 列表、表单、抽屉或操作按钮与源码一致 |
| 数据模型 | stat_date、sleep_hours、sleep_start_time、wake_time、sleep_quality_score、daytime_sleepiness、exercise_minutes、breakfast_flag、water_intake_level、daily_screen_time、short_video_minutes、gaming_minutes、night_device_use_flag、mood_score、stress_level、anxiety_flag、daily_note | 字段类型、只读字段、唯一约束不偏离模型 |
| 接口规则 | /api/User/StudentLifeDaily/ | 列表、保存、删除、动作接口请求参数正确 |
| 权限控制 | 登录用户、班级范围或系统权限 | 非授权数据不可越权访问 |
| 测试用例 | 正常、异常、空数据、回显和删除 | test-cases.md 覆盖主要路径 |
| 数据联动 | 独立列表和学生抽屉按学生身份联动 | 抽屉打开、保存、刷新均限定当前学生 |
可以直接使用下面的Prompt进行PDD 验收
text
请根据 docs/modules/学生生活日常/pdd.md 对 学生生活日常 进行验收。
验收范围:业务目标、页面结构、数据模型、接口规则、权限控制、测试用例、数据联动。
请输出验收结果表,字段包含:验收项、通过状态、发现问题、涉及文件、修复建议。不要只给结论;必须指出未通过项的具体文件位置和建议改法。
总结
学生生活日常不是简单日志,它把睡眠、运动、饮食、设备使用和情绪压力沉淀为可追踪的每日快照,为画像分析和班主任干预提供数据基础。
Codex 开发这类学生子模块时,应由 PDD 明确字段、日期范围和学生身份边界,由 SOP 固定独立页面与抽屉复用方式,再用 Prompt 约束查询、回显和保存逻辑。