From 3c206b52e35776b0732014ca9ef68f88d6163402 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 20 Feb 2020 18:39:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/search_service.rb | 3 ++- app/services/subject_search_service.rb | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/services/search_service.rb b/app/services/search_service.rb index a45875e07..72cd49c14 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -41,7 +41,8 @@ class SearchService < ApplicationService when 'shixun' then { where: { id: Laboratory.current.shixuns.where(public: 2, status: 2, fork_from: nil).or(Laboratory.current.shixuns.where(status: 2, id: User.current.shixuns)).pluck(:id) } } when 'subject' then - { where: { id: Laboratory.current.subjects.pluck(:id) } } + { where: { id: Laboratory.current.subjects.where(public: 2, status: 2) + .or( Laboratory.current.shixuns.where(status: 2, id: User.current.shixuns).pluck(:id)) } } when 'course' then { where: { id: Laboratory.current.all_courses.pluck(:id) } } else diff --git a/app/services/subject_search_service.rb b/app/services/subject_search_service.rb index 9c2776beb..dc5b069a5 100644 --- a/app/services/subject_search_service.rb +++ b/app/services/subject_search_service.rb @@ -17,9 +17,12 @@ class SubjectSearchService < ApplicationService if type == "mine" @subjects = @subjects.where(id: User.current.subjects).visible.unhidden else - @subjects = @subjects.visible.unhidden + if User.current.admin? || User.current.business? + @subjects = @subjects.unhidden + else + @subjects = @subjects.publiced.unhidden.or(@subjects.where(id: User.current.subjects)) + end end - Subject.search(keyword, search_options) end