用户搜索接口添加按昵称或姓名搜索

This commit is contained in:
z9hang 2015-03-18 17:31:35 +08:00
parent 52f2a31b84
commit 9d686349da
2 changed files with 3 additions and 1 deletions

View File

@ -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

View File

@ -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