部门的删除

dev_aliyun
cxt 5 years ago
parent 6e322a5630
commit 7da238def9

@ -1746,6 +1746,7 @@ end
# 删除
def delete_applied_departments
transaction do
applied_department = ApplyAddDepartment.find params[:depart_id]
applied_message = AppliedMessage.where(:applied_id => applied_department.id, :applied_type => "ApplyAddDepartment")
applied_message.update_all(:status => 3)
@ -1765,6 +1766,7 @@ end
elsif params[:tip] == "applied"
applied_department.destroy
end
end
respond_to do |format|
format.html{ redirect_to depart_managements_path }
end

@ -0,0 +1,16 @@
class MigrateDeleteDepartment < ActiveRecord::Migration
def up
ApplyAddDepartment.where("status= 3 and created_at > '2019-07-25 00:00:00'").each do |apply|
if apply.department.present? && !apply.department.is_auth
user_exs = UserExtensions.where("department_id = #{apply.department_id}")
users = User.where(id: user_exs.pluck(:user_id))
user_exs.update_all(department_id: nil)
users.update_all(profile_completed: false)
apply.department.destroy
end
end
end
def down
end
end
Loading…
Cancel
Save