You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							29 lines
						
					
					
						
							761 B
						
					
					
				
			
		
		
	
	
							29 lines
						
					
					
						
							761 B
						
					
					
				| class Admins::LibraryApplyQuery < 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 'processed' then %w(agreed refused)
 | |
|         else params[:status]
 | |
|         end
 | |
|     applies = LibraryApply.where(status: status) if status.present?
 | |
| 
 | |
|     # 关键字模糊查询
 | |
|     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 |