commit
01e1230691
@ -0,0 +1,10 @@
|
|||||||
|
class ShixunListsController < ApplicationController
|
||||||
|
def index
|
||||||
|
@results = ShixunSearchService.call(search_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def search_params
|
||||||
|
params.permit(:keyword, :type, :page, :limit, :order, :type, :status, :diff)
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,56 @@
|
|||||||
|
class ShixunSearchService < ApplicationService
|
||||||
|
include ElasticsearchAble
|
||||||
|
|
||||||
|
attr_reader :params
|
||||||
|
|
||||||
|
def initialize(params)
|
||||||
|
@params = params
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
# 全部实训/我的实训
|
||||||
|
type = params[:type] || "all"
|
||||||
|
# 状态:已发布/未发布
|
||||||
|
status = params[:status] || "all"
|
||||||
|
|
||||||
|
# 超级管理员用户显示所有未隐藏的实训、非管理员显示所有已发布的实训(对本单位公开且未隐藏未关闭)
|
||||||
|
if type == "mine"
|
||||||
|
@shixuns = User.current.shixuns.none_closed
|
||||||
|
else
|
||||||
|
if User.current.admin? || User.current.business?
|
||||||
|
@shixuns = Shixun.none_closed.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)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
unless status == "all"
|
||||||
|
@shixuns = status == "published" ? @shixuns.where(status: 2) : @shixuns.where(status: [0, 1])
|
||||||
|
end
|
||||||
|
|
||||||
|
## 筛选 难度
|
||||||
|
if params[:diff].present? && params[:diff].to_i != 0
|
||||||
|
@shixuns = @shixuns.where(trainee: params[:diff])
|
||||||
|
end
|
||||||
|
|
||||||
|
Shixun.search(keyword, search_options)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def search_options
|
||||||
|
model_options = {
|
||||||
|
includes: [ :shixun_info, :challenges, :subjects, user: { user_extension: :school } ]
|
||||||
|
}
|
||||||
|
model_options.merge!(where: { id: @shixuns.pluck(:id) })
|
||||||
|
model_options.merge!(order: {"myshixuns_count" => sort_str})
|
||||||
|
model_options.merge!(default_options)
|
||||||
|
model_options
|
||||||
|
end
|
||||||
|
|
||||||
|
def sort_str
|
||||||
|
params[:order] || "desc"
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,22 @@
|
|||||||
|
json.shixuns_count @results.total_count
|
||||||
|
|
||||||
|
json.shixun_list do
|
||||||
|
json.array! @results.with_highlights(multiple: true) do |obj, highlights|
|
||||||
|
json.merge! obj.to_searchable_json
|
||||||
|
json.challenge_names obj.challenges.pluck(:subject)
|
||||||
|
|
||||||
|
# 去除开头标点符号
|
||||||
|
reg = /^[,。?:;‘’!“”—……、]/
|
||||||
|
highlights[:description]&.first&.sub!(reg, '')
|
||||||
|
highlights[:content]&.first&.sub!(reg, '')
|
||||||
|
|
||||||
|
json.title highlights.delete(:name)&.join('...') || obj.searchable_title
|
||||||
|
json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]
|
||||||
|
|
||||||
|
json.content highlights
|
||||||
|
json.level level_to_s(obj.trainee)
|
||||||
|
json.subjects obj.subjects.uniq do |subject|
|
||||||
|
json.(subject, :id, :name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,250 @@
|
|||||||
|
.searchinput{
|
||||||
|
width: 800px;
|
||||||
|
margin-top: 53px;
|
||||||
|
}
|
||||||
|
.newshixunheadersear{
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.packinput .ant-input{
|
||||||
|
height: 55px;
|
||||||
|
width:663px !important;
|
||||||
|
font-size: 14px;
|
||||||
|
/*color: #681616 !important;*/
|
||||||
|
border-color: #E1EDF8 !important;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.packinput .ant-input-group-addon .ant-btn{
|
||||||
|
width:137px !important;
|
||||||
|
font-size: 18px;
|
||||||
|
height: 53px;
|
||||||
|
background:rgba(76,172,255,1);
|
||||||
|
|
||||||
|
}
|
||||||
|
.tabtitle{
|
||||||
|
height: 62px !important;
|
||||||
|
box-shadow: 3px 10px 21px 0px rgba(76, 76, 76, 0.15);
|
||||||
|
border-radius: 6px;
|
||||||
|
background: #fff;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.tabtitles2{
|
||||||
|
background: #fff;
|
||||||
|
height: 62px !important;
|
||||||
|
width: 1200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabtitless{
|
||||||
|
height: 62px !important;
|
||||||
|
line-height: 62px !important;
|
||||||
|
|
||||||
|
}
|
||||||
|
.tabtitle1{
|
||||||
|
|
||||||
|
}
|
||||||
|
.tabtitle2{
|
||||||
|
margin-left: 30px !important;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.counttit{
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.counttittext{
|
||||||
|
text-align: left;
|
||||||
|
width: 1200px;
|
||||||
|
height: 18px;
|
||||||
|
color: #888888;
|
||||||
|
font-size: 13px;
|
||||||
|
margin-top: 24px;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
.counttittexts{
|
||||||
|
color: #4CACFF !important;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mainx{
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 17px;
|
||||||
|
}
|
||||||
|
.project-packages-list{
|
||||||
|
|
||||||
|
}
|
||||||
|
.project-package-item{
|
||||||
|
display: -webkit-flex;
|
||||||
|
display: flex;
|
||||||
|
flex-direction:column;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 20px;
|
||||||
|
background: white;
|
||||||
|
/* box-shadow: 1px 3px 3px 1px rgba(156,156,156,0.16); */
|
||||||
|
|
||||||
|
}
|
||||||
|
.xuxianpro{
|
||||||
|
height: 20px;
|
||||||
|
border-bottom: 1px dashed;
|
||||||
|
border-color: #EAEAEA;
|
||||||
|
margin-bottom: 18px;
|
||||||
|
}
|
||||||
|
.magr11{
|
||||||
|
margin-top: 11px;
|
||||||
|
}
|
||||||
|
.highlight{
|
||||||
|
color: #4CACFF;
|
||||||
|
}
|
||||||
|
.fonttext{
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fontextcolor{
|
||||||
|
color: #777777;
|
||||||
|
}
|
||||||
|
.tzbq{
|
||||||
|
margin-left: 68px;
|
||||||
|
}
|
||||||
|
.tzbqx{
|
||||||
|
/* margin-left: 24px; */
|
||||||
|
}
|
||||||
|
.bjyss{
|
||||||
|
background: #F8F8F8;
|
||||||
|
}
|
||||||
|
.zj{
|
||||||
|
overflow:hidden;
|
||||||
|
text-overflow:ellipsis;
|
||||||
|
white-space:nowrap
|
||||||
|
}
|
||||||
|
.ziticor{
|
||||||
|
color: #777777;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
.foohter{
|
||||||
|
margin-top: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction:row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maxwidth1100{
|
||||||
|
max-width: 1100px;
|
||||||
|
overflow:hidden;
|
||||||
|
text-overflow:ellipsis;
|
||||||
|
white-space:nowrap;
|
||||||
|
font-size: 18px !important;
|
||||||
|
font-weight: 500;
|
||||||
|
color: rgba(51,51,51,1) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.newshixunmodelmidfont{
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 400;
|
||||||
|
color: #999999;
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-left: 30px;
|
||||||
|
max-width: 1100px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newshixunmodelbotfont{
|
||||||
|
font-size:12px;
|
||||||
|
font-weight:400;
|
||||||
|
color:rgba(102,102,102,1);
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-left: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newshixunlist{
|
||||||
|
max-height:227px;
|
||||||
|
width: 1200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xuxianpro {
|
||||||
|
height: 20px;
|
||||||
|
border-bottom: 1px dashed;
|
||||||
|
border-color: #eaeaea;
|
||||||
|
margin-bottom: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newshixunpd030{
|
||||||
|
padding: 0px 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd303010{
|
||||||
|
padding: 30px 30px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newshixunfont12{
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(76,172,255,1);
|
||||||
|
line-height: 21px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newshixunmode{
|
||||||
|
width: 100px;
|
||||||
|
height: 38px;
|
||||||
|
border-radius: 3px;
|
||||||
|
border: 1px solid rgba(191,191,191,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ntopsj {
|
||||||
|
position: absolute;
|
||||||
|
top: -4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nyslbottomsj {
|
||||||
|
position: absolute;
|
||||||
|
bottom: -6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inherits .ant-dropdown-menu-item{
|
||||||
|
cursor: inherit !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menus{
|
||||||
|
width: 91px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newshixunmodelbotfont span{
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.minhegiht300{
|
||||||
|
min-height: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newshixunlist:hover{
|
||||||
|
box-shadow: 1px 6px 16px rgba(156,156,156,0.16);
|
||||||
|
opacity: 1;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newshixun500{
|
||||||
|
max-width: 500px;
|
||||||
|
overflow: hidden;
|
||||||
|
-o-text-overflow: ellipsis;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mt3 {
|
||||||
|
margin-top: 3px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight{
|
||||||
|
color: #4CACFF;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in new issue