|
|
|
@ -18,7 +18,7 @@ module Mobile
|
|
|
|
|
resources :project_packages do
|
|
|
|
|
desc 'project packages index'
|
|
|
|
|
params do
|
|
|
|
|
optional :category, type: String, desc: '类型'
|
|
|
|
|
optional :category_id, type: Integer, desc: '类型ID'
|
|
|
|
|
optional :keyword, type: String, desc: '搜索关键字'
|
|
|
|
|
optional :sort_by, type: String, desc: '排序'
|
|
|
|
|
optional :sort_direction, type: String, desc: '排序方向'
|
|
|
|
@ -28,7 +28,7 @@ module Mobile
|
|
|
|
|
get do
|
|
|
|
|
packages = ProjectPackage.where(status: %w(published bidding_ended bidding_finished))
|
|
|
|
|
|
|
|
|
|
packages = packages.where(category: params[:category]) if params[:category].present?
|
|
|
|
|
packages = packages.where(project_package_category_id: params[:category_id]) if params[:category_id].present?
|
|
|
|
|
|
|
|
|
|
keyword = params[:keyword].to_s.strip
|
|
|
|
|
packages = packages.where('title LIKE ?', "%#{keyword}%") if keyword.present?
|
|
|
|
@ -39,7 +39,7 @@ module Mobile
|
|
|
|
|
sort = params[:sort_by] == 'price' ? 'min_price' : 'published_at'
|
|
|
|
|
packages = packages.order("#{sort} #{direction}")
|
|
|
|
|
|
|
|
|
|
packages = paginate packages.includes(:creator, :attachments, bidding_users: :user)
|
|
|
|
|
packages = paginate packages.includes(:creator, :attachments, :project_package_category, bidding_users: :user)
|
|
|
|
|
|
|
|
|
|
present :count, count
|
|
|
|
|
present :project_packages, packages, with: Mobile::Entities::ProjectPackage, type: :index, user: current_user
|
|
|
|
@ -96,7 +96,7 @@ module Mobile
|
|
|
|
|
|
|
|
|
|
desc 'create project packages'
|
|
|
|
|
params do
|
|
|
|
|
requires :category, type: String, desc: '类型'
|
|
|
|
|
requires :category_id, type: Integer, desc: '类型ID'
|
|
|
|
|
requires :title, type: String, desc: '标题'
|
|
|
|
|
requires :content, type: String, desc: '描述'
|
|
|
|
|
optional :attachment_ids, type: Array[Integer], desc: '附件ID数组'
|
|
|
|
@ -124,7 +124,7 @@ module Mobile
|
|
|
|
|
desc 'update project package'
|
|
|
|
|
params do
|
|
|
|
|
requires :id, type: Integer, desc: 'ID'
|
|
|
|
|
requires :category, type: String, desc: '类型'
|
|
|
|
|
requires :category_id, type: Integer, desc: '类型ID'
|
|
|
|
|
requires :title, type: String, desc: '标题'
|
|
|
|
|
requires :content, type: String, desc: '描述'
|
|
|
|
|
optional :attachment_ids, type: Array[Integer], desc: '附件ID数组'
|
|
|
|
|