新增:后台管理论坛审核

This commit is contained in:
yystopf 2026-04-03 11:13:10 +08:00
parent 8211e7580a
commit 1a855bc11e
5 changed files with 61 additions and 3 deletions

View File

@ -2,8 +2,21 @@ class Admins::UserActionsController < Admins::BaseController
before_action :require_admin
def index
@user_actions = UserAction.order(created_at: :desc)
@user_actions = UserAction.where.not(action_type: ["CompetitionInfoCreate", "CompetitionInfoUpdate", "CompetitionInfoUp", "CompetitionInfoDown", 'MemoPassed']).order(created_at: :desc)
if params[:action_type].present?
@user_actions = @user_actions.where(action_type: params[:action_type])
end
keyword = params[:keyword].to_s.strip.presence
if keyword
sql = 'login LIKE :keyword OR phone LIKE :keyword OR email LIKE :keyword'
@user_actions = @user_actions.where(sql, keyword: "%#{keyword}%")
end
@user_actions = paginate @user_actions
end
def index_1
@user_actions = UserAction.where(action_type: ["CompetitionInfoCreate", "CompetitionInfoUpdate", "CompetitionInfoUp", "CompetitionInfoDown", 'MemoPassed']).order(created_at: :desc)
if params[:action_type].present?
if params[:action_type].include?("CompetitionInfo")
@user_actions = @user_actions.where(action_type: ["CompetitionInfoCreate", "CompetitionInfoUpdate", "CompetitionInfoUp", "CompetitionInfoDown"])

View File

@ -43,6 +43,7 @@ class UserAction < ApplicationRecord
when "CompetitionInfoUp" then "上架竞赛"
when "CompetitionInfoDown" then "下架竞赛"
when "Attachment" then "上传附件"
when "MemoPassed" then "论坛审核"
else self.action_type
end
end
@ -70,6 +71,7 @@ class UserAction < ApplicationRecord
else
return "上传附件地址:<a href=\"#{Rails.application.config_for(:configuration)['platform_url']}/attachments/#{attachment.id}\">#{attachment.title}</a>"
end
when "MemoPassed" then "<a href=\"#{Rails.application.config_for(:configuration)['platform_url']}/forumsDetail/#{memo.id}\">#{memo&.subject}</a>"
else "--"
end
end
@ -119,6 +121,14 @@ class UserAction < ApplicationRecord
competition_info
end
def memo
memo = if action_type == "MemoPassed" && data_bank.present?
Memo.find_by(id: self.action_id)
else
nil
end
end
def build_mode(model_name)
model = model_name.constantize.new

View File

@ -5,7 +5,7 @@
<div class="box search-form-container user-list-form">
<%= form_tag(admins_user_actions_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
操作类型:
<% action_type_options = [['上传附件', 'Attachment'], ['登录', 'Login'], ['退出登录', 'Logout'],['删除用户','DestroyUser'], ['删除项目', 'DestroyProject'], ['删除组织', 'DestroyOrganization'], ['竞赛', 'CompetitionInfo']] %>
<% action_type_options = [['上传附件', 'Attachment'], ['登录', 'Login'], ['退出登录', 'Logout'],['删除用户','DestroyUser'], ['删除项目', 'DestroyProject'], ['删除组织', 'DestroyOrganization']] %>
<%= select_tag(:action_type, options_for_select(action_type_options, params[:action_type]), class: 'form-control') %>
<%#= text_field_tag(:action_type, params[:action_type], class: 'form-control col-sm-2 ml-3',style: 'display: none;', placeholder: '自定义操作类型检索') %>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '操作人用户名/邮箱/手机号检索') %>

View File

@ -0,0 +1,33 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('操作记录', admins_user_actions_path) %>
<% end %>
<div class="box search-form-container user-list-form">
<%= form_tag(admins_user_actions_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
操作类型:
<% action_type_options = [['竞赛', 'CompetitionInfo'], ['论坛审核', 'MemoPassed']] %>
<%= select_tag(:action_type, options_for_select(action_type_options, params[:action_type]), class: 'form-control') %>
<%#= text_field_tag(:action_type, params[:action_type], class: 'form-control col-sm-2 ml-3',style: 'display: none;', placeholder: '自定义操作类型检索') %>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '操作人用户名/邮箱/手机号检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<% end %>
</div>
<div class="box admin-list-container users-list-container">
<%= render partial: 'admins/user_actions/user_action_list', locals: { user_actions: @user_actions } %>
</div>
<script>
$(function () {
$('#action_type_select').change(function () {
var switch_value = $(this).val();
$('#action_type').val(switch_value);
if (switch_value == ''){
$('#action_type').show();
}else{
$('#action_type').hide();
}
})
})
</script>

View File

@ -1120,7 +1120,9 @@ Rails.application.routes.draw do
post :drag, on: :collection
post :replace_image_url, on: :member
end
resources :user_actions , only:[:index]
resources :user_actions , only:[:index] do
get :index_1, on: :collection
end
resources :faqs
resources :nps do
post :switch_change, on: :collection