新增教师介绍数据库与同步 API#2
Open
ElysiaFollower wants to merge 11 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
本 PR 为教师介绍功能提供后端数据层、公开 API、后台管理 API 和同步审核能力,支撑前端新增的「教师介绍」公开页与「教师介绍管理」后台页。原实现阶段主要依赖人工整理资料和临时前端数据,无法满足后续维护中的持久化、权限控制、字段审校和同步失败回退需求。
配套前端 PR:ZJUCSA/csa-frontend#5
主要变更
数据模型与迁移
teachers表,用于保存教师公开资料、排序、启用状态、头像 URL、研究方向、外部主页、来源状态、字段来源和同步草稿。teacher_meta表,用于保存教师资料整体同步时间、来源状态、来源 URL 和同步说明。教师数据契约与持久化服务
services/teachers_cache.py,集中定义公开响应、后台维护记录、来源配置、同步草稿和元信息的 Pydantic 契约。load_teacher_store、write_teacher_store、public_response_from_store等统一入口。公开与后台 API
GET /teachers/list:返回启用教师列表和公开元信息。GET /teachers/detail?id=...:返回单个教师详情,未命中时返回 404。login_required_publisher权限:GET /teachers/admin/list:读取后台完整维护数据。POST /teachers/admin/save:新增或更新教师资料、排序、来源配置和外部链接。DELETE /teachers/admin/{teacher_id}:删除教师记录。POST /teachers/admin/sync:按单个教师或全量教师生成同步草稿。POST /teachers/admin/publish:按字段发布待审核同步建议。POST /teachers/admin/discard:忽略待审核同步建议。POST /teachers/sync:保留兼容的同步入口。标准主页同步与审核草稿
services/teachers_sync.py,支持从标准浙大个人主页https://person.zju.edu.cn/<slug>抽取姓名、职称、单位、邮箱、研究方向、简介摘要和详细简介。draft.changes,由后台逐字段审核后发布。验证脚本
scripts/verify_teachers_db.py:验证数据库记录、公开投影、详情接口、后台保存校验、内存数据库 round trip 和 404/422 行为。scripts/verify_teachers_sync.py:使用本地 HTML fixture 和 fake session 验证标准主页解析、同步草稿、逐字段发布、人工保存后的草稿刷新和失败回退。影响范围
/teachers/*API,不改变现有新闻、活动、用户、招新等接口语义。验证
已在本地
csa_backendconda 环境执行:结果:
teachers database verification passedteachers sync verification passed另已执行:
结果:无 whitespace/error 输出。
后续注意
person.zju.edu.cn/<slug>形式,非标准主页会作为外部链接展示并进入人工维护路径。