diff --git a/app/api/mobile/apis/cnmooc.rb b/app/api/mobile/apis/cnmooc.rb index 96b10101..7546fd58 100644 --- a/app/api/mobile/apis/cnmooc.rb +++ b/app/api/mobile/apis/cnmooc.rb @@ -43,6 +43,9 @@ module Mobile requires :accessType, type: Integer, desc: "资源类型" end get "source_url" do + user_source = UserSource.find_by_user_id(params[:userId]) + return {error: -1, messages: "用户不存在,请先创建用户"} if user_source.blank? + self.logged_user = user_source.user CnmoocsService.new.source_url(params) end diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index 24a9950e..3161eeac 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -115,9 +115,6 @@ class CnmoocsService end def source_url(params) - user_source = UserSource.find_by_user_id(params[:userId]) - return {error: -1, messages: "用户不存在,请先创建用户"} if user_source.blank? - self.logged_user = user_source.user shixun = Shixun.find_by_id(params[:resouceId]) if shixun.blank? return { error: -1, messages: '资源不存在' }