梳理代码逻辑

导出数据

# 导出数据异步任务执行

ExportService::Service.get_entity_exporter(org, member_or_id, entity_name, options).export

class ExportService::Service
  class << self
    def get_entity_exporter(org, member_or_id, entity_name, options)
      case entity_name
      when 'SaleOrderReport'
				ExportService::SaleOrderReportExporter.new(member_or_id, options)
      when ''
        #...
      end
    end
  end
end

module ExportService
  class SaleOrderReportExporter < BaseExporter
  	#...
	end
end

class BaseExporter
  include ExportService::Base
  #...
end

module ExportService
  module Base
    def export
      #...
      send_complete_message
    end
    
    def send_complete_message
      send_message(handle: 'exported', remark: '导出成功', row_index: @current_page, href: "/exporter/download?path=#{@completed_filename}&entity_name=#{entity_klass}" )
    end
    
    def send_message(message)
      ActionCable.server.broadcast @broadcast, message if message.present?
    end
  end
end


登陆

# 回调路径
GET users/auth users#auth

# app/controllers/users_controller.rb
def	auth
  uc_api = IkApi::UserCenter.new
  # ...
end
# cookies和session分别存储 uid和 token.

# 用户中心相关
# lib/ik_api


# 登陆地址
GET "/users/sign_in" users/sessions#new

# 登陆拦截
# app/controller/application_controller.rb
class ApplicationController < ActionController::Base
  before_action :authenticate_user!, if: -> { !devise_controller? }
  def authenticate_user!
    #...
  end
end