|
|
|
@ -23,9 +23,10 @@ class ShixunSearchService < ApplicationService
|
|
|
|
|
if User.current.admin? || User.current.business? || !User.current.school_id
|
|
|
|
|
@shixuns = @shixuns.where(hidden: 0)
|
|
|
|
|
else
|
|
|
|
|
none_shixun_ids = ShixunSchool.where("school_id != #{User.current.school_id}").pluck(:shixun_id)
|
|
|
|
|
shixun_ids = ShixunSchool.where(school_id: User.current.school_id).pluck(:shixun_id)
|
|
|
|
|
shixun_ids = shixun_ids.reject(&:blank?).length == 0 ? -1 : shixun_ids.join(",")
|
|
|
|
|
|
|
|
|
|
@shixuns = @shixuns.where.not(id: none_shixun_ids).where(hidden: 0, status: 2, public: 2).or(@shixuns.where(id: User.current.shixuns))
|
|
|
|
|
@shixuns = @shixuns.where("use_scope = 1 or id in (#{shixun_ids})").unhidden.published.or(@shixuns.where(id: User.current.shixuns))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|