chore(content): merge content full implementation into main

Merge feat/content-ai09 with complete content service
This commit is contained in:
SpecialX
2026-07-10 19:13:02 +08:00
74 changed files with 5256 additions and 355 deletions

View File

@@ -2,46 +2,273 @@ 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 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);
}
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; }
message ListTextbooksResponse { repeated Textbook textbooks = 1; }
message KnowledgePoint {
message GetTextbookRequest {
string id = 1;
string title = 2;
}
message GetPrerequisitesRequest { string knowledge_point_id = 1; }
message KnowledgePointsResponse { repeated KnowledgePoint points = 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 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;
}

View File

@@ -10,30 +10,14 @@ package next_edu_cloud.events.v1;
// edu.teaching.<aggregate>.<action>
//
// Event routing (TOPIC_MAP in outbox.publisher.ts):
// edu.teaching.exam.created <- ExamEvent.created
// edu.teaching.exam.updated <- ExamEvent.updated
// edu.teaching.exam.published <- ExamEvent.published
// edu.teaching.exam.submitted <- ExamEvent.submitted
// edu.teaching.exam.deleted <- ExamEvent.deleted
// edu.teaching.homework.assigned <- HomeworkEvent.assigned
// edu.teaching.homework.submitted <- HomeworkEvent.submitted
// edu.teaching.homework.graded <- HomeworkEvent.graded
// edu.teaching.grade.recorded <- GradeEvent.recorded
// edu.teaching.grade.updated <- GradeEvent.updated
// edu.teaching.attendance.recorded <- AttendanceEvent.recorded
// edu.teaching.class.transferred <- ClassEvent.transferred
//
// All events MUST include:
// - schema_version: event schema version (default "v1")
// - event_id: UUID for idempotent consumption
// - occurred_at: business timestamp (ms epoch)
// - metadata: { traceId, userId }
message EventMetadata {
string schema_version = 1;
string trace_id = 2;
string user_id = 3;
}
// edu.exam.events <- exam.created / exam.updated / exam.deleted
// edu.homework.events <- homework.assigned / homework.submitted / homework.graded
// edu.grade.events <- grade.recorded / grade.updated
// edu.class.events <- class.transferred
// edu.content.textbook.events <- textbook.created / textbook.updated / textbook.published / textbook.archived
// edu.content.chapter.events <- chapter.created / chapter.updated / chapter.deleted
// edu.content.knowledge_point.events <- knowledge_point.created / knowledge_point.updated / knowledge_point.prerequisite_added / knowledge_point.prerequisite_removed
// edu.content.question.events <- question.created / question.updated / question.published / question.deleted
message ClassEvent {
string event_id = 1;
@@ -144,3 +128,60 @@ message AuditEvent {
string trace_id = 13;
map<string, string> metadata = 14;
}
message TextbookEvent {
string event_id = 1;
string aggregate_id = 2;
string event_type = 3;
int64 occurred_at = 4;
string textbook_id = 5;
string title = 6;
string subject_id = 7;
string grade_id = 8;
string version = 9;
string action = 10;
map<string, string> metadata = 11;
}
message ChapterEvent {
string event_id = 1;
string aggregate_id = 2;
string event_type = 3;
int64 occurred_at = 4;
string chapter_id = 5;
string textbook_id = 6;
string title = 7;
int32 order = 8;
string action = 9;
map<string, string> metadata = 10;
}
message KnowledgePointEvent {
string event_id = 1;
string aggregate_id = 2;
string event_type = 3;
int64 occurred_at = 4;
string kp_id = 5;
string chapter_id = 6;
string title = 7;
int32 difficulty = 8;
string action = 9;
string prerequisite_id = 10;
map<string, string> metadata = 11;
}
message QuestionEvent {
string event_id = 1;
string aggregate_id = 2;
string event_type = 3;
int64 occurred_at = 4;
string question_id = 5;
string kp_id = 6;
string type = 7;
int32 difficulty = 8;
string status = 9;
string source = 10;
string created_by = 11;
string action = 12;
map<string, string> metadata = 13;
}