|
|
@ -21,6 +21,7 @@ module Mobile
|
|
|
|
optional :category, type: String, desc: '类型'
|
|
|
|
optional :category, type: String, desc: '类型'
|
|
|
|
optional :keyword, type: String, desc: '搜索关键字'
|
|
|
|
optional :keyword, type: String, desc: '搜索关键字'
|
|
|
|
optional :sort_by, type: String, desc: '排序'
|
|
|
|
optional :sort_by, type: String, desc: '排序'
|
|
|
|
|
|
|
|
optional :sort_direction, type: String, desc: '排序方向'
|
|
|
|
optional :page, type: Integer, desc: '页数'
|
|
|
|
optional :page, type: Integer, desc: '页数'
|
|
|
|
optional :per_page, type: Integer, desc: '分页大小'
|
|
|
|
optional :per_page, type: Integer, desc: '分页大小'
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -34,11 +35,10 @@ module Mobile
|
|
|
|
|
|
|
|
|
|
|
|
count = packages.count
|
|
|
|
count = packages.count
|
|
|
|
|
|
|
|
|
|
|
|
if params[:sort_by] == 'price'
|
|
|
|
direction = params[:sort_direction] == 'asc' ? 'asc' : 'desc'
|
|
|
|
packages = packages.order('min_price desc')
|
|
|
|
sort = params[:sort_by] == 'price' ? 'min_price' : 'published_at'
|
|
|
|
else
|
|
|
|
packages = packages.order("#{sort} #{direction}")
|
|
|
|
packages = packages.order('published_at desc')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
packages = paginate packages.includes(:creator, :attachments, bidding_users: :user)
|
|
|
|
packages = paginate packages.includes(:creator, :attachments, bidding_users: :user)
|
|
|
|
|
|
|
|
|
|
|
|
present :count, count
|
|
|
|
present :count, count
|
|
|
|