小程序实训搜索功能

PCqiandao
jingquan huang 5 years ago
parent 8bfd3bfa98
commit b8358e913d

@ -34,8 +34,7 @@ class Weapps::ShixunSearchService < ApplicationService
unless params[:keyword].blank? unless params[:keyword].blank?
keyword = params[:keyword].strip keyword = params[:keyword].strip
shixuns = shixuns.joins(:user). shixuns = shixuns.joins(:user).
where("concat(lastname, firstname) like :keyword or shixuns.name like :keyword", where("shixuns.name like :keyword", keyword: "%#{keyword}%").distinct
keyword: "%#{keyword}%", name: "%#{keyword.split(" ").join("%")}%").distinct
end end
shixuns.order("#{sort_str} #{order_str}") shixuns.order("#{sort_str} #{order_str}")

Loading…
Cancel
Save