wangzhibo
2026-07-28 2b662657c5bc5bc45b69f475c7b2edcf8fc92f0c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Provide } from '@midwayjs/core';
import { BaseService, CoolCommException } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { OperationTradeRecordEntity } from '../entity/traderecord';
 
/**
 * 交易记录服务
 */
@Provide()
export class OperationTradeRecordService extends BaseService {
  @InjectEntityModel(OperationTradeRecordEntity)
  tradeRecordEntity: Repository<OperationTradeRecordEntity>;
 
 
  /**
   * 导入Excel数据
   * @param fileInfo 文件信息
   * @param dataList 解析后的数组
   */
  async importData(list: any[]) {
    if (!list || list.length === 0) {
      throw new Error('导入数据不能为空');
    }
    // 使用 TypeORM 的 save 方法批量插入
    await this.tradeRecordEntity.save(list);
 
  }
}