From 5862c16c680d503e41d6e04d431d3f70a1e95f84 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 18 Jan 2016 17:36:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=B2=BE=E5=93=81=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E6=8E=A8=E8=8D=90=20=E8=BF=87=E6=BB=A4=E6=8E=89?= =?UTF-8?q?=E7=A7=81=E6=9C=89=E8=AF=BE=E7=A8=8B=20=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E6=8E=89=E5=B7=B2=E5=88=A0=E9=99=A4=E7=9A=84=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 780d73de2..712f2d075 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -21,16 +21,10 @@ module CoursesHelper # 查询符合条件的精品课程 def find_excelletn_course keywords, course # 用新课程名去匹配精品课程中按课程名和Tag名 - if !course.is_public? && !User.current.member_of_course?(course) - sql = "SELECT distinct c.* FROM `courses` c, tags t, taggings ts where t.id = ts.tag_id and ts.taggable_id = c.id and c.is_excellent = 1 and is_delete = 0 and + sql = "SELECT distinct c.* FROM `courses` c, tags t, taggings ts where t.id = ts.tag_id and ts.taggable_id = c.id and c.is_excellent = 1 and is_delete = 0 and ts.taggable_type = 'Course' and (t.name like '%#{keywords}%'or c.name like '%#{keywords}%')" - resultSetTag = Course.find_by_sql(sql) - else - sql = "SELECT distinct c.* FROM `courses` c, tags t, taggings ts where t.id = ts.tag_id and ts.taggable_id = c.id and c.is_excellent = 1 and is_delete = 0 and - ts.taggable_type = 'Course' and (t.name like '%#{keywords}%'or c.name like '%#{keywords}%') ORDER BY c.updated_at desc limit 0,5;" - resultSetTag = Course.visible.find_by_sql(sql) - end - + resultSetTag = Course.find_by_sql(sql).select{|e_course| e_course.is_public ==1 unless User.current.member_of_course?(e_course)}.first(3) + resultSetTag end # 判断精品课程是否可见,非课程成员无法查看私有课程