ソースを参照

fix(api): 清理服务层fullUrl设置代码,使用parseWithAwait处理异步URL

- 移除aggregated.service.ts中设置fullUrl=null的代码
- 移除disabled-person.service.ts中手动设置fileUrl的代码
- 让parseWithAwait处理异步的fullUrl Promise
- 更新前端使用photo.file?.fullUrl而不是photo.fileUrl

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 2 日 前
コミット
1994d9238d

+ 0 - 43
allin-packages/disability-module/src/services/aggregated.service.ts

@@ -148,21 +148,6 @@ export class AggregatedService {
       savedVisits = await this.visitRepository.save(visitsToSave);
     }
 
-    // 为照片获取文件URL
-    for (const photo of savedPhotos) {
-      if (photo.fileId) {
-        try {
-          const file = await this.fileRepository.findOne({ where: { id: photo.fileId } });
-          if (file) {
-            const url = await file.fullUrl;
-            (photo as any).fileUrl = url;
-          }
-        } catch (error) {
-          console.error('获取文件URL失败:', error);
-          (photo as any).fileUrl = null;
-        }
-      }
-    }
 
     // 返回创建的所有信息
     return {
@@ -193,20 +178,6 @@ export class AggregatedService {
       throw new Error('未找到该残疾人信息');
     }
 
-    // 为照片获取文件URL
-    if (person.photos) {
-      for (const photo of person.photos) {
-        if (photo.file) {
-          try {
-            const url = await photo.file.fullUrl;
-            (photo as any).fileUrl = url;
-          } catch (error) {
-            console.error('获取文件URL失败:', error);
-            (photo as any).fileUrl = null;
-          }
-        }
-      }
-    }
 
     return {
       personInfo: person,
@@ -310,20 +281,6 @@ export class AggregatedService {
       return null;
     }
 
-    // 为照片获取文件URL
-    for (const photo of updatedPerson.photos || []) {
-      if (photo.fileId) {
-        try {
-          const file = await this.fileRepository.findOne({ where: { id: photo.fileId } });
-          if (file) {
-            const url = await file.fullUrl;
-            (photo as any).fileUrl = url;
-          }
-        } catch (error) {
-          console.error('获取文件URL失败:', error);
-        }
-      }
-    }
 
     return {
       personInfo: updatedPerson,

+ 0 - 25
allin-packages/disability-module/src/services/disabled-person.service.ts

@@ -95,18 +95,6 @@ export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
     });
 
     if (person && person.photos) {
-      // 为每个照片获取文件URL
-      for (const photo of person.photos) {
-        if (photo.file) {
-          try {
-            const url = await photo.file.fullUrl;
-            (photo as any).fileUrl = url;
-          } catch (error) {
-            console.error('获取文件URL失败:', error);
-            (photo as any).fileUrl = null;
-          }
-        }
-      }
     }
 
     return person;
@@ -182,7 +170,6 @@ export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
             (photo as any).fileUrl = url;
           } catch (error) {
             console.error('获取文件URL失败:', error);
-            (photo as any).fileUrl = null;
           }
         }
       }
@@ -239,18 +226,6 @@ export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
     });
 
     if (person && person.photos) {
-      // 为每个照片获取文件URL
-      for (const photo of person.photos) {
-        if (photo.file) {
-          try {
-            const url = await photo.file.fullUrl;
-            (photo as any).fileUrl = url;
-          } catch (error) {
-            console.error('获取文件URL失败:', error);
-            (photo as any).fileUrl = null;
-          }
-        }
-      }
     }
 
     return person;