mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
add site page
This commit is contained in:
17
app/queries/admins/identity_verification_query.rb
Normal file
17
app/queries/admins/identity_verification_query.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class Admins::IdentityVerificationQuery < 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
|
||||
state = params[:state].blank? ? [0,1,2] : params[:state].to_i
|
||||
applies = IdentityVerification.where(state: state)
|
||||
custom_sort(applies, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
||||
24
app/queries/admins/site_pages_query.rb
Normal file
24
app/queries/admins/site_pages_query.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
class Admins::SitePagesQuery < ApplicationQuery
|
||||
include CustomSortable
|
||||
|
||||
attr_reader :params
|
||||
|
||||
sort_columns :created_at, default_by: :created_at, default_direction: :desc
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
state = params[:state].blank? ? [true,false] : params[:state]
|
||||
pages = Page.joins(:user).where(state: state)
|
||||
# 关键字检索
|
||||
keyword = params[:keyword].to_s.strip.presence
|
||||
if keyword
|
||||
sql = 'users.nickname LIKE :keyword OR users.login LIKE :keyword OR users.mail LIKE :keyword OR users.phone LIKE :keyword'
|
||||
pages = pages.where(sql, keyword: "%#{keyword}%")
|
||||
end
|
||||
|
||||
custom_sort(pages, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
||||
13
app/queries/page_query.rb
Normal file
13
app/queries/page_query.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class PageQuery < ApplicationQuery
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params, user)
|
||||
@user = user
|
||||
end
|
||||
|
||||
def call
|
||||
pages = Page.where(user: @user)
|
||||
|
||||
pages
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user