Files
Edu/packages/shared-proto/proto/content.proto
SpecialX 78e406b317 feat(content): v2 扩展 Elective/LessonPlan/CoursePlan 三业务域
新增 3 个业务域(10 RPC):
- ElectiveService: 选修课列表/学生选课记录/选课/退课(含容量与重复校验)
- LessonPlanService: 教师备课列表/学生备课列表(仅 published)/详情
- CoursePlanService: 学生课程计划列表/详情
- KnowledgeGraphService.GetKnowledgePath: 与 GetLearningPath 同实现

新增 4 张 MySQL 表(elective_courses/selections/lesson_plans/course_plans),含完整索引。

新增 11 个权限点,覆盖 admin/teacher/student/parent 四角色。

proto 由 4 Service/22 RPC 扩展至 7 Service/32 RPC,v1 全部 RPC 保持向后兼容。

修复 logger.ts pino 导入: default import 在 NodeNext ESM 下不可调用,
改用 named import(与 iam/msg/core-edu 对齐)。

Docker 本地测试全部通过(HTTP + gRPC 双协议),健康检查、
Elective/LessonPlan/CoursePlan CRUD、4 个新 gRPC Service 全部验证通过。

nextstep-v2.md 已创建,记录上下游依赖与 6 项联调待办。
2026-07-14 17:54:37 +08:00

415 lines
9.3 KiB
Protocol Buffer

syntax = "proto3";
package next_edu_cloud.content.v1;
import "google/protobuf/struct.proto";
service TextbookService {
rpc CreateTextbook(CreateTextbookRequest) returns (Textbook);
rpc GetTextbook(GetTextbookRequest) returns (Textbook);
rpc ListTextbooks(ListTextbooksRequest) returns (ListTextbooksResponse);
rpc UpdateTextbook(UpdateTextbookRequest) returns (Textbook);
rpc DeleteTextbook(DeleteTextbookRequest) returns (Empty);
}
service ChapterService {
rpc CreateChapter(CreateChapterRequest) returns (Chapter);
rpc GetChapter(GetChapterRequest) returns (Chapter);
rpc ListChapters(ListChaptersRequest) returns (ListChaptersResponse);
rpc UpdateChapter(UpdateChapterRequest) returns (Chapter);
rpc DeleteChapter(DeleteChapterRequest) returns (Empty);
}
service KnowledgeGraphService {
rpc GetPrerequisites(GetPrerequisitesRequest) returns (KnowledgePointsResponse);
rpc GetLearningPath(GetLearningPathRequest) returns (LearningPath);
rpc GetKnowledgePath(GetKnowledgePathRequest) returns (LearningPath);
rpc AddPrerequisite(AddPrerequisiteRequest) returns (Empty);
rpc RemovePrerequisite(RemovePrerequisiteRequest) returns (Empty);
}
service QuestionService {
rpc CreateQuestion(CreateQuestionRequest) returns (Question);
rpc BatchCreateQuestions(BatchCreateQuestionsRequest) returns (BatchCreateQuestionsResponse);
rpc GetQuestion(GetQuestionRequest) returns (Question);
rpc ListQuestions(ListQuestionsRequest) returns (ListQuestionsResponse);
rpc UpdateQuestion(UpdateQuestionRequest) returns (Question);
rpc DeleteQuestion(DeleteQuestionRequest) returns (Empty);
rpc PublishQuestion(PublishQuestionRequest) returns (Empty);
rpc SearchQuestions(SearchQuestionsRequest) returns (SearchQuestionsResponse);
}
service ElectiveService {
rpc ListAvailableElectiveCourses(ListAvailableElectiveCoursesRequest) returns (ListElectiveCoursesResponse);
rpc ListElectiveSelectionsByStudent(ListElectiveSelectionsByStudentRequest) returns (ListElectiveSelectionsResponse);
rpc SelectCourse(SelectCourseRequest) returns (ElectiveSelection);
rpc DropCourse(DropCourseRequest) returns (Empty);
}
service LessonPlanService {
rpc ListLessonPlansByTeacher(ListLessonPlansByTeacherRequest) returns (ListLessonPlansResponse);
rpc ListLessonPlansByStudent(ListLessonPlansByStudentRequest) returns (ListLessonPlansResponse);
rpc GetLessonPlan(GetLessonPlanRequest) returns (LessonPlan);
}
service CoursePlanService {
rpc ListCoursePlansByStudent(ListCoursePlansByStudentRequest) returns (ListCoursePlansResponse);
rpc GetCoursePlan(GetCoursePlanRequest) returns (CoursePlan);
}
message Empty {}
message Textbook {
string id = 1;
string title = 2;
string subject_id = 3;
string grade_id = 4;
string version = 5;
string status = 6;
string tenant_id = 7;
google.protobuf.Struct metadata = 8;
int64 created_at = 9;
int64 updated_at = 10;
}
message Chapter {
string id = 1;
string textbook_id = 2;
string title = 3;
int32 order = 4;
string parent_id = 5;
string status = 6;
int64 created_at = 7;
int64 updated_at = 8;
}
message KnowledgePoint {
string id = 1;
string chapter_id = 2;
string title = 3;
string description = 4;
int32 difficulty = 5;
google.protobuf.Struct metadata = 6;
int64 created_at = 7;
int64 updated_at = 8;
}
message Question {
string id = 1;
string knowledge_point_id = 2;
string type = 3;
string content = 4;
google.protobuf.Struct options = 5;
string answer = 6;
string explanation = 7;
int32 difficulty = 8;
string status = 9;
string source = 10;
string created_by = 11;
google.protobuf.Struct metadata = 12;
int64 created_at = 13;
int64 updated_at = 14;
}
// TextbookService request/response messages
message CreateTextbookRequest {
string title = 1;
string subject_id = 2;
string grade_id = 3;
string version = 4;
google.protobuf.Struct metadata = 5;
}
message GetTextbookRequest {
string id = 1;
}
message ListTextbooksRequest {
string subject_id = 1;
string grade_id = 2;
string page_token = 3;
int32 page_size = 4;
}
message ListTextbooksResponse {
repeated Textbook textbooks = 1;
string next_page_token = 2;
}
message UpdateTextbookRequest {
string id = 1;
optional string title = 2;
optional string status = 3;
google.protobuf.Struct metadata = 4;
}
message DeleteTextbookRequest {
string id = 1;
}
// ChapterService request/response messages
message CreateChapterRequest {
string textbook_id = 1;
string title = 2;
int32 order = 3;
string parent_id = 4;
}
message GetChapterRequest {
string id = 1;
}
message ListChaptersRequest {
string textbook_id = 1;
string parent_id = 2;
}
message ListChaptersResponse {
repeated Chapter chapters = 1;
}
message UpdateChapterRequest {
string id = 1;
optional string title = 2;
optional int32 order = 3;
optional string status = 4;
}
message DeleteChapterRequest {
string id = 1;
}
// KnowledgeGraphService request/response messages
message GetPrerequisitesRequest {
string knowledge_point_id = 1;
int32 depth = 2;
}
message KnowledgePointsResponse {
repeated KnowledgePoint points = 1;
}
message GetLearningPathRequest {
string student_id = 1;
string subject_id = 2;
}
message LearningPath {
repeated KnowledgePoint points = 1;
repeated string recommended_order = 2;
}
message AddPrerequisiteRequest {
string kp_id = 1;
string prerequisite_id = 2;
}
message RemovePrerequisiteRequest {
string kp_id = 1;
string prerequisite_id = 2;
}
// QuestionService request/response messages
message CreateQuestionRequest {
string knowledge_point_id = 1;
string type = 2;
string content = 3;
google.protobuf.Struct options = 4;
string answer = 5;
string explanation = 6;
int32 difficulty = 7;
string source = 8;
string created_by = 9;
google.protobuf.Struct metadata = 10;
}
message BatchCreateQuestionsRequest {
repeated CreateQuestionRequest questions = 1;
}
message BatchCreateQuestionsResponse {
repeated string ids = 1;
repeated BatchCreateFailure failed = 2;
}
message BatchCreateFailure {
int32 index = 1;
string error = 2;
}
message GetQuestionRequest {
string id = 1;
}
message ListQuestionsRequest {
string knowledge_point_id = 1;
string type = 2;
int32 difficulty = 3;
string status = 4;
string page_token = 5;
int32 page_size = 6;
}
message ListQuestionsResponse {
repeated Question questions = 1;
string next_page_token = 2;
}
message UpdateQuestionRequest {
string id = 1;
optional string content = 2;
optional string answer = 3;
optional string status = 4;
google.protobuf.Struct options = 5;
optional string explanation = 6;
optional int32 difficulty = 7;
}
message DeleteQuestionRequest {
string id = 1;
}
message PublishQuestionRequest {
string id = 1;
}
message SearchQuestionsRequest {
string q = 1;
string type = 2;
int32 difficulty = 3;
string knowledge_point_id = 4;
string page_token = 5;
int32 page_size = 6;
}
message SearchQuestionsResponse {
repeated Question questions = 1;
int32 total = 2;
string next_page_token = 3;
}
// KnowledgeGraphService: GetKnowledgePath (按班级查询学习路径)
message GetKnowledgePathRequest {
string class_id = 1;
string subject_id = 2;
}
// ElectiveService messages
message ElectiveCourse {
string id = 1;
string title = 2;
string subject_id = 3;
string teacher_id = 4;
int32 capacity = 5;
int32 enrolled_count = 6;
string status = 7;
string description = 8;
int64 created_at = 9;
int64 updated_at = 10;
}
message ElectiveSelection {
string id = 1;
string student_id = 2;
string course_id = 3;
string status = 4;
int64 selected_at = 5;
int64 dropped_at = 6;
}
message ListAvailableElectiveCoursesRequest {
string subject_id = 1;
int32 page_size = 2;
string page_token = 3;
}
message ListElectiveCoursesResponse {
repeated ElectiveCourse courses = 1;
string next_page_token = 2;
}
message ListElectiveSelectionsByStudentRequest {
string student_id = 1;
string status = 2;
}
message ListElectiveSelectionsResponse {
repeated ElectiveSelection selections = 1;
}
message SelectCourseRequest {
string student_id = 1;
string course_id = 2;
}
message DropCourseRequest {
string student_id = 1;
string course_id = 2;
}
// LessonPlanService messages
message LessonPlan {
string id = 1;
string teacher_id = 2;
string class_id = 3;
string subject_id = 4;
string title = 5;
string content = 6;
string status = 7;
google.protobuf.Struct metadata = 8;
int64 created_at = 9;
int64 updated_at = 10;
}
message ListLessonPlansByTeacherRequest {
string teacher_id = 1;
string class_id = 2;
string subject_id = 3;
}
message ListLessonPlansByStudentRequest {
string student_id = 1;
string class_id = 2;
}
message ListLessonPlansResponse {
repeated LessonPlan lesson_plans = 1;
}
message GetLessonPlanRequest {
string id = 1;
}
// CoursePlanService messages
message CoursePlan {
string id = 1;
string student_id = 2;
string class_id = 3;
string subject_id = 4;
string title = 5;
string plan_type = 6;
string content = 7;
string status = 8;
google.protobuf.Struct metadata = 9;
int64 created_at = 10;
int64 updated_at = 11;
}
message ListCoursePlansByStudentRequest {
string student_id = 1;
string class_id = 2;
string plan_type = 3;
}
message ListCoursePlansResponse {
repeated CoursePlan course_plans = 1;
}
message GetCoursePlanRequest {
string id = 1;
}