|
|
|
@@ -67,7 +67,17 @@ class Organizations::TeamsController < Organizations::BaseController |
|
|
|
tip_exception("组织团队不允许被删除") if @team.owner? |
|
|
|
ActiveRecord::Base.transaction do |
|
|
|
Gitea::Organization::Team::DeleteService.call(@organization.gitea_token, @team.gtid) |
|
|
|
all_user_ids = @organization.team_users.pluck(:user_id) |
|
|
|
team_user_ids = @team.team_users.pluck(:user_id) |
|
|
|
# 当前删除团队中成员在其他组织其他团队不存在的成员需清除组织 |
|
|
|
remove_user_ids = team_user_ids - all_user_ids |
|
|
|
@team.destroy! |
|
|
|
if remove_user_ids.present? |
|
|
|
User.where(id: remove_user_ids).each do |user| |
|
|
|
@organization.organization_users.find_by(user_id: user.id).destroy! |
|
|
|
Gitea::Organization::OrganizationUser::DeleteService.call(@organization.gitea_token, @organization.login, user.login) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
render_ok |
|
|
|
rescue Exception => e |
|
|
|
|