feat: expand commercial ai drama platform
This commit is contained in:
+44
-2
@@ -102,6 +102,48 @@ export function searchPlatform(context, { query = "", scope = "workspace", limit
|
||||
results.push(baseResult("script", "剧本", row, "script", row.title, `${row.project_name}${row.episode_title ? ` · ${row.episode_title}` : ""} · v${row.version_number}`, row.status));
|
||||
}
|
||||
|
||||
const knowledgeScopeClause = scope === "project" && context?.project?.id
|
||||
? " AND (kd.project_id IS NULL OR kd.project_id = ?)"
|
||||
: projectIds.length
|
||||
? ` AND (kd.project_id IS NULL OR kd.project_id IN (${ids}))`
|
||||
: " AND kd.project_id IS NULL";
|
||||
const knowledgeParams = scope === "project" && context?.project?.id
|
||||
? [context.organization.id, context.workspace.id, pattern, pattern, pattern, context.project.id, perType]
|
||||
: projectIds.length
|
||||
? [context.organization.id, context.workspace.id, pattern, pattern, pattern, ...projectIds, perType]
|
||||
: [context.organization.id, context.workspace.id, pattern, pattern, pattern, perType];
|
||||
const knowledgeDocuments = dbAll(
|
||||
`SELECT kd.*
|
||||
FROM knowledge_documents kd
|
||||
WHERE kd.organization_id = ? AND kd.workspace_id = ?
|
||||
AND (kd.title LIKE ? ESCAPE '\\' OR kd.content LIKE ? ESCAPE '\\' OR kd.summary LIKE ? ESCAPE '\\')
|
||||
${knowledgeScopeClause}
|
||||
ORDER BY kd.updated_at DESC LIMIT ?`,
|
||||
knowledgeParams
|
||||
);
|
||||
for (const row of knowledgeDocuments) {
|
||||
results.push(baseResult("knowledge_document", "知识素材", row, "knowledge", row.title, `${row.source_type} · ${row.scope_mode === "project" ? "项目级" : "工作区级"}`, row.status));
|
||||
}
|
||||
|
||||
const knowledgeChunkParams = scope === "project" && context?.project?.id
|
||||
? [context.organization.id, context.workspace.id, pattern, pattern, context.project.id, perType]
|
||||
: projectIds.length
|
||||
? [context.organization.id, context.workspace.id, pattern, pattern, ...projectIds, perType]
|
||||
: [context.organization.id, context.workspace.id, pattern, pattern, perType];
|
||||
const knowledgeChunks = dbAll(
|
||||
`SELECT kc.*, kd.title AS document_title, kd.project_id, kd.scope_mode, kd.organization_id, kd.workspace_id
|
||||
FROM knowledge_chunks kc
|
||||
JOIN knowledge_documents kd ON kd.id = kc.document_id
|
||||
WHERE kd.organization_id = ? AND kd.workspace_id = ?
|
||||
AND (kc.heading LIKE ? ESCAPE '\\' OR kc.content LIKE ? ESCAPE '\\')
|
||||
${knowledgeScopeClause}
|
||||
ORDER BY kd.updated_at DESC, kc.chunk_index ASC LIMIT ?`,
|
||||
knowledgeChunkParams
|
||||
);
|
||||
for (const row of knowledgeChunks) {
|
||||
results.push(baseResult("knowledge_chunk", "知识片段", row, "knowledge", row.heading || row.document_title, `${row.document_title} · chunk ${row.chunk_index}`, row.chunk_type));
|
||||
}
|
||||
|
||||
const shots = dbAll(
|
||||
`SELECT sh.*, e.episode_number, e.title AS episode_title,
|
||||
p.id AS project_id, p.name AS project_name, w.organization_id AS organization_id, p.workspace_id
|
||||
@@ -112,9 +154,9 @@ export function searchPlatform(context, { query = "", scope = "workspace", limit
|
||||
JOIN projects p ON p.id = s.project_id
|
||||
JOIN workspaces w ON w.id = p.workspace_id
|
||||
WHERE p.id IN (${ids})
|
||||
AND (sh.title LIKE ? ESCAPE '\\' OR sh.id LIKE ? ESCAPE '\\' OR sh.continuity_json LIKE ? ESCAPE '\\')
|
||||
AND (sh.title LIKE ? ESCAPE '\\' OR sh.id LIKE ? ESCAPE '\\' OR sh.continuity_json LIKE ? ESCAPE '\\' OR p.name LIKE ? ESCAPE '\\' OR s.title LIKE ? ESCAPE '\\' OR e.title LIKE ? ESCAPE '\\')
|
||||
ORDER BY sh.updated_at DESC LIMIT ?`,
|
||||
[...projectIds, pattern, pattern, pattern, perType]
|
||||
[...projectIds, pattern, pattern, pattern, pattern, pattern, pattern, perType]
|
||||
);
|
||||
for (const row of shots) {
|
||||
results.push(baseResult("shot", "镜头", row, "director", row.title, `${row.project_name} · E${String(row.episode_number).padStart(2, "0")} · S${String(row.shot_number).padStart(2, "0")}`, row.status));
|
||||
|
||||
Reference in New Issue
Block a user