From e99fdba290d96d03eedafb85c497a79c752b27c0 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 26 Sep 2019 15:56:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=B7=BB=E5=8A=A0=E5=90=88?= =?UTF-8?q?=E4=BD=9C=E8=80=85=E5=92=8C=E8=AF=BE=E5=A0=82=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=AD=A6=E7=94=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 8 +++++--- app/controllers/shixuns_controller.rb | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index d2c9f88d2..4ce1d7487 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -922,14 +922,16 @@ class CoursesController < ApplicationController school_name = params[:school_name] # REDO:Extension - @users = User.joins(user_extension: :school) - .where("CONCAT(users.lastname, users.firstname) like ? and schools.name like ?", "%#{name}%", "%#{school_name}%") + @users = User.where(status: User::STATUS_ACTIVE) + @users = @users.where("concat(users.lastname, users.firstname) like '%#{name}%'") if name.present? + # REDO:Extension + @users = @users.joins(user_extension: :school).where("schools.name like '%#{school_name}%'") if school_name.present? @users_count = @users.size limit = params[:limit] || 20 page = params[:page] || 1 - @users = @users.page(page).per(limit) + @users = @users.includes(user_extension: :school).page(page).per(limit) end # 申请加入课堂 diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 8a120d6bd..07107b91f 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -890,9 +890,10 @@ class ShixunsController < ApplicationController 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(concat(users.lastname, users.firstname)) LIKE ? or users.phone like ?) - AND LOWER(schools.name) LIKE ?", user_name, user_name, school_name) + @users = User.where("users.id not in #{member_ids} AND users.status = 1 AND + (LOWER(concat(users.lastname, users.firstname)) LIKE ? or users.phone like ?)", + user_name, user_name) + @users = @users.joins(user_extension: :school).where("schools.name like '%#{school_name}%'") if params[:school_name].present? else @users = User.none end