mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-22 04:35:45 +08:00
Merge branch 'standalone_develop' into pre_trustie_server
This commit is contained in:
@@ -64,7 +64,6 @@ class Api::Pm::Issues::UpdateService < ApplicationService
|
||||
build_assigner_issue_journal_details unless assigner_ids.nil?# 操作记录
|
||||
build_attachment_issue_journal_details unless attachment_ids.nil?
|
||||
build_issue_tag_issue_journal_details unless issue_tag_ids.nil?
|
||||
build_issue_project_trends if status_id.present? # 开关时间记录
|
||||
build_assigner_participants unless assigner_ids.nil? # 负责人
|
||||
build_edit_participants
|
||||
build_atme_participants if @atme_receivers.present?
|
||||
@@ -92,6 +91,7 @@ class Api::Pm::Issues::UpdateService < ApplicationService
|
||||
|
||||
build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录
|
||||
build_previous_issue_changes
|
||||
build_issue_project_trends if status_id.present? # 开关时间记录
|
||||
build_cirle_blockchain_token if blockchain_token_num.present?
|
||||
unless @project.id.zero?
|
||||
# @信息发送
|
||||
@@ -172,7 +172,7 @@ class Api::Pm::Issues::UpdateService < ApplicationService
|
||||
|
||||
def build_issue_project_trends
|
||||
if @updated_issue.previous_changes["status_id"].present? && @updated_issue.previous_changes["status_id"][1] == 5
|
||||
@updated_issue.project_trends.new({user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE})
|
||||
@updated_issue.project_trends.create!({user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE})
|
||||
end
|
||||
if @updated_issue.previous_changes["status_id"].present? && @updated_issue.previous_changes["status_id"][0] == 5
|
||||
@updated_issue.project_trends.where(action_type: ProjectTrend::CLOSE).each(&:destroy!)
|
||||
|
||||
@@ -64,7 +64,6 @@ class Api::V1::Issues::UpdateService < ApplicationService
|
||||
build_assigner_issue_journal_details unless assigner_ids.nil?# 操作记录
|
||||
build_attachment_issue_journal_details unless attachment_ids.nil?
|
||||
build_issue_tag_issue_journal_details unless issue_tag_ids.nil?
|
||||
build_issue_project_trends if status_id.present? # 开关时间记录
|
||||
build_assigner_participants unless assigner_ids.nil? # 负责人
|
||||
build_edit_participants
|
||||
build_atme_participants if @atme_receivers.present?
|
||||
@@ -92,6 +91,7 @@ class Api::V1::Issues::UpdateService < ApplicationService
|
||||
|
||||
build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录
|
||||
build_previous_issue_changes
|
||||
build_issue_project_trends if status_id.present? # 开关时间记录
|
||||
build_cirle_blockchain_token if blockchain_token_num.present?
|
||||
unless @project.id.zero?
|
||||
# @信息发送
|
||||
@@ -172,7 +172,7 @@ class Api::V1::Issues::UpdateService < ApplicationService
|
||||
|
||||
def build_issue_project_trends
|
||||
if @updated_issue.previous_changes["status_id"].present? && @updated_issue.previous_changes["status_id"][1] == 5
|
||||
@updated_issue.project_trends.new({user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE})
|
||||
@updated_issue.project_trends.create!({user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE})
|
||||
end
|
||||
if @updated_issue.previous_changes["status_id"].present? && @updated_issue.previous_changes["status_id"][0] == 5
|
||||
@updated_issue.project_trends.where(action_type: ProjectTrend::CLOSE).each(&:destroy!)
|
||||
|
||||
38
app/services/api/v1/users/delete_user_service.rb
Normal file
38
app/services/api/v1/users/delete_user_service.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
class Api::V1::Users::DeleteUserService < ApplicationService
|
||||
attr_reader :user
|
||||
def initialize(user)
|
||||
@user = user
|
||||
end
|
||||
|
||||
def call
|
||||
begin
|
||||
ActiveRecord::Base.transaction do
|
||||
org_ids = TeamUser.where(user_id: @user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @user.id).pluck(:organization_id)
|
||||
organizations = Organization.where(id: org_ids)
|
||||
organizations.each do |org|
|
||||
# org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)})
|
||||
owner_count = org.team_users.joins(:team).where(teams: {authorize: %w(owner)}).count
|
||||
# 多个owner时,仅将用户从组织移除, 一个时直接删除
|
||||
org.team_users.where(user_id: @user.id).destroy_all
|
||||
org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all
|
||||
if owner_count == 1
|
||||
if org.team_users.joins(:team).where(user_id: @user.id, teams: { authorize: %w(owner) }).count > 0
|
||||
org.destroy!
|
||||
end
|
||||
end
|
||||
end
|
||||
@user.destroy!
|
||||
del_user_data_by_sql(@user.id)
|
||||
Gitea::User::DeleteService.call(@user.login, true)
|
||||
end
|
||||
return true
|
||||
rescue
|
||||
raise Error, "服务器错误,请联系系统管理员!"
|
||||
end
|
||||
end
|
||||
|
||||
def del_user_data_by_sql(user_id)
|
||||
sql1 = "delete from memos where author_id=#{user_id}"
|
||||
ActiveRecord::Base.connection.execute(sql1)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user