|
|
@ -7,9 +7,18 @@ class DiscussesController < ApplicationController
|
|
|
|
page = params[:page].to_i
|
|
|
|
page = params[:page].to_i
|
|
|
|
offset = page * LIMIT
|
|
|
|
offset = page * LIMIT
|
|
|
|
# 总数,分页使用
|
|
|
|
# 总数,分页使用
|
|
|
|
@disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count
|
|
|
|
if current_user.admin?
|
|
|
|
@discusses = Discuss.limit(LIMIT).where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).
|
|
|
|
@disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count
|
|
|
|
includes(:user, :praise_tread).offset(offset)
|
|
|
|
@discusses = Discuss.limit(LIMIT).where(:dis_id => dis_id, :dis_type => dis_type,
|
|
|
|
|
|
|
|
:root_id => nil).includes(:user, :praise_tread).offset(offset)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and
|
|
|
|
|
|
|
|
(hidden = :hidden or user_id = :user_id)",
|
|
|
|
|
|
|
|
{dis_id: dis_id, dis_type: dis_type, hidden: false, user_id: current_user.id})
|
|
|
|
|
|
|
|
@disscuss_count = disscusses.count
|
|
|
|
|
|
|
|
@discusses = disscusses.limit(LIMIT).includes(:user, :praise_tread).offset(offset)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@current_user = current_user
|
|
|
|
@current_user = current_user
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|