feat(content): docker 本地测试通过 + P5 ES 集成 + P6+ 审核工作流/可视化/可观测性
P5 ES 集成: - config/elasticsearch.ts: 惰性初始化 + ik_max_word→standard 回退 - shared/sync/es-sync.worker.ts: Kafka 消费 question 事件并索引 ES - questions search API: ES 优先, MySQL LIKE 降级 - ensureQuestionIndex() 幂等创建, IK 不可用回退 standard - main.ts: 启动 ensureQuestionIndex + esSyncWorker 生命周期管理 P6+ 审核工作流/可视化/可观测性: - Question 状态机: draft→pending_review→published→archived - 非法转换拦截 - 知识图谱可视化 API: Neo4j 优先 + MySQL 降级 - Cypher 返回标量避免 Node 包装对象问题 - 教材版本管理: GET /textbooks/versions + archive - 5 个 Prometheus 指标 + /readyz Outbox 积压检查 Docker 本地测试 (8 类全通过): - healthz/readyz (5 依赖 ok) - REST CRUD (textbook/chapter/kp/question) - ES 全文检索命中 - 审核工作流状态机 (合法/非法转换) - Outbox 事件驱动 (8 事件全 published) - Neo4j 同步 (KnowledgePoint 节点创建) - 可视化 (nodes/edges 正确) - Prometheus 指标 docs/nextstep.md: 上游 (MySQL/Neo4j/Kafka/Redis/ES/ai) + 下游 (teacher-bff/student-bff/parent-bff/data-ana/api-gateway/ai)
This commit is contained in:
@@ -101,4 +101,36 @@ export class TextbooksService {
|
||||
{ deleted: true },
|
||||
);
|
||||
}
|
||||
|
||||
// ========== P6.3: 教材版本管理 ==========
|
||||
|
||||
/**
|
||||
* 归档教材:将 status 置为 archived,发布 TEXTBOOK_ARCHIVED 事件。
|
||||
* 与 update(id, { status: "archived" }) 的区别:
|
||||
* - 显式语义化方法,便于权限粒度控制和审计
|
||||
* - 不接受其他字段变更,仅做状态归档
|
||||
*/
|
||||
async archiveTextbook(id: string): Promise<void> {
|
||||
const existing = await this.getById(id);
|
||||
await textbooksRepository.update(id, { status: "archived" });
|
||||
|
||||
await this.outbox.publish(
|
||||
EVENT_TYPES.TEXTBOOK_ARCHIVED,
|
||||
AGGREGATE_TYPES.TEXTBOOK,
|
||||
id,
|
||||
{
|
||||
title: existing.title,
|
||||
status: "archived",
|
||||
previous_status: existing.status,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出同 subject + grade 的所有教材版本(含已归档)。
|
||||
* 用于版本管理界面展示历史版本。
|
||||
*/
|
||||
async listVersions(subjectId: string, gradeId: string): Promise<Textbook[]> {
|
||||
return textbooksRepository.findBySubjectAndGrade(subjectId, gradeId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user