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.
24 lines
895 B
24 lines
895 B
# 申请成为老师加入课堂 消息通知
|
|
class ApplyTeacherRoleJoinCourseNotifyJob < ApplicationJob
|
|
queue_as :notify
|
|
|
|
def perform(user_id, course_id, role)
|
|
user = User.find_by(id: user_id)
|
|
course = Course.find_by(id: course_id)
|
|
return if user.blank? || course.blank?
|
|
|
|
attrs = %i[user_id trigger_user_id container_id container_type belong_container_id
|
|
belong_container_type tiding_type extra created_at updated_at]
|
|
|
|
same_attrs = {
|
|
trigger_user_id: user.id, container_id: course.id, container_type: 'JoinCourse',
|
|
belong_container_id: course.id, belong_container_type: 'Course', tiding_type: 'Apply', extra: role
|
|
}
|
|
Tiding.bulk_insert(*attrs) do |worker|
|
|
course.teachers_without_assistant_professor.each do |teacher|
|
|
worker.add same_attrs.merge(user_id: teacher.user_id)
|
|
end
|
|
end
|
|
end
|
|
end
|