From 843b370b3d8010d0eb66c68ff5f32272fcb6ae59 Mon Sep 17 00:00:00 2001 From: SpecialX <47072643+wangxiner55@users.noreply.github.com> Date: Tue, 14 Jul 2026 22:57:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(shared-proto):=20ai/core=5Fedu/iam=20proto?= =?UTF-8?q?=20v2=20=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ai.proto: 新增 GenerateReport RPC + GenerateReportRequest/GeneratedReport message core_edu.proto: 新增 ExtendExam/ForceSubmitExam/ReorderExamQuestions 3 RPC + message iam.proto: 新增 CreateUser/UpdateUser/DeleteUser 3 RPC + 4 message --- packages/shared-proto/proto/ai.proto | 48 +++++++++++++++------- packages/shared-proto/proto/core_edu.proto | 47 ++++++++++++++++++++- packages/shared-proto/proto/iam.proto | 41 ++++++++++++++++++ 3 files changed, 120 insertions(+), 16 deletions(-) diff --git a/packages/shared-proto/proto/ai.proto b/packages/shared-proto/proto/ai.proto index e48aaff..3be63a7 100644 --- a/packages/shared-proto/proto/ai.proto +++ b/packages/shared-proto/proto/ai.proto @@ -23,6 +23,8 @@ service AiService { rpc GetLessonPlanStatus(GetLessonPlanStatusRequest) returns (LessonPlanStatus); // 教师确认备课结果入库(调 content.CreateQuestions) rpc ConfirmLessonPlan(ConfirmLessonPlanRequest) returns (ConfirmResult); + // 生成学情报告(班级总结 / 学生详情 / 考试分析) + rpc GenerateReport(GenerateReportRequest) returns (GeneratedReport); } // === 聊天 === @@ -33,11 +35,11 @@ message ChatRequest { // 可选上下文(ai12 增补:BFF 透传用户身份与数据范围) optional string user_id = 4; optional string session_id = 5; - optional string data_scope = 6; // JSON 序列化的 DataScope + optional string data_scope = 6; // JSON 序列化的 DataScope } message ChatMessage { - string role = 1; // system / user / assistant + string role = 1; // system / user / assistant string content = 2; } @@ -45,8 +47,8 @@ message ChatResponse { string content = 1; string model = 2; Usage usage = 3; - bool degraded = 4; // 降级标记(方案 B:success=true + data 内 degraded) - string degraded_reason = 5; // 降级原因(如 llm_unavailable / redis_unavailable) + bool degraded = 4; // 降级标记(方案 B:success=true + data 内 degraded) + string degraded_reason = 5; // 降级原因(如 llm_unavailable / redis_unavailable) } message Usage { @@ -65,12 +67,12 @@ message ChatChunk { message GenerateQuestionRequest { string prompt = 1; string subject = 2; - string difficulty = 3; // easy / medium / hard + string difficulty = 3; // easy / medium / hard // 扩展字段(ai12 增补) optional string grade = 4; repeated string knowledge_point_ids = 5; - optional string question_type = 6; // single_choice / multi_choice / fill_blank / short_answer / essay - optional int32 count = 7; // 生成数量,默认 1 + optional string question_type = 6; // single_choice / multi_choice / fill_blank / short_answer / essay + optional int32 count = 7; // 生成数量,默认 1 } message GeneratedQuestion { @@ -80,15 +82,15 @@ message GeneratedQuestion { string question_type = 4; string difficulty = 5; repeated string knowledge_point_ids = 6; - optional double evaluation_score = 7; // 质量评分(0.0-1.0,评估三道防线输出) + optional double evaluation_score = 7; // 质量评分(0.0-1.0,评估三道防线输出) bool degraded = 8; string degraded_reason = 9; } message GeneratedQuestionChunk { - string content = 1; // 逐字内容 + string content = 1; // 逐字内容 bool done = 2; - optional GeneratedQuestion complete_question = 3; // done=true 时携带完整题目 + optional GeneratedQuestion complete_question = 3; // done=true 时携带完整题目 } // === 表达优化 === @@ -109,15 +111,15 @@ message GenerateLessonPlanRequest { string class_id = 1; string subject_id = 2; string topic = 3; - string target_difficulty = 4; // easy / medium / hard + string target_difficulty = 4; // easy / medium / hard int32 question_count = 5; string user_id = 6; - string data_scope = 7; // JSON 序列化的 DataScope + string data_scope = 7; // JSON 序列化的 DataScope } message LessonPlanResponse { string workflow_id = 1; - string status = 2; // pending / analyzing / generating / pending_review / persisted / failed + string status = 2; // pending / analyzing / generating / pending_review / persisted / failed int32 estimated_completion_seconds = 3; bool degraded = 4; string degraded_reason = 5; @@ -138,7 +140,7 @@ message LessonPlanStatus { message ConfirmLessonPlanRequest { string workflow_id = 1; - map modifications = 2; // question_id → 修改后内容(可选,教师审核修改) + map modifications = 2; // question_id → 修改后内容(可选,教师审核修改) } message ConfirmResult { @@ -146,3 +148,21 @@ message ConfirmResult { repeated string persisted_question_ids = 2; optional string error = 3; } + +// === 学情报告 === +message GenerateReportRequest { + string class_id = 1; + string report_type = 2; // class_summary / student_detail / exam_analysis + optional string student_id = 3; + string user_id = 4; + string data_scope = 5; // JSON 序列化的 DataScope +} + +message GeneratedReport { + string id = 1; + string content = 2; // 报告正文(Markdown) + string summary = 3; // 摘要 + repeated string recommendations = 4; // 教学建议 + bool degraded = 5; + string degraded_reason = 6; +} diff --git a/packages/shared-proto/proto/core_edu.proto b/packages/shared-proto/proto/core_edu.proto index 9cf8a67..56c4d2a 100644 --- a/packages/shared-proto/proto/core_edu.proto +++ b/packages/shared-proto/proto/core_edu.proto @@ -6,8 +6,8 @@ package next_edu_cloud.core_edu.v1; // Covers exam management, homework assignment, grade recording, // attendance tracking, and class queries. // -// Total: 9 Service / 40 RPC (P3.13 expanded state per downstream 9-module analysis). -// - ExamService: 10 RPC (8 original + SaveExamDraft + RecordExamViolation) +// Total: 9 Service / 43 RPC (P3.13 expanded + P3.14 exam realtime events). +// - ExamService: 13 RPC (8 original + SaveExamDraft + RecordExamViolation + ExtendExam + ForceSubmitExam + ReorderExamQuestions) // - HomeworkService: 5 RPC // - GradeService: 7 RPC (6 original + GetReportCard) // - ClassService: 4 RPC @@ -36,6 +36,9 @@ service ExamService { rpc GradeExam(GradeExamRequest) returns (GradeExamResponse); rpc SaveExamDraft(SaveExamDraftRequest) returns (SaveExamDraftResponse); rpc RecordExamViolation(RecordExamViolationRequest) returns (RecordExamViolationResponse); + rpc ExtendExam(ExtendExamRequest) returns (ExtendExamResponse); + rpc ForceSubmitExam(ForceSubmitExamRequest) returns (ForceSubmitExamResponse); + rpc ReorderExamQuestions(ReorderExamQuestionsRequest) returns (ReorderExamQuestionsResponse); } service HomeworkService { @@ -493,6 +496,46 @@ message RecordExamViolationResponse { string violation_id = 1; } +// ---------------------------------------------------------------------------- +// Exam realtime events (P3.14: 考试实时事件,供 push-gateway → student-portal WebSocket 推送) +// ---------------------------------------------------------------------------- + +message ExtendExamRequest { + string exam_id = 1; + int32 extension_seconds = 2; // 延长秒数 + string extended_by = 3; // 操作教师 ID +} + +message ExtendExamResponse { + bool success = 1; + int32 new_duration = 2; // 延长后的总时长(秒) +} + +message ForceSubmitExamRequest { + string exam_id = 1; + repeated string student_ids = 2; // 强制收卷的学生 ID 列表(空=全部未提交学生) + string forced_by = 3; // 操作教师 ID +} + +message ForceSubmitExamResponse { + int32 affected_count = 1; // 强制收卷的学生数 +} + +message QuestionOrderInput { + string question_id = 1; + int32 order = 2; +} + +message ReorderExamQuestionsRequest { + string exam_id = 1; + repeated QuestionOrderInput orders = 2; // 新的题目顺序 + string reordered_by = 3; +} + +message ReorderExamQuestionsResponse { + bool success = 1; +} + // ---------------------------------------------------------------------------- // Grade domain extensions (P3.13) // ---------------------------------------------------------------------------- diff --git a/packages/shared-proto/proto/iam.proto b/packages/shared-proto/proto/iam.proto index 012a783..84d01cb 100644 --- a/packages/shared-proto/proto/iam.proto +++ b/packages/shared-proto/proto/iam.proto @@ -15,9 +15,24 @@ service IamService { // 用户信息类 rpc GetUserInfo(GetUserInfoRequest) returns (UserInfo); + rpc BatchGetUsers(BatchGetUsersRequest) returns (BatchGetUsersResponse); // GetEffectiveDataScope 解析用户可见数据范围(DataScope 6 级). // data-ana gRPC 调用此 RPC 解析查询过滤范围(coord-cross-review §2 #3 裁决 P4 补全). rpc GetEffectiveDataScope(GetEffectiveDataScopeRequest) returns (EffectiveDataScope); + + // 权限与视口类 + rpc GetEffectivePermissions(GetEffectivePermissionsRequest) returns (EffectivePermissionsResponse); + rpc GetEffectiveAccess(GetEffectiveAccessRequest) returns (EffectiveAccessResponse); + rpc GetViewports(GetViewportsRequest) returns (ViewportsResponse); + + // 密钥与关系类 + rpc GetPublicKey(GetPublicKeyRequest) returns (PublicKeyResponse); + rpc GetChildrenByParent(GetChildrenByParentRequest) returns (ChildrenResponse); + + // 管理员用户管理类(admin-portal §2.3 P1 阻塞项补齐) + rpc CreateUser(CreateUserRequest) returns (UserInfo); + rpc UpdateUser(UpdateUserRequest) returns (UserInfo); + rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse); } // ========== 认证类 ========== @@ -159,3 +174,29 @@ message EffectiveDataScope { repeated string scope_ids = 3; // class_id 列表(CLASS 级)/ grade_id 列表(GRADE 级) string school_id = 4; // SCHOOL 级时的学校 ID } + +// ========== 管理员用户管理类 ========== + +message CreateUserRequest { + string email = 1; + string password = 2; + string name = 3; + string role_id = 4; // 可选:指定角色 ID(不传则使用默认 teacher 角色) + string data_scope = 5; // 可选:self / subject / class / grade / school / all +} + +message UpdateUserRequest { + string user_id = 1; + string name = 2; // 可选 + string email = 3; // 可选 + string status = 4; // 可选:active / inactive / locked + string data_scope = 5; // 可选:self / subject / class / grade / school / all +} + +message DeleteUserRequest { + string user_id = 1; +} + +message DeleteUserResponse { + bool success = 1; +}