云上实验室

dev_home
cxt 5 years ago
parent a34b0683c8
commit bb77a670e0

@ -1,6 +1,6 @@
class ShixunListsController < ApplicationController class ShixunListsController < ApplicationController
def index def index
@results = ShixunSearchService.call(search_params, request.subdomain) @results = ShixunSearchService.call(search_params, current_laboratory)
end end
private private

@ -1,6 +1,6 @@
class SubjectListsController < ApplicationController class SubjectListsController < ApplicationController
def index def index
@results = SubjectSearchService.call(search_params, request.subdomain) @results = SubjectSearchService.call(search_params, current_laboratory)
end end
private private

@ -1,11 +1,11 @@
class ShixunSearchService < ApplicationService class ShixunSearchService < ApplicationService
include ElasticsearchAble include ElasticsearchAble
attr_reader :params, :subdomain attr_reader :params, :laboratory
def initialize(params, subdomain) def initialize(params, laboratory)
@params = params @params = params
@subdomain = subdomain @laboratory = laboratory
end end
def call def call
@ -37,8 +37,8 @@ class ShixunSearchService < ApplicationService
end end
## 云上实验室过滤 ## 云上实验室过滤
unless current_laboratory.main_site? unless laboratory.main_site?
@shixuns = @shixuns.joins(:laboratory_shixuns).where(laboratory_shixuns: { laboratory_id: current_laboratory.id }) @shixuns = @shixuns.joins(:laboratory_shixuns).where(laboratory_shixuns: { laboratory_id: @laboratory.id })
end end
# laboratory = Laboratory.find_by_subdomain(subdomain) # laboratory = Laboratory.find_by_subdomain(subdomain)

@ -1,11 +1,11 @@
class SubjectSearchService < ApplicationService class SubjectSearchService < ApplicationService
include ElasticsearchAble include ElasticsearchAble
attr_reader :params, :subdomain attr_reader :params, :laboratory
def initialize(params, subdomain) def initialize(params, laboratory)
@params = params @params = params
@subdomain = subdomain @laboratory = laboratory
end end
def call def call
@ -22,8 +22,8 @@ class SubjectSearchService < ApplicationService
# @subjects = @subjects.where(id: laboratory.subjects) if laboratory # @subjects = @subjects.where(id: laboratory.subjects) if laboratory
## 云上实验室过滤 ## 云上实验室过滤
unless current_laboratory.main_site? unless laboratory.main_site?
subjects = subjects.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id }) @subjects = @subjects.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: laboratory.id })
end end
Subject.search(keyword, search_options) Subject.search(keyword, search_options)

Loading…
Cancel
Save