|
|
@ -62,15 +62,12 @@ class CoursesController < ApplicationController
|
|
|
|
if @order == "mine"
|
|
|
|
if @order == "mine"
|
|
|
|
@courses = Course.joins(:course_members)
|
|
|
|
@courses = Course.joins(:course_members)
|
|
|
|
.where("is_delete = 0 AND is_hidden = 0 AND course_members.user_id = ?", @user.id)
|
|
|
|
.where("is_delete = 0 AND is_hidden = 0 AND course_members.user_id = ?", @user.id)
|
|
|
|
.order("courses.id = 1309 DESC, courses.#{order_str} DESC")
|
|
|
|
|
|
|
|
elsif @order == "created_at"
|
|
|
|
elsif @order == "created_at"
|
|
|
|
# REDO:Extension
|
|
|
|
# REDO:Extension
|
|
|
|
@courses = Course.where(is_delete: 0, is_hidden: 0, is_end: 0)
|
|
|
|
@courses = Course.where(is_delete: 0, is_hidden: 0, is_end: 0)
|
|
|
|
.order("courses.id = 1309 DESC, courses.#{order_str} DESC")
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
# REDO:Extension
|
|
|
|
# REDO:Extension
|
|
|
|
@courses = Course.where(is_delete: 0, is_hidden: 0)
|
|
|
|
@courses = Course.where(is_delete: 0, is_hidden: 0)
|
|
|
|
.order("courses.id = 1309 DESC, courses.#{order_str} DESC")
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 根据搜索关键字进一步筛选
|
|
|
|
# 根据搜索关键字进一步筛选
|
|
|
@ -89,14 +86,15 @@ class CoursesController < ApplicationController
|
|
|
|
@courses = @courses.joins(:school, course_members: :user)
|
|
|
|
@courses = @courses.joins(:school, course_members: :user)
|
|
|
|
.where("#{sql}", keyword: "%#{params[:search]}%").distinct
|
|
|
|
.where("#{sql}", keyword: "%#{params[:search]}%").distinct
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@courses_count = @courses.size
|
|
|
|
@courses_count = @courses.count("courses.id")
|
|
|
|
|
|
|
|
@courses = @courses.order("courses.id = 1309 DESC, courses.#{order_str} DESC")
|
|
|
|
|
|
|
|
|
|
|
|
# 分页
|
|
|
|
# 分页
|
|
|
|
page = params[:page] || 1
|
|
|
|
page = params[:page] || 1
|
|
|
|
limit = params[:limit] || 16
|
|
|
|
limit = params[:limit] || 16
|
|
|
|
|
|
|
|
|
|
|
|
@courses = @courses.page(page).per(limit)
|
|
|
|
@courses = @courses.page(page).per(limit)
|
|
|
|
@courses = @courses.preload(:school, teacher: :user_extension)
|
|
|
|
@courses = @courses.preload(:school, :none_hidden_course_modules, teacher: :user_extension)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def visits_plus_one
|
|
|
|
def visits_plus_one
|
|
|
|