Merge branch 'dev_aliyun' into dev_cxt

dev_ec
cxt 5 years ago
commit a8fc4d674c

@ -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

@ -5,6 +5,6 @@ class ShixunListsController < ApplicationController
private
def search_params
params.permit(:keyword, :type, :page, :limit, :order, :type, :status, :diff)
params.permit(:keyword, :type, :page, :limit, :order, :status, :diff)
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

@ -18,7 +18,9 @@ module Searchable::Subject
def search_data
{
name: name,
description: Util.extract_content(description)[0..Searchable::MAXIMUM_LENGTH]
description: Util.extract_content(description)[0..Searchable::MAXIMUM_LENGTH],
shixuns_count: shixuns_count,
myshixuns_count: member_count,
}.merge!(searchable_user_data)
.merge!(searchable_stages_data)
end
@ -45,7 +47,8 @@ module Searchable::Subject
visits_count: visits,
stage_count: stages_count,
stage_shixuns_count: stage_shixuns_count,
shixuns_count: shixuns_count
shixuns_count: shixuns_count,
myshixuns_count: member_count
}
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.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

@ -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

@ -174,6 +174,7 @@ Rails.application.routes.draw do
end
end
resources :subject_lists
resources :shixun_lists
resources :shixuns, param: :identifier do
@ -795,6 +796,7 @@ Rails.application.routes.draw do
end
resources :libraries, only: [:index, :show, :create, :update, :destroy]
resources :library_tags, only: [:index]
scope module: :projects do
resources :project_applies, only: [:create]

@ -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

@ -83,9 +83,9 @@ export function initAxiosInterceptors(props) {
}
config.url = `${proxy}${url}`;
if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?debug=${'student'}`
config.url = `${config.url}?debug=${debugType}`
} else {
config.url = `${config.url}&debug=${'student'}`
config.url = `${config.url}&debug=${debugType}`
}
} else {
// 加api前缀

@ -274,7 +274,7 @@ class GraduateTaskItem extends Component{
<p className="color-grey mt16 fl">
<span className="mr50">
{/* <a href="/users/innov" className="panel-name-small hide fl mr15 mr30 color-grey3">{discussMessage.author.name}</a> */}
{ discussMessage.author && <span className="mr15 color-grey-3">{discussMessage.author}</span> }
{discussMessage.commit_count===undefined?"":<span className="mr15 color-grey9 font-14">{discussMessage.commit_count} 已交</span>}
{discussMessage.uncommit_count===undefined?"":<span className="mr15 color-grey9 font-14">{discussMessage.uncommit_count} 未交</span>}
{/*<span className="mr15 color-grey9">{discussMessage.replies_count} 3 未评</span>*/}

@ -489,6 +489,9 @@ class PathDetailIndex extends Component{
.padding40-20-30{
padding:40px 20px 30px;
}
.pathDetailIndex .markdown-body > p {
line-height: 28px;
}
`
}
</style>
@ -501,7 +504,7 @@ class PathDetailIndex extends Component{
loadtype={loadtype}
>
</Modals>
<div className="newMain clearfix">
<div className="newMain clearfix pathDetailIndex">
<DetailTop {...this.state} {...this.props} getdatasindex={(key)=>this.getdatasindex(key)} getMenuItemsindex={(key,status)=>this.getMenuItemsindex(key,status)} getlistdatas={()=>this.getlistdatas()}></DetailTop>
<div className="educontent clearfix mb80">
<div className="with65 fl">

@ -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…
Cancel
Save