From 250888abc58fcf60f0c66fe9f7097d13523ee419 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 15:15:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E4=BD=9C=E8=80=85?= =?UTF-8?q?=E7=BF=BB=E9=A1=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 27 ++++++++++--------- .../shixuns/add_collaborators.json.jbuilder | 5 ++-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index df6de775a..32a2c6ef9 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -623,19 +623,22 @@ class ShixunsController < ApplicationController end def add_collaborators - member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")" - user_name = "%#{params[:user_name].to_s.strip}%" - school_name = "%#{params[:school_name].to_s.strip}%" - 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 + member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")" + user_name = "%#{params[:user_name].to_s.strip}%" + school_name = "%#{params[:school_name].to_s.strip}%" + if user_name.present? || school_name.present? + @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 - '#{school_name}'").distinct.page(page).per(limit) - else - @users = User.none - end - end + '#{school_name}'") + else + @users = User.none + end + page = params[:page] || 1 + limit = params[:limit] || 20 + @users_count = @users.count + @users = @users.page(page).per(limit) + + end def shixun_members_added raise("user_ids 不能为空!") if params[:user_ids].blank? diff --git a/app/views/shixuns/add_collaborators.json.jbuilder b/app/views/shixuns/add_collaborators.json.jbuilder index ab4716681..e77fd41a0 100644 --- a/app/views/shixuns/add_collaborators.json.jbuilder +++ b/app/views/shixuns/add_collaborators.json.jbuilder @@ -2,6 +2,7 @@ json.array! @users do |user| json.user_id user.id json.identify user.identity - json.nickname user.nickname + json.nickname user.real_name json.school_name user.school_name -end \ No newline at end of file +end +json.user_count @users_count \ No newline at end of file