parent
							
								
									43110605c1
								
							
						
					
					
						commit
						5d1acd8a5d
					
				| @ -0,0 +1,46 @@ | ||||
| class Managements::ProjectPackageAppliesController < Managements::BaseController | ||||
|   before_filter :set_menu_type | ||||
| 
 | ||||
|   def index | ||||
|     applies = ProjectPackageApply.order('project_package_applies.updated_at desc') | ||||
| 
 | ||||
|     search = params[:search].to_s.strip | ||||
|     if search.present? | ||||
|       applies = applies.joins(:project_package).where('project_packages.title like :search', search: "%#{search}%") | ||||
|     end | ||||
| 
 | ||||
|     applies = applies.where(status: params[:status].presence || :pending) | ||||
| 
 | ||||
|     @applies = paginateHelper applies.includes(project_package: { creator: :user_extensions }) | ||||
| 
 | ||||
|     respond_to do |format| | ||||
|       format.js | ||||
|       format.html | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   def agree | ||||
|     ProjectPackages::AgreeApplyService.new(current_apply).call | ||||
|     render json: { status: 0 } | ||||
|   rescue ProjectPackages::AgreeApplyService::Error => e | ||||
|     render json: { status: -1, message: e.message } | ||||
|   end | ||||
| 
 | ||||
|   def refuse | ||||
|     ProjectPackages::RefuseApplyService.new(current_apply, reason: params[:reason]).call | ||||
|     render json: { status: 0 } | ||||
|   rescue ProjectPackages::RefuseApplyService::Error => e | ||||
|     render json: { status: -1, message: e.message } | ||||
|   end | ||||
| 
 | ||||
|   private | ||||
| 
 | ||||
|   def current_apply | ||||
|     @_current_apply ||= ProjectPackageApply.find(params[:id]) | ||||
|   end | ||||
| 
 | ||||
|   def set_menu_type | ||||
|     @menu_type = 10 | ||||
|     @sub_type = 9 | ||||
|   end | ||||
| end | ||||
| @ -0,0 +1,16 @@ | ||||
| class Admins::ShiXunsController < Admins::BaseController | ||||
| 
 | ||||
|   def index | ||||
|     params[:status] ||= 'pending' | ||||
|     applies = Admins::LibraryApplyQuery.call(params) | ||||
| 
 | ||||
|     @library_applies = paginate applies.preload(library: :user) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   end | ||||
| 
 | ||||
|   def destroy | ||||
| 
 | ||||
|   end | ||||
| end | ||||
| @ -0,0 +1,38 @@ | ||||
| class Admins::ShiXunQuery < ApplicationQuery | ||||
|   include CustomSortable | ||||
| 
 | ||||
|   attr_reader :params | ||||
| 
 | ||||
|   sort_columns :updated_at, default_by: :updated_at, default_direction: :desc | ||||
| 
 | ||||
|   def initialize(params) | ||||
|     @params = params | ||||
|   end | ||||
| 
 | ||||
|   def call | ||||
|     status = | ||||
|         case params[:status] | ||||
|         when "editing" then [0] | ||||
|         when "pending" then [1] | ||||
|         when "processed" then [2] | ||||
|         else | ||||
|           [0,1,2] | ||||
|         end | ||||
| 
 | ||||
|     applies = LibraryApply.where(status: status) if status.present? | ||||
| 
 | ||||
|     look_name = params[:look_name] | ||||
|     if look_name.present? | ||||
|       applies = applies.where() | ||||
|     end | ||||
| 
 | ||||
|     # 关键字模糊查询 | ||||
|     keyword = params[:keyword].to_s.strip | ||||
|     if keyword.present? | ||||
|       applies = applies.joins(:library) | ||||
|                     .where('title LIKE :keyword OR uuid LIKE :keyword', keyword: "%#{keyword}%") | ||||
|     end | ||||
| 
 | ||||
|     custom_sort(applies, params[:sort_by], params[:sort_direction]) | ||||
|   end | ||||
| end | ||||
					Loading…
					
					
				
		Reference in new issue