Version: 0.9.72.dev.260505
后端: 1.task-class 服务边界落地 - 新增 cmd/task-class 独立进程入口,落地 services/task_class dao/rpc/sv - 新增 gateway/client/taskclass、shared/contracts/taskclass 和 shared/ports task-class port - 将 /api/v1/task-class/* HTTP 门面切到 task-class zrpc,gateway 只保留鉴权、幂等、参数绑定和响应透传 - 保留 task-class 迁移期直写 schedule_events / schedules 权限,维持 insert/apply 与 item 状态更新的本地事务语义 - 修复 task-class 删除已排入日程任务块时 schedules / schedule_events 的外键删除顺序 - 补充 taskClass.rpc 示例配置与阶段 5 文档基线、切流点、残留依赖和 smoke 记录 - 忽略根目录 .tmp 临时烟测产物
This commit is contained in:
88
backend/shared/contracts/taskclass/types.go
Normal file
88
backend/shared/contracts/taskclass/types.go
Normal file
@@ -0,0 +1,88 @@
|
||||
package taskclass
|
||||
|
||||
// TargetTime 表示任务块被安排到课表中的相对时间坐标。
|
||||
type TargetTime struct {
|
||||
Week int `json:"week"`
|
||||
DayOfWeek int `json:"day_of_week"`
|
||||
SectionFrom int `json:"section_from"`
|
||||
SectionTo int `json:"section_to"`
|
||||
}
|
||||
|
||||
// UpsertTaskClassRequest 是 task-class 服务新增/更新任务类的跨进程契约。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. UserID 由 gateway 鉴权后补齐,不信任前端传入值;
|
||||
// 2. TaskClassID 仅 update 场景使用,add 场景保持 0;
|
||||
// 3. 业务校验仍由 task-class 服务 sv 层统一执行。
|
||||
type UpsertTaskClassRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
TaskClassID int `json:"task_class_id,omitempty"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
StartDate string `json:"start_date" binding:"required"`
|
||||
EndDate string `json:"end_date" binding:"required"`
|
||||
Mode string `json:"mode" binding:"required,oneof=auto manual"`
|
||||
SubjectType string `json:"subject_type,omitempty"`
|
||||
DifficultyLevel string `json:"difficulty_level,omitempty"`
|
||||
CognitiveIntensity string `json:"cognitive_intensity,omitempty"`
|
||||
Config UpsertTaskClassConfig `json:"config" binding:"required"`
|
||||
Items []UpsertTaskClassItemConfig `json:"items" binding:"required"`
|
||||
}
|
||||
|
||||
type UpsertTaskClassConfig struct {
|
||||
TotalSlots int `json:"total_slots" binding:"required,min=1"`
|
||||
AllowFillerCourse bool `json:"allow_filler_course"`
|
||||
Strategy string `json:"strategy" binding:"required,oneof=steady rapid"`
|
||||
ExcludedSlots []int `json:"excluded_slots"`
|
||||
ExcludedDaysOfWeek []int `json:"excluded_days_of_week"`
|
||||
}
|
||||
|
||||
type UpsertTaskClassItemConfig struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
Order int `json:"order" binding:"required,min=1"`
|
||||
Content string `json:"content" binding:"required"`
|
||||
EmbeddedTime *TargetTime `json:"embedded_time"`
|
||||
}
|
||||
|
||||
type UserRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
}
|
||||
|
||||
type GetTaskClassRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
TaskClassID int `json:"task_class_id"`
|
||||
}
|
||||
|
||||
type InsertTaskClassItemIntoScheduleRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
TaskItemID int `json:"task_item_id"`
|
||||
Week int `json:"week" binding:"required,min=1"`
|
||||
DayOfWeek int `json:"day_of_week" binding:"required,min=1,max=7"`
|
||||
StartSection int `json:"start_section" binding:"required,min=1"`
|
||||
EndSection int `json:"end_section" binding:"required,min=1,gtefield=StartSection"`
|
||||
EmbedCourseEventID int `json:"embed_course_event_id"`
|
||||
}
|
||||
|
||||
type DeleteTaskClassItemRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
TaskItemID int `json:"task_item_id"`
|
||||
}
|
||||
|
||||
type DeleteTaskClassRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
TaskClassID int `json:"task_class_id"`
|
||||
}
|
||||
|
||||
type ApplyBatchIntoScheduleRequest struct {
|
||||
UserID int `json:"user_id"`
|
||||
TaskClassID int `json:"task_class_id" binding:"required"`
|
||||
Items []SingleTaskClassItem `json:"items" binding:"required,dive,required"`
|
||||
}
|
||||
|
||||
type SingleTaskClassItem struct {
|
||||
TaskItemID int `json:"task_item_id" binding:"required"`
|
||||
Week int `json:"week" binding:"required,min=1"`
|
||||
DayOfWeek int `json:"day_of_week" binding:"required,min=1,max=7"`
|
||||
StartSection int `json:"start_section" binding:"required,min=1"`
|
||||
EndSection int `json:"end_section" binding:"required,min=1,gtefield=StartSection"`
|
||||
EmbedCourseEventID int `json:"embed_course_event_id"`
|
||||
}
|
||||
Reference in New Issue
Block a user