From 51b01b3b93f2e630dfd2cbd99a6d22ba103f1516 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 15 Nov 2019 11:08:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=91=E4=B8=8A=E5=AE=9E=E9=AA=8C=E5=AE=A4?= =?UTF-8?q?=E7=9A=84=E9=80=89=E7=94=A8=E5=AE=9E=E8=AE=AD=E3=80=81=E9=80=89?= =?UTF-8?q?=E7=94=A8=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/laboratory.rb | 3 +++ app/services/shixun_search_service.rb | 3 +++ app/services/subject_search_service.rb | 3 +++ 3 files changed, 9 insertions(+) diff --git a/app/models/laboratory.rb b/app/models/laboratory.rb index 792f8620e..8b42c630f 100644 --- a/app/models/laboratory.rb +++ b/app/models/laboratory.rb @@ -9,7 +9,10 @@ class Laboratory < ApplicationRecord has_many :portal_images, dependent: :destroy has_many :laboratory_shixuns, dependent: :destroy + has_many :shixuns, through: :laboratory_shixuns, source: :shixun + has_many :laboratory_subjects, dependent: :destroy + has_many :subjects, through: :laboratory_subjects, source: :subject has_many :courses, dependent: :destroy has_many :competitions, dependent: :destroy diff --git a/app/services/shixun_search_service.rb b/app/services/shixun_search_service.rb index 911f341f8..6c6757069 100644 --- a/app/services/shixun_search_service.rb +++ b/app/services/shixun_search_service.rb @@ -35,6 +35,9 @@ class ShixunSearchService < ApplicationService @shixuns = @shixuns.where(trainee: params[:diff]) end + laboratory = Laboratory.find_by_subdomain(request.subdomain) + @shixuns = @shixuns.where(id: laboratory.shixuns) if laboratory + Shixun.search(keyword, search_options) end diff --git a/app/services/subject_search_service.rb b/app/services/subject_search_service.rb index f69c56c88..191b3e7a8 100644 --- a/app/services/subject_search_service.rb +++ b/app/services/subject_search_service.rb @@ -17,6 +17,9 @@ class SubjectSearchService < ApplicationService @subjects = Subject.visible.unhidden end + laboratory = Laboratory.find_by_subdomain(request.subdomain) + @subjects = @subjects.where(id: laboratory.subjects) if laboratory + Subject.search(keyword, search_options) end