添加合作者翻页问题

dev_forum
daiao 5 years ago
parent cd87ea9b5a
commit 250888abc5

@ -627,14 +627,17 @@ class ShixunsController < ApplicationController
user_name = "%#{params[:user_name].to_s.strip}%" user_name = "%#{params[:user_name].to_s.strip}%"
school_name = "%#{params[:school_name].to_s.strip}%" school_name = "%#{params[:school_name].to_s.strip}%"
if user_name.present? || school_name.present? if user_name.present? || school_name.present?
page = params[:page] || 1
limit = params[:limit] || 20
@users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND
LOWER(users.lastname) LIKE '#{user_name}' AND LOWER(schools.name) LIKE LOWER(users.lastname) LIKE '#{user_name}' AND LOWER(schools.name) LIKE
'#{school_name}'").distinct.page(page).per(limit) '#{school_name}'")
else else
@users = User.none @users = User.none
end end
page = params[:page] || 1
limit = params[:limit] || 20
@users_count = @users.count
@users = @users.page(page).per(limit)
end end
def shixun_members_added def shixun_members_added

@ -2,6 +2,7 @@
json.array! @users do |user| json.array! @users do |user|
json.user_id user.id json.user_id user.id
json.identify user.identity json.identify user.identity
json.nickname user.nickname json.nickname user.real_name
json.school_name user.school_name json.school_name user.school_name
end end
json.user_count @users_count
Loading…
Cancel
Save