Version: 0.9.73.dev.260505
后端: 1.阶段 5 course 服务边界落地 - 新增 cmd/course 独立进程入口,落地 services/course dao/rpc/sv - 新增 gateway/client/course、shared/contracts/course 和 shared/ports course port - 将 /api/v1/course/* HTTP 门面切到 course zrpc,gateway 只保留鉴权、限流、幂等、文件读取和响应透传 - 保留 course 迁移期直写 schedule_events / schedules 权限,维持课程导入两个表同事务写入语义 - 为 course parse-image 补 bytes RPC 契约和 gRPC 消息大小配置,兼容课表图片上传 - 补充 course.rpc 示例配置与阶段 5 文档基线、切流点、残留依赖和 smoke 记录
This commit is contained in:
66
backend/shared/contracts/course/types.go
Normal file
66
backend/shared/contracts/course/types.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package course
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// CourseArrangement 是课程导入中单个上课时间片的跨进程契约。
|
||||
type CourseArrangement struct {
|
||||
StartWeek int `json:"start_week"`
|
||||
EndWeek int `json:"end_week"`
|
||||
DayOfWeek int `json:"day_of_week"`
|
||||
StartSection int `json:"start_section"`
|
||||
EndSection int `json:"end_section"`
|
||||
WeekType string `json:"week_type"`
|
||||
}
|
||||
|
||||
// UserCheckCourseRequest 是 course validate / import 共用的课程输入契约。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. 只描述 HTTP 与 course 服务之间稳定传递的字段;
|
||||
// 2. 不承载课程冲突检测、时间换算或 schedule 写入逻辑;
|
||||
// 3. UserID 由 gateway 在 import 场景补齐,不信任前端传入。
|
||||
type UserCheckCourseRequest struct {
|
||||
CourseName string `json:"course_name"`
|
||||
Location string `json:"location"`
|
||||
IsAllowTasks bool `json:"is_allow_tasks"`
|
||||
Arrangements []CourseArrangement `json:"arrangements"`
|
||||
}
|
||||
|
||||
type UserImportCoursesRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
Courses []UserCheckCourseRequest `json:"courses"`
|
||||
}
|
||||
|
||||
// ImportCoursesResult 用来保留旧 HTTP 在冲突时返回 conflicts 数据的语义。
|
||||
type ImportCoursesResult struct {
|
||||
Conflict bool `json:"conflict"`
|
||||
Conflicts json.RawMessage `json:"conflicts,omitempty"`
|
||||
}
|
||||
|
||||
type CourseImageParseRequest struct {
|
||||
Filename string `json:"filename"`
|
||||
MIMEType string `json:"mime_type"`
|
||||
ImageBytes []byte `json:"image_bytes"`
|
||||
}
|
||||
|
||||
type CourseImageParseRow struct {
|
||||
RowID string `json:"row_id"`
|
||||
CourseName string `json:"course_name"`
|
||||
Location string `json:"location"`
|
||||
IsAllowTasks bool `json:"is_allow_tasks"`
|
||||
StartWeek *int `json:"start_week"`
|
||||
EndWeek *int `json:"end_week"`
|
||||
DayOfWeek *int `json:"day_of_week"`
|
||||
StartSection *int `json:"start_section"`
|
||||
EndSection *int `json:"end_section"`
|
||||
WeekType string `json:"week_type"`
|
||||
Confidence float64 `json:"confidence"`
|
||||
RawText string `json:"raw_text"`
|
||||
RowWarnings []string `json:"row_warnings"`
|
||||
}
|
||||
|
||||
type CourseImageParseResponse struct {
|
||||
DraftStatus string `json:"draft_status"`
|
||||
Message string `json:"message"`
|
||||
Warnings []string `json:"warnings"`
|
||||
Rows []CourseImageParseRow `json:"rows"`
|
||||
}
|
||||
Reference in New Issue
Block a user