fixed 用户删除优化处理,多个owner时,仅将用户从组织移除, 一个时直接删除
This commit is contained in:
parent
5f3aaa03eb
commit
d1968a63c1
|
@ -31,9 +31,9 @@ class Admins::UsersController < Admins::BaseController
|
||||||
organizations = Organization.where(id: org_ids)
|
organizations = Organization.where(id: org_ids)
|
||||||
organizations.each do |org|
|
organizations.each do |org|
|
||||||
# org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)})
|
# org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)})
|
||||||
org.team_users.joins(:team).where(teams: {authorize: %w(owner)})
|
owner_count = org.team_users.joins(:team).where(teams: {authorize: %w(owner)}).count
|
||||||
# 多个owner时,仅将用户从组织移除, 一个时直接删除
|
# 多个owner时,仅将用户从组织移除, 一个时直接删除
|
||||||
if org.count > 1
|
if owner_count > 1
|
||||||
org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}).destroy_all
|
org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}).destroy_all
|
||||||
org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all
|
org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue