| | |
| | | |
| | | func AddMoveHistory(operationList []*models.Operation, db *gorm.DB) error { |
| | | var histories []*models.MoveHistory |
| | | operationMap := make(map[string]*models.Operation, len(operationList)) |
| | | for _, operation := range operationList { |
| | | for _, v := range operation.Details { |
| | | history := &models.MoveHistory{ |
| | |
| | | } |
| | | histories = append(histories, history) |
| | | } |
| | | operationMap[operation.Number] = operation |
| | | } |
| | | if err := db.Model(&models.MoveHistory{}).Create(&histories).Error; err != nil { |
| | | return err |
| | | } |
| | | for _, history := range histories { |
| | | service.AddNewHistoryReportRecord(history) |
| | | service.AddNewHistoryReportRecord(history, operationMap[history.Number]) |
| | | } |
| | | return nil |
| | | } |