Skip to content

Commit

Permalink
data importe
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Dec 5, 2023
1 parent e0776aa commit ca0cda3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
17 changes: 17 additions & 0 deletions app/models/datum/model/data_list/data_import.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
require 'write_xlsx'
module Datum
module Model::DataList::DataImport
extend ActiveSupport::Concern

def template
io = StringIO.new
workbook = WriteXLSX.new(io)

sheet = workbook.add_worksheet
sheet.write_row(0, 0, headers)

workbook.close
io.string
end

def headers
export.columns.values.map(&->(i){ i[:header] })
end

end
end
15 changes: 11 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@
end
end
namespace :panel, defaults: { namespace: 'panel' } do
resources :data_lists do
collection do
post :sync
end
resources :data_exports do
member do
put :update_publish
patch :rebuild
end
end
resources :data_imports do
member do
match :template, via: [:get, :post]
end
end
resources :data_lists, only: [] do
collection do
post :sync
end
resources :table_lists do
collection do
get :direct
Expand Down

0 comments on commit ca0cda3

Please sign in to comment.