From bb77a670e03f3040b374718748bb8604aec32442 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 15 Nov 2019 14:11:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=91=E4=B8=8A=E5=AE=9E=E9=AA=8C=E5=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixun_lists_controller.rb | 2 +- app/controllers/subject_lists_controller.rb | 2 +- app/services/shixun_search_service.rb | 10 +++++----- app/services/subject_search_service.rb | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) 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)