feat(teacher): 连接 Yuxi 老师并提供项目与会话只读工具
This commit is contained in:
@@ -24,10 +24,11 @@ export async function handleCodingTeacherRoutes(
|
||||
/^\/api\/coding\/teacher-preview\/topics(?:\/([^/]+))?(?:\/(messages|events|save|requests\/([^/]+)\/cancel))?$/
|
||||
);
|
||||
const config = url.pathname === '/api/coding/teacher/config';
|
||||
const catalog = url.pathname === '/api/coding/teacher/teachers';
|
||||
const draft = url.pathname === '/api/coding/teacher-preview';
|
||||
const pending = url.pathname === '/api/coding/teacher-preview/pending-link';
|
||||
if (!source && !preview && !config && !draft && !pending) return false;
|
||||
if ((config || draft || pending) && req.method !== 'GET') {
|
||||
if (!source && !preview && !config && !catalog && !draft && !pending) return false;
|
||||
if ((config || catalog || draft || pending) && req.method !== 'GET') {
|
||||
sendJson(res, 405, { error: '不支持此操作。' });
|
||||
return true;
|
||||
}
|
||||
@@ -41,6 +42,10 @@ export async function handleCodingTeacherRoutes(
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
if (catalog) {
|
||||
sendJson(res, 200, await service.catalog());
|
||||
return true;
|
||||
}
|
||||
if (config && req.method === 'GET') {
|
||||
sendJson(res, 200, await service.definition());
|
||||
return true;
|
||||
@@ -63,8 +68,8 @@ export async function handleCodingTeacherRoutes(
|
||||
return true;
|
||||
}
|
||||
if (!id && req.method === 'POST') {
|
||||
const body = await parseJsonBody<{ draftRevision?: number; sampleContext?: string }>(req);
|
||||
sendJson(res, 201, await service.create(scope, body.draftRevision, body.sampleContext));
|
||||
const body = await parseJsonBody<{ draftRevision?: number; sampleContext?: string; teacherVersion?: number }>(req);
|
||||
sendJson(res, 201, await service.create(scope, body.draftRevision, body.sampleContext, body.teacherVersion));
|
||||
return true;
|
||||
}
|
||||
if (id && !action && req.method === 'GET') {
|
||||
|
||||
Reference in New Issue
Block a user