2024-03-07 22:48:01 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class RepositoryExportService
|
2024-08-06 19:26:14 +08:00
|
|
|
def initialize(file_type, rows, columns, repository, handle_name_func = nil, in_module: false, ordered_row_ids: nil)
|
2024-03-07 22:48:01 +08:00
|
|
|
@file_type = file_type
|
|
|
|
@rows = rows
|
|
|
|
@columns = columns
|
|
|
|
@repository = repository
|
|
|
|
@handle_name_func = handle_name_func
|
|
|
|
@in_module = in_module
|
2024-08-06 19:26:14 +08:00
|
|
|
@ordered_row_ids = ordered_row_ids
|
2024-03-07 22:48:01 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def export!
|
|
|
|
case @file_type
|
|
|
|
when :csv
|
2024-08-06 19:26:14 +08:00
|
|
|
file_data = RepositoryCsvExport.to_csv(@rows, @columns, @repository, @handle_name_func, @in_module, @ordered_row_ids)
|
2024-03-07 22:48:01 +08:00
|
|
|
when :xlsx
|
2024-08-06 19:26:14 +08:00
|
|
|
file_data = RepositoryXlsxExport.to_xlsx(@rows, @columns, @repository, @handle_name_func, @in_module, @ordered_row_ids)
|
2024-03-07 22:48:01 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
file_data
|
|
|
|
end
|
|
|
|
end
|