parent
1be0a918a6
commit
f38e01edaf
|
@ -364,7 +364,7 @@ class ForumSectionsService
|
||||||
return {status: -1, message: "请登录"} unless check_user_permission(current_user, params[:id])
|
return {status: -1, message: "请登录"} unless check_user_permission(current_user, params[:id])
|
||||||
select_section_ids = [params[:id]]
|
select_section_ids = [params[:id]]
|
||||||
unless @forum_section.parent_id.present?
|
unless @forum_section.parent_id.present?
|
||||||
children_forums = @forum_section.children_forum.pluck(:id)
|
children_forums = @forum_section.child_ids
|
||||||
select_section_ids = select_section_ids + children_forums
|
select_section_ids = select_section_ids + children_forums
|
||||||
end
|
end
|
||||||
select_section_ids.uniq
|
select_section_ids.uniq
|
||||||
|
@ -389,7 +389,7 @@ class ForumSectionsService
|
||||||
else
|
else
|
||||||
memo_min_sections = memo.memo_forums.first
|
memo_min_sections = memo.memo_forums.first
|
||||||
end
|
end
|
||||||
memo_last_section = memo_min_sections.forum_section
|
memo_last_section = memo_min_sections&.forum_section
|
||||||
|
|
||||||
memo_list = {
|
memo_list = {
|
||||||
memo_id: memo.id,
|
memo_id: memo.id,
|
||||||
|
@ -416,7 +416,7 @@ class ForumSectionsService
|
||||||
|
|
||||||
select_section_ids = [params[:id]]
|
select_section_ids = [params[:id]]
|
||||||
unless @forum_section.parent_id.present?
|
unless @forum_section.parent_id.present?
|
||||||
children_forums = @forum_section.children_forum.pluck(:id)
|
children_forums = @forum_section.child_ids
|
||||||
select_section_ids = select_section_ids + children_forums
|
select_section_ids = select_section_ids + children_forums
|
||||||
end
|
end
|
||||||
select_section_ids.uniq
|
select_section_ids.uniq
|
||||||
|
@ -462,7 +462,7 @@ class ForumSectionsService
|
||||||
|
|
||||||
select_section_ids = [params[:id]]
|
select_section_ids = [params[:id]]
|
||||||
unless @forum_section.parent_id.present?
|
unless @forum_section.parent_id.present?
|
||||||
children_forums = @forum_section.children_forum.pluck(:id)
|
children_forums = @forum_section.child_ids
|
||||||
select_section_ids = select_section_ids + children_forums
|
select_section_ids = select_section_ids + children_forums
|
||||||
end
|
end
|
||||||
select_section_ids.uniq
|
select_section_ids.uniq
|
||||||
|
@ -473,7 +473,7 @@ class ForumSectionsService
|
||||||
offset = page * LIMIT
|
offset = page * LIMIT
|
||||||
#全部的父帖子
|
#全部的父帖子
|
||||||
memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq
|
memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq
|
||||||
memos_all = Memo.where(hidden: false,parent_id: nil, id: memo_forum_section_ids).order("created_at desc")
|
memos_all = Memo.where(hidden: false,parent_id: nil, forum_section_id: select_section_ids).order("created_at desc")
|
||||||
# memos_all = Memo.where(hidden: false, parent_id: nil).joins(:memo_forums).where("memo_forums.forum_id in (#{select_section_ids.join(",")})")
|
# memos_all = Memo.where(hidden: false, parent_id: nil).joins(:memo_forums).where("memo_forums.forum_id in (#{select_section_ids.join(",")})")
|
||||||
if params[:type].present?
|
if params[:type].present?
|
||||||
if params[:type] == "sticky"
|
if params[:type] == "sticky"
|
||||||
|
@ -499,7 +499,7 @@ class ForumSectionsService
|
||||||
else
|
else
|
||||||
memo_min_sections = memo.memo_forums.first
|
memo_min_sections = memo.memo_forums.first
|
||||||
end
|
end
|
||||||
memo_last_section = memo_min_sections.forum_section
|
memo_last_section = memo_min_sections&.forum_section
|
||||||
|
|
||||||
memo_list = {
|
memo_list = {
|
||||||
memo_id: memo.id,
|
memo_id: memo.id,
|
||||||
|
|
|
@ -596,7 +596,14 @@ class MemosService
|
||||||
|
|
||||||
page = params[:page].to_i > 0 ? (params[:page].to_i - 1) : 0
|
page = params[:page].to_i > 0 ? (params[:page].to_i - 1) : 0
|
||||||
offset = page * LIMIT
|
offset = page * LIMIT
|
||||||
all_memos = forum_section.memos.posts
|
all_memos =
|
||||||
|
if forum_section.is_root?
|
||||||
|
forum_section_ids = forum_section.child_ids << forum_section.id
|
||||||
|
Rails.logger.info "######### forum_section_ids: #{forum_section_ids}"
|
||||||
|
Memo.where(forum_section_id: forum_section_ids)
|
||||||
|
else
|
||||||
|
forum_section.memos.posts
|
||||||
|
end
|
||||||
select_type = params[:select_type]
|
select_type = params[:select_type]
|
||||||
case select_type.to_s
|
case select_type.to_s
|
||||||
when "is_fine"
|
when "is_fine"
|
||||||
|
@ -729,6 +736,7 @@ class MemosService
|
||||||
|
|
||||||
|
|
||||||
def check_banned_permission current_user, memo_id
|
def check_banned_permission current_user, memo_id
|
||||||
|
return true if current_user&.admin?
|
||||||
forum_id = MemoForum&.where(is_children: false, memo_id: memo_id)&.first.try(:forum_id).to_s
|
forum_id = MemoForum&.where(is_children: false, memo_id: memo_id)&.first.try(:forum_id).to_s
|
||||||
user_banned_permission current_user, forum_id
|
user_banned_permission current_user, forum_id
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue