|
|
@@ -1,5 +1,5 @@
|
|
|
import { GenericCrudService } from '@/server/utils/generic-crud.service';
|
|
|
-import { DataSource, Repository, In } from 'typeorm';
|
|
|
+import { DataSource, Repository } from 'typeorm';
|
|
|
import { SolutionDesign } from './solution-design.entity';
|
|
|
import { SolutionChapter } from './solution-chapter.entity';
|
|
|
import { DocumentService } from '@/server/modules/documents/document.service';
|
|
|
@@ -27,7 +27,7 @@ export class SolutionDesignService extends GenericCrudService<SolutionDesign> {
|
|
|
constructor(dataSource: DataSource) {
|
|
|
super(dataSource, SolutionDesign);
|
|
|
this.chapterRepository = dataSource.getRepository(SolutionChapter);
|
|
|
- this.documentService = new DocumentService(dataSource);
|
|
|
+ this.documentService = new DocumentService();
|
|
|
this.fileService = new FileService(dataSource);
|
|
|
this.aiService = new AIService();
|
|
|
}
|
|
|
@@ -54,10 +54,14 @@ export class SolutionDesignService extends GenericCrudService<SolutionDesign> {
|
|
|
|
|
|
// 如果有原始文件,尝试自动提取章节
|
|
|
if (originalFileId) {
|
|
|
- await this.autoExtractChapters(savedDesign.id, originalFileId);
|
|
|
+ await this.autoExtractChapters(savedDesign.id!, originalFileId);
|
|
|
}
|
|
|
|
|
|
- return this.getById(savedDesign.id, ['user', 'originalFile', 'chapters']);
|
|
|
+ const result = await this.getById(savedDesign.id!, ['user', 'originalFile', 'chapters']);
|
|
|
+ if (!result) {
|
|
|
+ throw new Error('创建方案设计失败');
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -151,7 +155,7 @@ export class SolutionDesignService extends GenericCrudService<SolutionDesign> {
|
|
|
// 更新总章节数
|
|
|
await this.repository.increment({ id: designId }, 'totalChapters', 1);
|
|
|
|
|
|
- return savedChapter;
|
|
|
+ return savedChapter as unknown as SolutionChapter;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -318,17 +322,17 @@ export class SolutionDesignService extends GenericCrudService<SolutionDesign> {
|
|
|
const downloadUrl = await this.documentService.saveToMinio(buffer, fileName);
|
|
|
|
|
|
// 创建文件记录
|
|
|
- const file = await this.fileService.createFile({
|
|
|
- originalName: fileName,
|
|
|
+ const fileResult = await this.fileService.createFile({
|
|
|
+ name: fileName,
|
|
|
size: buffer.length,
|
|
|
- mimeType: design.outputFormat === 'pdf' ? 'application/pdf' :
|
|
|
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
|
- storagePath: downloadUrl
|
|
|
+ type: design.outputFormat === 'pdf' ? 'application/pdf' :
|
|
|
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
|
+ path: downloadUrl
|
|
|
});
|
|
|
|
|
|
// 更新方案设计的输出文件
|
|
|
await this.repository.update(designId, {
|
|
|
- outputFileId: file.id,
|
|
|
+ outputFileId: fileResult.file.id,
|
|
|
status: 'completed'
|
|
|
});
|
|
|
|