Merge remote-tracking branch 'origin/standalone_develop' into standalone_develop

This commit is contained in:
xxq250 2025-10-16 09:26:38 +08:00
commit 354b8ee8a9
2 changed files with 22 additions and 3 deletions

View File

@ -25,6 +25,8 @@
class UserAction < ApplicationRecord
belongs_to :user, optional: true
after_save :add_user_info
serialize :data_bank, JSON
@ -36,6 +38,7 @@ class UserAction < ApplicationRecord
when "Login" then "登录"
when "Logout" then "退出登录"
when "DestroyOrganization" then "删除组织"
when "Attachment" then "上传附件"
else self.action_type
end
end
@ -43,7 +46,7 @@ class UserAction < ApplicationRecord
def opt_user_name
user = User.find_by(id: self.user_id)
if user.present?
user&.login
user&.real_name
else
del_user = UserAction.find_by(action_type: "DestroyUser", action_id: self.user_id)
del_user.present? ? del_user.user.login : "不存在用户:#{user_id}"
@ -55,6 +58,13 @@ class UserAction < ApplicationRecord
when "DestroyUser" then "账号:#{user&.login}<br/>邮箱:#{user&.mail}<br/>手机号:#{user&.phone}<br/>昵称:#{user&.nickname}<br/>"
when "DestroyProject" then "项目名称:#{project&.name}<br/>项目标识:#{project&.identifier}<br/>"
when "DestroyOrganization" then "组织名称:#{organization&.nickname}<br/>组织标识:#{organization&.login}<br/>"
when 'Attachment'
issue = Issue.find_by_id(attachment.container_id)
if attachment.container_type == "Issue" && issue&.issue_classify == "issue"
return "上传附件issue地址<a href=\"#{Rails.application.config_for(:configuration)['platform_url']}/#{issue&.project&.owner&.login}/#{issue&.project&.identifier}/issues/#{issue&.project_issues_index}\">#{issue&.subject}</a>"
else
return "上传附件地址:<a href=\"#{Rails.application.config_for(:configuration)['platform_url']}/attachments/#{attachment.uuid}\">#{attachment.title}</a>"
end
else "--"
end
end
@ -86,6 +96,15 @@ class UserAction < ApplicationRecord
action_organization
end
def attachment
action_attachment = if action_type == "Attachment" && data_bank.present?
build_mode("Attachment")
else
Attachment.find_by(id: self.action_id)
end
action_attachment
end
def build_mode(model_name)
model = model_name.constantize.new

View File

@ -5,9 +5,9 @@
<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 = [['自定义',''],['删除用户','DestroyUser'], ['删除项目', 'DestroyProject'], ['删除组织', 'DestroyOrganization']] %>
<% action_type_options = [['上传附件', 'Attachment'], ['登录', 'Login'], ['退出登录', 'Logout'],['删除用户','DestroyUser'], ['删除项目', 'DestroyProject'], ['删除组织', 'DestroyOrganization']] %>
<%= select_tag(:action_type_select, options_for_select(action_type_options), class: 'form-control') %>
<%= text_field_tag(:action_type, params[:action_type], class: 'form-control col-sm-2 ml-3',style: 'display:;', placeholder: '自定义操作类型检索') %>
<%= 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 %>