3.9 KiB
3.9 KiB
学生信息家庭信息显示问题排查总结
问题概述
- 报告时间: 2025-01-03
- 问题描述: 查询学生详细信息时,家庭信息没有正确显示
- 排查状态: 已完成修复和验证
问题分析结果
1. 根本原因确认
经过详细分析,确认问题的根本原因是:
- Mapper查询字段缺失:
XgStudentInfoMapper.xml中的selectVoPage查询语句缺少家庭信息字段 - 前端字段名称不一致: 详情页面使用的字段名称与后端实体类不匹配
2. 具体缺失字段
父母信息字段:
father_name(父亲姓名)father_phone(父亲电话)father_work_unit(父亲工作单位)mother_name(母亲姓名)mother_phone(母亲电话)mother_work_unit(母亲工作单位)
特殊情况字段:
is_minority(少数民族)is_disabled(残疾学生)is_orphan(孤儿)is_left_behind_child(留守儿童)is_single_child(独生子女)
3. 前端字段名称错误
isFromPoorFamily→isPoorStudentisLeftBehind→isLeftBehindChildisOnlyChild→isSingleChild
修复措施
1. 后端修复
文件: backend/ruoyi-modules/ruoyi-xg-xx/src/main/resources/mapper/xg/XgStudentInfoMapper.xml
在 selectVoPage 查询语句中添加了缺失的字段:
-- 父母信息字段
father_name, father_phone, father_work_unit,
mother_name, mother_phone, mother_work_unit,
-- 特殊情况字段
is_poor_student, is_minority, is_disabled, is_orphan, is_left_behind_child, is_single_child,
2. 前端修复
文件: web/src/views/xg-xx/studentInfo/components/StudentDetailDialog.vue
修正了字段名称:
isFromPoorFamily→isPoorStudentisLeftBehind→isLeftBehindChildisOnlyChild→isSingleChild
验证方法
1. 数据库层面验证
可以执行以下SQL脚本验证数据是否存在:
-- 检查父母信息数据
SELECT
student_no, name,
father_name, father_phone, father_work_unit,
mother_name, mother_phone, mother_work_unit
FROM xg_student_info
WHERE deleted = 0
AND (father_name IS NOT NULL OR mother_name IS NOT NULL)
LIMIT 5;
-- 检查特殊情况数据
SELECT
student_no, name,
is_poor_student, is_minority, is_disabled,
is_orphan, is_left_behind_child, is_single_child
FROM xg_student_info
WHERE deleted = 0
AND (is_poor_student = 1 OR is_minority = 1 OR is_disabled = 1
OR is_orphan = 1 OR is_left_behind_child = 1 OR is_single_child = 1)
LIMIT 5;
2. 应用层面验证
- 重启后端服务以确保Mapper修改生效
- 在前端页面查看学生详情,确认家庭信息正确显示
- 检查特殊情况标识是否正确显示
排查步骤回顾
1. 问题定位
- 确认数据库中存在家庭信息数据
- 检查后端实体类字段定义正确
- 发现Mapper查询语句缺少字段
2. 代码分析
- 检查ResultMap映射配置
- 分析selectVoPage查询语句
- 对比前端字段名称
3. 修复验证
- 添加缺失的查询字段
- 修正前端字段名称
- 创建验证脚本
预防措施
1. 开发规范
- 新增字段时必须同时更新相关查询语句
- 前后端字段命名保持一致
- 定期检查字段映射关系
2. 测试完善
- 增加字段完整性测试
- 在功能测试中验证数据显示完整性
- 建立自动化测试脚本
3. 文档维护
- 及时更新API文档
- 记录字段变更历史
- 保持代码和文档同步
总结
本次问题的核心是数据能正常录入但查询时字段缺失,这是一个典型的Mapper查询字段不完整问题。通过系统性的分析和修复,确保了:
- ✅ 学生信息详情页面能正确显示父母信息
- ✅ 学生信息详情页面能正确显示特殊情况信息
- ✅ 前后端字段名称保持一致
- ✅ 数据录入和查询功能正常
修复后,用户可以正常查看学生的完整家庭信息,提升了系统的功能完整性和用户体验。