Merge branches 'dev_aliyun' and 'dev_cs' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_cs
commit
664777d571
@ -0,0 +1,2 @@
|
|||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
@ -0,0 +1,3 @@
|
|||||||
|
// Place all the styles related to the subject_lists controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,6 @@
|
|||||||
|
class LibraryTagsController < ApplicationController
|
||||||
|
def index
|
||||||
|
library_tags = LibraryTag.all
|
||||||
|
render_ok(library_tags: library_tags.as_json(only: %i[id name]), count: library_tags.size)
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,10 @@
|
|||||||
|
class SubjectListsController < ApplicationController
|
||||||
|
def index
|
||||||
|
@results = SubjectSearchService.call(search_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def search_params
|
||||||
|
params.permit(:keyword, :type, :page, :limit, :order, :sort)
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,2 @@
|
|||||||
|
module SubjectListsHelper
|
||||||
|
end
|
@ -0,0 +1,42 @@
|
|||||||
|
class SubjectSearchService < ApplicationService
|
||||||
|
include ElasticsearchAble
|
||||||
|
|
||||||
|
attr_reader :params
|
||||||
|
|
||||||
|
def initialize(params)
|
||||||
|
@params = params
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
# 全部实训/我的实训
|
||||||
|
type = params[:type] || "all"
|
||||||
|
|
||||||
|
if type == "mine"
|
||||||
|
@subjects = User.current.shixuns.visible.unhidden
|
||||||
|
else
|
||||||
|
@subjects = Subject.visible.unhidden
|
||||||
|
end
|
||||||
|
|
||||||
|
Subject.search(keyword, search_options)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def search_options
|
||||||
|
model_options = {
|
||||||
|
includes: [ user: { user_extension: :school } ]
|
||||||
|
}
|
||||||
|
model_options.merge!(where: { id: @subjects.pluck(:id) })
|
||||||
|
model_options.merge!(order: {sort_type => sort_str})
|
||||||
|
model_options.merge!(default_options)
|
||||||
|
model_options
|
||||||
|
end
|
||||||
|
|
||||||
|
def sort_str
|
||||||
|
params[:order] || "desc"
|
||||||
|
end
|
||||||
|
|
||||||
|
def sort_type
|
||||||
|
params[:sort] || "myshixuns_count"
|
||||||
|
end
|
||||||
|
end
|
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
json.graduation_requirements @graduation_requirements, partial: 'ecs/ec_graduation_requirements/shared/ec_graduation_requirement', as: :ec_graduation_requirement
|
json.graduation_requirements @graduation_requirements, partial: 'ecs/ec_graduation_requirements/shared/ec_graduation_requirement', as: :ec_graduation_requirement
|
||||||
json.training_subitems @training_subitems, partial: 'ecs/ec_training_subitems/shared/ec_training_subitem', as: :ec_training_subitem
|
json.training_subitems @training_subitems, partial: 'ecs/ec_training_objectives/shared/ec_training_subitem', as: :ec_training_subitem
|
||||||
json.requirement_support_objectives @requirement_support_objectives, partial: 'ecs/requirement_support_objectives/shared/requirement_support_objective', as: :requirement_support_objective
|
json.requirement_support_objectives @requirement_support_objectives, partial: 'ecs/requirement_support_objectives/shared/requirement_support_objective', as: :requirement_support_objective
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
json.subjects_count @results.total_count
|
||||||
|
|
||||||
|
json.subject_list do
|
||||||
|
json.array! @results.with_highlights(multiple: true) do |obj, highlights|
|
||||||
|
json.merge! obj.to_searchable_json
|
||||||
|
|
||||||
|
# 去除开头标点符号
|
||||||
|
reg = /^[,。?:;‘’!“”—……、]/
|
||||||
|
# 附件的替换
|
||||||
|
atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/
|
||||||
|
|
||||||
|
highlights[:description]&.first&.sub!(reg, '')
|
||||||
|
highlights[:description]&.map{|des| des.gsub!(atta_reg, '')}
|
||||||
|
highlights[:content]&.first&.sub!(reg, '')
|
||||||
|
highlights[:content]&.map{|des| des.gsub!(atta_reg, '')}
|
||||||
|
|
||||||
|
json.title highlights.delete(:name)&.join('...') || obj.searchable_title
|
||||||
|
json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.sub!(atta_reg, '')
|
||||||
|
|
||||||
|
json.content highlights
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,9 @@
|
|||||||
|
class AddLibraryTagData < ActiveRecord::Migration[5.2]
|
||||||
|
def up
|
||||||
|
execute 'INSERT INTO library_tags(id, name) VALUES(4, "高校案例")'
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
execute 'DELETE FROM library_tags WHERE id = 4 and name = "高校案例"'
|
||||||
|
end
|
||||||
|
end
|
@ -1,36 +1,37 @@
|
|||||||
import React,{ Component } from "react";
|
import React,{ Component } from "react";
|
||||||
import './css/moopCases.css'
|
import './css/moopCases.css'
|
||||||
import '../courses/css/Courses.css'
|
import '../courses/css/Courses.css'
|
||||||
|
|
||||||
class CaseTags extends Component{
|
class CaseTags extends Component{
|
||||||
constructor(props){
|
constructor(props){
|
||||||
super(props);
|
super(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
let { tags } = this.props;
|
let { tags } = this.props;
|
||||||
return(
|
return(
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{
|
{
|
||||||
tags && tags.map((item,key)=>{
|
tags && tags.map((item,key)=>{
|
||||||
return(
|
return(
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{
|
{
|
||||||
item.name == "获奖案例" ?
|
item.name == "获奖案例" ?
|
||||||
<span key={key} className="edu-filter-btn fl cdefault edu-activity-red ml10">{item.name}</span>
|
<span key={key} className="edu-filter-btn fl cdefault edu-activity-red ml10">{item.name}</span>
|
||||||
:
|
:
|
||||||
item.name == "入库案例" ?
|
item.name == "入库案例" ?
|
||||||
<span key={key} className="edu-filter-btn fl cdefault edu-activity-blue ml10">{item.name}</span>
|
<span key={key} className="edu-filter-btn fl cdefault edu-activity-blue ml10">{item.name}</span>
|
||||||
:
|
:item.name =='企业案例'?
|
||||||
<span key={key} className="edu-filter-btn fl cdefault edu-activity-orange-sub ml10">{item.name}</span>
|
<span key={key} className="edu-filter-btn fl cdefault edu-activity-orange-sub ml10">{item.name}</span>
|
||||||
}
|
: <span key={key} className="edu-filter-btn fl cdefault edu-activity-36c53c-sub ml10">{item.name}</span>
|
||||||
</React.Fragment>
|
}
|
||||||
)
|
</React.Fragment>
|
||||||
})
|
)
|
||||||
}
|
})
|
||||||
</React.Fragment>
|
}
|
||||||
|
</React.Fragment>
|
||||||
)
|
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
export default CaseTags;
|
export default CaseTags;
|
@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe SubjectListsController, type: :controller do
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,15 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes
|
||||||
|
# the SubjectListsHelper. For example:
|
||||||
|
#
|
||||||
|
# describe SubjectListsHelper do
|
||||||
|
# describe "string concat" do
|
||||||
|
# it "concats two strings with spaces" do
|
||||||
|
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
RSpec.describe SubjectListsHelper, type: :helper do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in new issue