You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
511 B
20 lines
511 B
5 years ago
|
class Admins::AddDepartmentMemberService < ApplicationService
|
||
|
|
||
|
attr_reader :department, :params
|
||
|
|
||
|
def initialize(department, params)
|
||
|
@department = department
|
||
|
@params = params
|
||
|
end
|
||
|
|
||
|
def call
|
||
|
columns = %i[]
|
||
|
DepartmentMember.bulk_insert(*columns) do |worker|
|
||
|
Array.wrap(params[:user_ids]).compact.each do |user_id|
|
||
|
next if department.department_members.exists?(user_id: user_id)
|
||
|
|
||
|
worker.add(department_id: department.id, user_id: user_id)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|