Skip to content

Commit

Permalink
Merge pull request #159 from actiontech/main
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
rocky114 authored Feb 1, 2024
2 parents a86a8de + f23a3e1 commit 179e4cc
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5795,6 +5795,10 @@
},
"x-go-name": "AuditSQLResult"
},
"export_sql_type": {
"type": "string",
"x-go-name": "ExportSQLType"
},
"export_status": {
"type": "string",
"x-go-name": "ExportResult"
Expand Down
3 changes: 3 additions & 0 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,9 @@ definitions:
$ref: '#/definitions/AuditSQLResult'
type: array
x-go-name: AuditSQLResult
export_sql_type:
type: string
x-go-name: ExportSQLType
export_status:
type: string
x-go-name: ExportResult
Expand Down
1 change: 1 addition & 0 deletions internal/dms/biz/data_export_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ type DataExportTaskRepo interface {
ListDataExportTasks(ctx context.Context, opt *ListDataExportTaskOption) (exportTasks []*DataExportTask, total int64, err error)
DeleteUnusedDataExportTasks(ctx context.Context) error
BatchUpdateDataExportTaskByIds(ctx context.Context, ids []string, args map[string]interface{}) error
SaveDataExportTaskRecords(ctx context.Context, dataExportTaskRecords []*DataExportTaskRecord) error
}
19 changes: 19 additions & 0 deletions internal/dms/storage/data_export_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (d *DataExportTaskRepo) SaveDataExportTask(ctx context.Context, dataExportD

return nil
}

func (d *DataExportTaskRepo) GetDataExportTaskByIds(ctx context.Context, ids []string) (dataExportDataExportTasks []*biz.DataExportTask, err error) {
tasks := make([]*model.DataExportTask, 0)
if err := transaction(d.log, ctx, d.db, func(tx *gorm.DB) error {
Expand Down Expand Up @@ -168,3 +169,21 @@ func (d *DataExportTaskRepo) BatchUpdateDataExportTaskByIds(ctx context.Context,
return nil
})
}

func (d *DataExportTaskRepo) SaveDataExportTaskRecords(ctx context.Context, dataExportTaskRecords []*biz.DataExportTaskRecord) error {
models := make([]*model.DataExportTaskRecord, 0)
for _, dataExportTaskRecord := range dataExportTaskRecords {
models = append(models, convertBizDataExportTaskRecords(dataExportTaskRecord))
}

if err := transaction(d.log, ctx, d.db, func(tx *gorm.DB) error {
if err := tx.WithContext(ctx).Save(models).Error; err != nil {
return fmt.Errorf("failed to save data export task records: %v", err)
}
return nil
}); err != nil {
return err
}

return nil
}
2 changes: 1 addition & 1 deletion internal/dms/storage/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ type DataExportTask struct {
type DataExportTaskRecord struct {
Number uint `json:"number" gorm:"index:task_id_number,unique"`
DataExportTaskId string `json:"data_export_task_id" gorm:"size:32;column:data_export_task_id;index:task_id_number,unique"`
ExportSQL string `json:"export_sql" gorm:"size:255"`
ExportSQL string `json:"export_sql"`
ExportSQLType string `json:"export_sql_type" gorm:"column:export_sql_type;size:10"`
ExportResult string `json:"export_result"`
ExportStatus string `json:"export_status" gorm:"size:32"`
Expand Down

0 comments on commit 179e4cc

Please sign in to comment.