...
|
...
|
@@ -49,8 +49,9 @@ func (ptr *AppendDataToTableService) AppendData(ctx *domain.Context, fileId int, |
|
|
}
|
|
|
|
|
|
// 日志
|
|
|
entry := domain.NewLogEntry(table.Name, domain.MainTable.ToString(), domain.AppendData, ctx)
|
|
|
if err = FastLog(ptr.transactionContext, domain.CommonLog, table.TableId, &AppendDataToTableLog{
|
|
|
LogEntry: domain.NewLogEntry(table.Name, domain.MainTable.ToString(), domain.AppendData, ctx),
|
|
|
LogEntry: (&entry).WithAppendFileId(fileId),
|
|
|
File: file,
|
|
|
Table: table,
|
|
|
SubTables: subTables,
|
...
|
...
|
@@ -90,6 +91,39 @@ func (ptr *AppendDataToTableService) AppendData(ctx *domain.Context, fileId int, |
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// PreflightCheck 预检
|
|
|
func (ptr *AppendDataToTableService) PreflightCheck(ctx *domain.Context, fileId int, tableId int, mappingFields []*domain.MappingField) (interface{}, error) {
|
|
|
tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
|
|
|
table, err := tableRepository.FindOne(map[string]interface{}{"tableId": tableId})
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("表不存在")
|
|
|
}
|
|
|
inSourceId := []int{table.TableId}
|
|
|
if table.ParentId != 0 {
|
|
|
inSourceId = append(inSourceId, table.ParentId)
|
|
|
}
|
|
|
logRepository, _ := repository.NewLogRepository(ptr.transactionContext)
|
|
|
_, logs, err := logRepository.Find(map[string]interface{}{
|
|
|
"inSourceId": inSourceId,
|
|
|
"inOperationType": []string{domain.GenerateMainTable.ToString(), domain.AppendData.ToString()},
|
|
|
"limit": 500,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
for _, log := range logs {
|
|
|
if log.Entry.AppendFileId == fileId {
|
|
|
return map[string]interface{}{
|
|
|
"fileAppended": true,
|
|
|
}, nil
|
|
|
}
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"fileAppended": false,
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
func NewAppendDataToTableService(transactionContext *pgTransaction.TransactionContext) (*AppendDataToTableService, error) {
|
|
|
if transactionContext == nil {
|
|
|
return nil, fmt.Errorf("transactionContext参数不能为nil")
|
...
|
...
|
|