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);
|
|
}
|
}
|