parent
b93b86b9a0
commit
5862c16c68
|
@ -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
|
||||
|
||||
# 判断精品课程是否可见,非课程成员无法查看私有课程
|
||||
|
|
Loading…
Reference in New Issue