|
|
|
@ -14,16 +14,18 @@ class ShixunSearchService < ApplicationService
|
|
|
|
|
# 状态:已发布/未发布
|
|
|
|
|
status = params[:status] || "all"
|
|
|
|
|
|
|
|
|
|
@shixuns = laboratory.shixuns.none_closed
|
|
|
|
|
|
|
|
|
|
# 超级管理员用户显示所有未隐藏的实训、非管理员显示所有已发布的实训(对本单位公开且未隐藏未关闭)
|
|
|
|
|
if type == "mine"
|
|
|
|
|
@shixuns = User.current.shixuns.none_closed
|
|
|
|
|
@shixuns = @shixuns.where(id: User.current.shixuns)
|
|
|
|
|
else
|
|
|
|
|
if User.current.admin? || User.current.business?
|
|
|
|
|
@shixuns = Shixun.none_closed.where(hidden: 0)
|
|
|
|
|
@shixuns = @shixuns.where(hidden: 0)
|
|
|
|
|
else
|
|
|
|
|
none_shixun_ids = ShixunSchool.where("school_id != #{User.current.school_id}").pluck(:shixun_id)
|
|
|
|
|
|
|
|
|
|
@shixuns = Shixun.where.not(id: none_shixun_ids).none_closed.where(hidden: 0)
|
|
|
|
|
@shixuns = @shixuns.where.not(id: none_shixun_ids).where(hidden: 0)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -36,17 +38,6 @@ class ShixunSearchService < ApplicationService
|
|
|
|
|
@shixuns = @shixuns.where(trainee: params[:diff])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
## 云上实验室过滤
|
|
|
|
|
if laboratory.main_site?
|
|
|
|
|
not_shixun_ids = Shixun.joins(:laboratory_shixuns).where("laboratory_shixuns.laboratory_id != #{laboratory.id}")
|
|
|
|
|
@shixuns = @shixuns.where.not(id: not_shixun_ids)
|
|
|
|
|
else
|
|
|
|
|
@shixuns = @shixuns.joins(:laboratory_shixuns).where(laboratory_shixuns: { laboratory_id: laboratory.id })
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# laboratory = Laboratory.find_by_subdomain(subdomain)
|
|
|
|
|
# @shixuns = @shixuns.where(id: laboratory.shixuns) if laboratory
|
|
|
|
|
|
|
|
|
|
Shixun.search(keyword, search_options)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|