fix: concat nickname
This commit is contained in:
		
							parent
							
								
									d5a65112ca
								
							
						
					
					
						commit
						a5b98bcad4
					
				| 
						 | 
					@ -32,7 +32,7 @@ class Admins::AuthSchoolsController < Admins::BaseController
 | 
				
			||||||
  def search_manager
 | 
					  def search_manager
 | 
				
			||||||
    school = School.find_by(id: params[:school_id])
 | 
					    school = School.find_by(id: params[:school_id])
 | 
				
			||||||
    user_ids = school&.ec_school_users&.pluck(:user_id)
 | 
					    user_ids = school&.ec_school_users&.pluck(:user_id)
 | 
				
			||||||
    @users = User.where.not(id: user_ids).where("concat(lastname, firstname) like ?", "%#{params[:name].strip.to_s}%").limit(10)
 | 
					    @users = User.where.not(id: user_ids).where("CONCAT_WS(lastname, firstname, nickname) like ?", "%#{params[:name].strip.to_s}%").limit(10)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # 添加认证学校管理员
 | 
					  # 添加认证学校管理员
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,7 @@ class Admins::LaboratoriesController < Admins::BaseController
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    keyword = params[:keyword].to_s.strip
 | 
					    keyword = params[:keyword].to_s.strip
 | 
				
			||||||
    if keyword.present?
 | 
					    if keyword.present?
 | 
				
			||||||
      like_sql = 'shixuns.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword '\
 | 
					      like_sql = 'shixuns.name LIKE :keyword OR CONCAT_WS(users.lastname, users.firstname, users.nickname) LIKE :keyword '\
 | 
				
			||||||
                 'OR mirror_repositories.name LIKE :keyword'
 | 
					                 'OR mirror_repositories.name LIKE :keyword'
 | 
				
			||||||
      shixuns = shixuns.joins(:user, :mirror_repositories).where(like_sql, keyword: "%#{keyword}%")
 | 
					      shixuns = shixuns.joins(:user, :mirror_repositories).where(like_sql, keyword: "%#{keyword}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ class Admins::LaboratoriesController < Admins::BaseController
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    keyword = params[:keyword].to_s.strip
 | 
					    keyword = params[:keyword].to_s.strip
 | 
				
			||||||
    if keyword.present?
 | 
					    if keyword.present?
 | 
				
			||||||
      like_sql = 'subjects.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword'
 | 
					      like_sql = 'subjects.name LIKE :keyword OR CONCAT_WS(users.lastname, users.firstname, users.nickname) LIKE :keyword'
 | 
				
			||||||
      subjects = subjects.joins(:user).where(like_sql, keyword: "%#{keyword}%")
 | 
					      subjects = subjects.joins(:user).where(like_sql, keyword: "%#{keyword}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ class MembersController < ApplicationController
 | 
				
			||||||
    scope = @project.members.includes(:roles, user: :user_extension)
 | 
					    scope = @project.members.includes(:roles, user: :user_extension)
 | 
				
			||||||
    search = params[:search].to_s.downcase
 | 
					    search = params[:search].to_s.downcase
 | 
				
			||||||
    role = params[:role].to_s
 | 
					    role = params[:role].to_s
 | 
				
			||||||
    scope = scope.joins(:user).where("LOWER(concat(users.lastname, users.firstname, users.login, users.mail)) LIKE ?", "%#{search.split(" ").join('|')}%") if search.present?
 | 
					    scope = scope.joins(:user).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.login, users.mail, users.nickname)) LIKE ?", "%#{search.split(" ").join('|')}%") if search.present?
 | 
				
			||||||
    scope = scope.joins(:roles).where("roles.name LIKE ?", "%#{role}%") if role.present?
 | 
					    scope = scope.joins(:roles).where("roles.name LIKE ?", "%#{role}%") if role.present?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @total_count = scope.size
 | 
					    @total_count = scope.size
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@ class Organizations::OrganizationUsersController < Organizations::BaseController
 | 
				
			||||||
  def index
 | 
					  def index
 | 
				
			||||||
    @organization_users = @organization.organization_users.includes(:user)
 | 
					    @organization_users = @organization.organization_users.includes(:user)
 | 
				
			||||||
    search = params[:search].to_s.downcase
 | 
					    search = params[:search].to_s.downcase
 | 
				
			||||||
    @organization_users = @organization_users.joins(:user).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.login, users.mail)) LIKE ?", "%#{search.split(" ").join('|')}%") if search.present?
 | 
					    @organization_users = @organization_users.joins(:user).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.login, users.mail, users.nickname)) LIKE ?", "%#{search.split(" ").join('|')}%") if search.present?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @organization_users = kaminari_paginate(@organization_users)
 | 
					    @organization_users = kaminari_paginate(@organization_users)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,7 +63,7 @@ class UsersController < ApplicationController
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def fan_users
 | 
					  def fan_users
 | 
				
			||||||
    watchers = @user.watchers.includes(:user).order("watchers.created_at desc")
 | 
					    watchers = @user.watchers.includes(:user).order("watchers.created_at desc")
 | 
				
			||||||
    watchers = watchers.joins(:user).where("LOWER(concat(users.lastname, users.firstname, users.login)) LIKE ?", "%#{params[:search].split(" ").join('|')}%") if params[:search].present?
 | 
					    watchers = watchers.joins(:user).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.login, users.nickname)) LIKE ?", "%#{params[:search].split(" ").join('|')}%") if params[:search].present?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @watchers_count = watchers.size
 | 
					    @watchers_count = watchers.size
 | 
				
			||||||
    @watchers = paginate(watchers)
 | 
					    @watchers = paginate(watchers)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ class UsersForPrivateMessagesController < ApplicationController
 | 
				
			||||||
      return
 | 
					      return
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    users = users.where('LOWER(concat(lastname, firstname, nickname)) LIKE ?', "%#{keyword}%")
 | 
					    users = users.where('LOWER(CONCAT_WS(lastname, firstname, nickname)) LIKE ?', "%#{keyword}%")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @users = users.limit(10).includes(:user_extension)
 | 
					    @users = users.limit(10).includes(:user_extension)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,7 +86,7 @@ class Weapps::CoursesController < Weapps::BaseController
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if search.present?
 | 
					    if search.present?
 | 
				
			||||||
      @teacher_list = @teacher_list.joins(:user).where("LOWER(CONCAT(users.lastname, users.firstname)) like ?", "%#{search}%")
 | 
					      @teacher_list = @teacher_list.joins(:user).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.nickname)) like ?", "%#{search}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @teacher_list_size = @teacher_list.size
 | 
					    @teacher_list_size = @teacher_list.size
 | 
				
			||||||
| 
						 | 
					@ -127,7 +127,7 @@ class Weapps::CoursesController < Weapps::BaseController
 | 
				
			||||||
    @students = CourseMember.students(@course)
 | 
					    @students = CourseMember.students(@course)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if search.present?
 | 
					    if search.present?
 | 
				
			||||||
      @students = @students.joins(user: :user_extension).where("LOWER(CONCAT(users.lastname, users.firstname)) like ? or
 | 
					      @students = @students.joins(user: :user_extension).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.nickname)) like ? or
 | 
				
			||||||
                                                        user_extensions.student_id like ?", "%#{search}%", "%#{search}%")
 | 
					                                                        user_extensions.student_id like ?", "%#{search}%", "%#{search}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,7 +86,7 @@ class ZipsController < ApplicationController
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          #搜索
 | 
					          #搜索
 | 
				
			||||||
          if params[:search].present?
 | 
					          if params[:search].present?
 | 
				
			||||||
            @ex_users = @ex_users.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
 | 
					            @ex_users = @ex_users.joins(user: :user_extension).where("CONCAT_WS(lastname, firstname, nickname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          default_ex_users_size = @ex_users&.size
 | 
					          default_ex_users_size = @ex_users&.size
 | 
				
			||||||
| 
						 | 
					@ -130,7 +130,7 @@ class ZipsController < ApplicationController
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      unless params[:search].blank?
 | 
					      unless params[:search].blank?
 | 
				
			||||||
        @all_student_works = @all_student_works.joins(user: :user_extension).where("concat(lastname, firstname) like ?
 | 
					        @all_student_works = @all_student_works.joins(user: :user_extension).where("CONCAT_WS(lastname, firstname, nickname) like ?
 | 
				
			||||||
                         or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
 | 
					                         or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,42 +1,42 @@
 | 
				
			||||||
# == Schema Information
 | 
					# == Schema Information
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Table name: attachments
 | 
					# Table name: attachments
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#  id                        :integer          not null, primary key
 | 
					#  id                        :integer          not null, primary key
 | 
				
			||||||
#  container_id              :integer
 | 
					#  container_id              :integer
 | 
				
			||||||
#  container_type            :string(30)
 | 
					#  container_type            :string(30)
 | 
				
			||||||
#  filename                  :string(255)      default(""), not null
 | 
					#  filename                  :string(255)      default(""), not null
 | 
				
			||||||
#  disk_filename             :string(255)      default(""), not null
 | 
					#  disk_filename             :string(255)      default(""), not null
 | 
				
			||||||
#  filesize                  :integer          default("0"), not null
 | 
					#  filesize                  :integer          default("0"), not null
 | 
				
			||||||
#  content_type              :string(255)      default("")
 | 
					#  content_type              :string(255)      default("")
 | 
				
			||||||
#  digest                    :string(60)       default(""), not null
 | 
					#  digest                    :string(60)       default(""), not null
 | 
				
			||||||
#  downloads                 :integer          default("0"), not null
 | 
					#  downloads                 :integer          default("0"), not null
 | 
				
			||||||
#  author_id                 :integer          default("0"), not null
 | 
					#  author_id                 :integer          default("0"), not null
 | 
				
			||||||
#  created_on                :datetime
 | 
					#  created_on                :datetime
 | 
				
			||||||
#  description               :text(65535)
 | 
					#  description               :text(65535)
 | 
				
			||||||
#  disk_directory            :string(255)
 | 
					#  disk_directory            :string(255)
 | 
				
			||||||
#  attachtype                :integer          default("1")
 | 
					#  attachtype                :integer          default("1")
 | 
				
			||||||
#  is_public                 :integer          default("1")
 | 
					#  is_public                 :integer          default("1")
 | 
				
			||||||
#  copy_from                 :integer
 | 
					#  copy_from                 :integer
 | 
				
			||||||
#  quotes                    :integer          default("0")
 | 
					#  quotes                    :integer          default("0")
 | 
				
			||||||
#  is_publish                :integer          default("1")
 | 
					#  is_publish                :integer          default("1")
 | 
				
			||||||
#  publish_time              :datetime
 | 
					#  publish_time              :datetime
 | 
				
			||||||
#  resource_bank_id          :integer
 | 
					#  resource_bank_id          :integer
 | 
				
			||||||
#  unified_setting           :boolean          default("1")
 | 
					#  unified_setting           :boolean          default("1")
 | 
				
			||||||
#  cloud_url                 :string(255)      default("")
 | 
					#  cloud_url                 :string(255)      default("")
 | 
				
			||||||
#  course_second_category_id :integer          default("0")
 | 
					#  course_second_category_id :integer          default("0")
 | 
				
			||||||
#  delay_publish             :boolean          default("0")
 | 
					#  delay_publish             :boolean          default("0")
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Indexes
 | 
					# Indexes
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#  index_attachments_on_author_id                        (author_id)
 | 
					#  index_attachments_on_author_id                        (author_id)
 | 
				
			||||||
#  index_attachments_on_container_id_and_container_type  (container_id,container_type)
 | 
					#  index_attachments_on_container_id_and_container_type  (container_id,container_type)
 | 
				
			||||||
#  index_attachments_on_course_second_category_id        (course_second_category_id)
 | 
					#  index_attachments_on_course_second_category_id        (course_second_category_id)
 | 
				
			||||||
#  index_attachments_on_created_on                       (created_on)
 | 
					#  index_attachments_on_created_on                       (created_on)
 | 
				
			||||||
#  index_attachments_on_is_public                        (is_public)
 | 
					#  index_attachments_on_is_public                        (is_public)
 | 
				
			||||||
#  index_attachments_on_quotes                           (quotes)
 | 
					#  index_attachments_on_quotes                           (quotes)
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Attachment < ApplicationRecord
 | 
					class Attachment < ApplicationRecord
 | 
				
			||||||
  include BaseModel
 | 
					  include BaseModel
 | 
				
			||||||
  include Publicable
 | 
					  include Publicable
 | 
				
			||||||
| 
						 | 
					@ -51,7 +51,7 @@ class Attachment < ApplicationRecord
 | 
				
			||||||
  # 二级目录
 | 
					  # 二级目录
 | 
				
			||||||
  # belongs_to :course_second_category, optional: true
 | 
					  # belongs_to :course_second_category, optional: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  scope :by_filename_or_user_name,      -> (keywords) { joins(:author).where("filename like :search or LOWER(concat(users.lastname, users.firstname)) LIKE :search",
 | 
					  scope :by_filename_or_user_name,      -> (keywords) { joins(:author).where("filename like :search or LOWER(CONCAT_WS(users.lastname, users.firstname, users.nickname)) LIKE :search",
 | 
				
			||||||
                                                        :search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank? }
 | 
					                                                        :search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank? }
 | 
				
			||||||
  scope :by_keywords,                   -> (keywords) { where("filename LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank? }
 | 
					  scope :by_keywords,                   -> (keywords) { where("filename LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank? }
 | 
				
			||||||
  scope :ordered,                       -> (opts = {}) { order("#{opts[:sort_type]} #{opts[:sort] == 1 ? 'asc': 'desc'}") }
 | 
					  scope :ordered,                       -> (opts = {}) { order("#{opts[:sort_type]} #{opts[:sort] == 1 ? 'asc': 'desc'}") }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -170,7 +170,7 @@ class User < Owner
 | 
				
			||||||
  # Groups and active users
 | 
					  # Groups and active users
 | 
				
			||||||
  scope :active, lambda { where(status: STATUS_ACTIVE) }
 | 
					  scope :active, lambda { where(status: STATUS_ACTIVE) }
 | 
				
			||||||
  scope :like, lambda { |keywords|
 | 
					  scope :like, lambda { |keywords|
 | 
				
			||||||
    sql = "CONCAT(lastname, firstname) LIKE :search OR login LIKE :search OR mail LIKE :search OR nickname LIKE :search"
 | 
					    sql = "CONCAT_WS(lastname, firstname, nickname) LIKE :search OR login LIKE :search OR mail LIKE :search OR nickname LIKE :search"
 | 
				
			||||||
    where(sql, :search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
 | 
					    where(sql, :search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,7 @@ class Admins::ApplyItemBankQuery < ApplicationQuery
 | 
				
			||||||
    keyword = params[:keyword].to_s.strip
 | 
					    keyword = params[:keyword].to_s.strip
 | 
				
			||||||
    if keyword.present?
 | 
					    if keyword.present?
 | 
				
			||||||
      applies = applies.joins(user: { user_extension: :school })
 | 
					      applies = applies.joins(user: { user_extension: :school })
 | 
				
			||||||
                  .where('CONCAT(lastname,firstname) LIKE :keyword OR schools.name LIKE :keyword', keyword: "%#{keyword}%")
 | 
					                  .where('CONCAT_WS(lastname,firstname, nickname) LIKE :keyword OR schools.name LIKE :keyword', keyword: "%#{keyword}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    custom_sort(applies, params[:sort_by], params[:sort_direction])
 | 
					    custom_sort(applies, params[:sort_by], params[:sort_direction])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,7 @@ class Admins::ApplyUserAuthenticationQuery < ApplicationQuery
 | 
				
			||||||
    keyword = params[:keyword].to_s.strip
 | 
					    keyword = params[:keyword].to_s.strip
 | 
				
			||||||
    if keyword.present?
 | 
					    if keyword.present?
 | 
				
			||||||
      applies = applies.joins(user: { user_extension: :school })
 | 
					      applies = applies.joins(user: { user_extension: :school })
 | 
				
			||||||
                  .where('CONCAT(lastname,firstname) LIKE :keyword OR schools.name LIKE :keyword', keyword: "%#{keyword}%")
 | 
					                  .where('CONCAT_WS(lastname,firstname,nickname) LIKE :keyword OR schools.name LIKE :keyword', keyword: "%#{keyword}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    custom_sort(applies, params[:sort_by], params[:sort_direction])
 | 
					    custom_sort(applies, params[:sort_by], params[:sort_direction])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@ class Admins::CourseListQuery < ApplicationQuery
 | 
				
			||||||
      case search_type
 | 
					      case search_type
 | 
				
			||||||
      when "0"
 | 
					      when "0"
 | 
				
			||||||
        course_lists = course_lists.joins(:user)
 | 
					        course_lists = course_lists.joins(:user)
 | 
				
			||||||
                      .where('CONCAT(lastname, firstname) like :keyword', keyword: "%#{keyword}%")
 | 
					                      .where('CONCAT_WS(lastname, firstname, nickname) like :keyword', keyword: "%#{keyword}%")
 | 
				
			||||||
      when "1"
 | 
					      when "1"
 | 
				
			||||||
        course_lists = course_lists.where('name like :keyword', keyword: "%#{keyword}%")
 | 
					        course_lists = course_lists.where('name like :keyword', keyword: "%#{keyword}%")
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,7 @@ class Admins::CourseQuery < ApplicationQuery
 | 
				
			||||||
    # 关键字
 | 
					    # 关键字
 | 
				
			||||||
    keyword = params[:keyword].to_s.strip
 | 
					    keyword = params[:keyword].to_s.strip
 | 
				
			||||||
    if keyword
 | 
					    if keyword
 | 
				
			||||||
      sql = 'CONCAT(lastname, firstname) LIKE :keyword OR courses.name LIKE :keyword OR course_lists.name LIKE :keyword'
 | 
					      sql = 'CONCAT_WS(lastname, firstname, nickname) LIKE :keyword OR courses.name LIKE :keyword OR course_lists.name LIKE :keyword'
 | 
				
			||||||
      courses = courses.joins(:teacher, :course_list).where(sql, keyword: "%#{keyword}%")
 | 
					      courses = courses.joins(:teacher, :course_list).where(sql, keyword: "%#{keyword}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ class Admins::LaboratoryShixunQuery < ApplicationQuery
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    keyword = params[:keyword].to_s.strip
 | 
					    keyword = params[:keyword].to_s.strip
 | 
				
			||||||
    if keyword.present?
 | 
					    if keyword.present?
 | 
				
			||||||
      like_sql = 'shixuns.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword'
 | 
					      like_sql = 'shixuns.name LIKE :keyword OR CONCAT_WS(users.lastname, users.firstname, users.nickname) LIKE :keyword'
 | 
				
			||||||
      laboratory_shixuns = laboratory_shixuns.joins(shixun: :user).where(like_sql, keyword: "%#{keyword}%")
 | 
					      laboratory_shixuns = laboratory_shixuns.joins(shixun: :user).where(like_sql, keyword: "%#{keyword}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ class Admins::LaboratorySubjectQuery < ApplicationQuery
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    keyword = params[:keyword].to_s.strip
 | 
					    keyword = params[:keyword].to_s.strip
 | 
				
			||||||
    if keyword.present?
 | 
					    if keyword.present?
 | 
				
			||||||
      like_sql = 'subjects.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword'
 | 
					      like_sql = 'subjects.name LIKE :keyword OR CONCAT_WS(users.lastname, users.firstname, users.nickname) LIKE :keyword'
 | 
				
			||||||
      laboratory_subjects = laboratory_subjects.joins(subject: :user).where(like_sql, keyword: "%#{keyword}%")
 | 
					      laboratory_subjects = laboratory_subjects.joins(subject: :user).where(like_sql, keyword: "%#{keyword}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,7 +40,7 @@ class Admins::SubjectQuery < ApplicationQuery
 | 
				
			||||||
    # 关键字
 | 
					    # 关键字
 | 
				
			||||||
    keyword = params[:keyword].to_s.strip
 | 
					    keyword = params[:keyword].to_s.strip
 | 
				
			||||||
    if keyword
 | 
					    if keyword
 | 
				
			||||||
      sql = 'CONCAT(lastname, firstname) LIKE :keyword OR subjects.name LIKE :keyword'
 | 
					      sql = 'CONCAT_WS(lastname, firstname, nickname) LIKE :keyword OR subjects.name LIKE :keyword'
 | 
				
			||||||
      subjects = subjects.joins(:user).where(sql, keyword: "%#{keyword}%")
 | 
					      subjects = subjects.joins(:user).where(sql, keyword: "%#{keyword}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,14 +30,14 @@ class Admins::UserQuery < ApplicationQuery
 | 
				
			||||||
    # 关键字检索
 | 
					    # 关键字检索
 | 
				
			||||||
    keyword = params[:keyword].to_s.strip.presence
 | 
					    keyword = params[:keyword].to_s.strip.presence
 | 
				
			||||||
    if keyword
 | 
					    if keyword
 | 
				
			||||||
      sql = 'CONCAT(lastname, firstname) LIKE :keyword OR login LIKE :keyword OR mail LIKE :keyword OR phone LIKE :keyword'
 | 
					      sql = 'CONCAT_WS(lastname, firstname, nickname) LIKE :keyword OR login LIKE :keyword OR mail LIKE :keyword OR phone LIKE :keyword'
 | 
				
			||||||
      users = users.where(sql, keyword: "%#{keyword}%")
 | 
					      users = users.where(sql, keyword: "%#{keyword}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # 姓名
 | 
					    # 姓名
 | 
				
			||||||
    name = params[:name].to_s.strip.presence
 | 
					    name = params[:name].to_s.strip.presence
 | 
				
			||||||
    if name.present?
 | 
					    if name.present?
 | 
				
			||||||
      users = users.where('CONCAT(lastname, firstname) LIKE :name', name: "%#{name}%")
 | 
					      users = users.where('CONCAT_WS(lastname, firstname, nickname) LIKE :name', name: "%#{name}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # 单位ID
 | 
					    # 单位ID
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@ class UserQuery < ApplicationQuery
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # 真实姓名
 | 
					    # 真实姓名
 | 
				
			||||||
    if name = strip_param(:name)
 | 
					    if name = strip_param(:name)
 | 
				
			||||||
      users = users.where('LOWER(CONCAT(users.lastname, users.firstname)) LIKE ?', "%#{name.downcase}%")
 | 
					      users = users.where('LOWER(CONCAT_WS(users.lastname, users.firstname, users.nickname)) LIKE ?', "%#{name.downcase}%")
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # 单位名称
 | 
					    # 单位名称
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,7 +84,7 @@ class Admins::ImportUserService < ApplicationService
 | 
				
			||||||
    if data.identity.to_i == 1
 | 
					    if data.identity.to_i == 1
 | 
				
			||||||
      users = users.where(user_extensions: { student_id: data.student_id })
 | 
					      users = users.where(user_extensions: { student_id: data.student_id })
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      users = users.where(user_extensions: { technical_title: data.technical_title }).where('CONCAT(users.lastname,users.firstname) = ?', data.name)
 | 
					      users = users.where(user_extensions: { technical_title: data.technical_title }).where('CONCAT_WS(users.lastname,users.firstname,users.nickname) = ?', data.name)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    users.first
 | 
					    users.first
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue