File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed
Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -399,17 +399,26 @@ export class AppService {
399399
400400 async saveData ( writeData : EIPs [ ] ) {
401401 try {
402- // console.log(writeData.length);
403402 await this . prisma . eIPs . deleteMany ( { } ) ;
404- // for (const item of writeData) {
405- // console.log('item:', item);
406- // await this.prisma.eIPs.create({ data: item });
407- // }
408- await this . prisma . eIPs . createMany ( {
409- data : writeData ,
410- } ) ;
403+
404+ for ( const item of writeData ) {
405+ // 确保 requires 字段是数字数组
406+ const formattedItem = {
407+ ...item ,
408+ requires : Array . isArray ( item . requires )
409+ ? item . requires . map ( ( r ) =>
410+ typeof r === 'number' ? r : parseInt ( r ) ,
411+ )
412+ : [ ] ,
413+ } ;
414+
415+ await this . prisma . eIPs . create ( {
416+ data : formattedItem ,
417+ } ) ;
418+ }
411419 } catch ( err ) {
412- console . log ( err ) ;
420+ console . error ( 'Error saving data:' , err ) ;
421+ throw err ;
413422 }
414423 }
415424
You can’t perform that action at this time.
0 commit comments