diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 9a5307be6..b6d1db25c 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -82,7 +82,7 @@ module Mobile desc "用户搜索" params do requires :name, type: String, desc: '用户名关键字' - requires :search_by, type: String,desc: '搜索依据:0 昵称,1 用户名,2 邮箱' + requires :search_by, type: String,desc: '搜索依据:0 昵称,1 用户名,2 邮箱,3 昵称和姓名' end get 'search/search_user' do us = UsersService.new diff --git a/app/models/user.rb b/app/models/user.rb index 83e08254c..860eb56a5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -214,6 +214,8 @@ class User < Principal where(" LOWER(login) LIKE '#{pattern}' ") elsif type == "1" where(" LOWER(concat(lastname, firstname)) LIKE '#{pattern}' ") + elsif type == "3" + where(" LOWER(concat(lastname, firstname,login)) LIKE '#{pattern}' ") else where(" LOWER(mail) LIKE '#{pattern}' ") end