From 031b93f7cfb0db09cf14eb270b34a80c327d039b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 16 Aug 2019 13:48:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E8=AF=BE=E5=A0=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/duplicate_course_service.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/services/duplicate_course_service.rb b/app/services/duplicate_course_service.rb index 9d61984db..8d6ce4f72 100644 --- a/app/services/duplicate_course_service.rb +++ b/app/services/duplicate_course_service.rb @@ -38,7 +38,12 @@ class DuplicateCourseService < ApplicationService def copy_course_modules! origin_course.course_modules.each do |course_module| attrs = course_module.as_json(only: %i[module_type position hidden module_name]) - CourseModule.create!(attrs.merge(course_id: course.id)) + new_course_module = CourseModule.create!(attrs.merge(course_id: course.id)) + # 复制子目录 + course_module.course_second_categories.each do |second_category| + category_attr = second_category.as_json(only: %i[category_type name position]) + CourseSecondCategory.create!(category_attr.merge(course_id: course.id, course_module_id: new_course_module.id)) + end end end