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.
17 lines
411 B
17 lines
411 B
6 years ago
|
class Ecs::LinkCourseService < ApplicationService
|
||
|
Error = Class.new(StandardError)
|
||
|
|
||
|
attr_reader :ec_course, :params
|
||
|
|
||
|
def initialize(ec_course, params)
|
||
|
@ec_course = ec_course
|
||
|
@params = params
|
||
|
end
|
||
|
|
||
|
def call
|
||
|
course = Course.find_by(id: params[:course_id])
|
||
|
raise Error, '课程不存在' if course.blank?
|
||
|
|
||
|
ec_course.ec_major_courses.create!(course: course)
|
||
|
end
|
||
|
end
|