diff --git a/app/controllers/shixun_lists_controller.rb b/app/controllers/shixun_lists_controller.rb index 47ebe034f..d0bfe3d88 100644 --- a/app/controllers/shixun_lists_controller.rb +++ b/app/controllers/shixun_lists_controller.rb @@ -1,6 +1,6 @@ class ShixunListsController < ApplicationController def index - @results = ShixunSearchService.call(search_params, request.subdomain) + @results = ShixunSearchService.call(search_params, current_laboratory) end private diff --git a/app/controllers/subject_lists_controller.rb b/app/controllers/subject_lists_controller.rb index a13e7be80..ef85ccd70 100644 --- a/app/controllers/subject_lists_controller.rb +++ b/app/controllers/subject_lists_controller.rb @@ -1,6 +1,6 @@ class SubjectListsController < ApplicationController def index - @results = SubjectSearchService.call(search_params, request.subdomain) + @results = SubjectSearchService.call(search_params, current_laboratory) end private diff --git a/app/services/shixun_search_service.rb b/app/services/shixun_search_service.rb index e1eec9f50..1b35fbe54 100644 --- a/app/services/shixun_search_service.rb +++ b/app/services/shixun_search_service.rb @@ -1,11 +1,11 @@ class ShixunSearchService < ApplicationService include ElasticsearchAble - attr_reader :params, :subdomain + attr_reader :params, :laboratory - def initialize(params, subdomain) + def initialize(params, laboratory) @params = params - @subdomain = subdomain + @laboratory = laboratory end def call @@ -37,8 +37,8 @@ class ShixunSearchService < ApplicationService end ## 云上实验室过滤 - unless current_laboratory.main_site? - @shixuns = @shixuns.joins(:laboratory_shixuns).where(laboratory_shixuns: { laboratory_id: current_laboratory.id }) + unless laboratory.main_site? + @shixuns = @shixuns.joins(:laboratory_shixuns).where(laboratory_shixuns: { laboratory_id: @laboratory.id }) end # laboratory = Laboratory.find_by_subdomain(subdomain) diff --git a/app/services/subject_search_service.rb b/app/services/subject_search_service.rb index 314763ceb..9985e8693 100644 --- a/app/services/subject_search_service.rb +++ b/app/services/subject_search_service.rb @@ -1,11 +1,11 @@ class SubjectSearchService < ApplicationService include ElasticsearchAble - attr_reader :params, :subdomain + attr_reader :params, :laboratory - def initialize(params, subdomain) + def initialize(params, laboratory) @params = params - @subdomain = subdomain + @laboratory = laboratory end def call @@ -22,8 +22,8 @@ class SubjectSearchService < ApplicationService # @subjects = @subjects.where(id: laboratory.subjects) if laboratory ## 云上实验室过滤 - unless current_laboratory.main_site? - subjects = subjects.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id }) + unless laboratory.main_site? + @subjects = @subjects.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: laboratory.id }) end Subject.search(keyword, search_options)