cnmooc source url

pre_develop
p31729568 6 years ago
parent 02aa938fe4
commit 3d1e29cf0a

@ -37,6 +37,16 @@ module Mobile
CnmoocsService.new.create_user params
end
desc "获取资源访问地址"
params do
requires :userId, type: Integer, desc: "用户ID"
requires :resouceId, type: String, desc: "资源唯一标示"
requires :accessType, type: Integer, desc: "资源类型"
end
get "source_url" do
CnmoocsService.new.source_url(params)
end
desc "远程登录"
params do
requires :mail, type: String, desc: "邮箱地址"

@ -207,6 +207,9 @@ class ApplicationController < ActionController::Base
elsif session[:wechat_openid]
uw = UserWechat.find_by_openid(session[:wechat_openid])
user = uw.user if uw
elsif session[:third_party_user_id]
c_user = UserSource.find_by_id(session[:third_party_user_id])
user = c_user.user if c_user
end
end
if user.nil? && Setting.rest_api_enabled? && accept_api_auth?

@ -269,6 +269,8 @@ class User < Principal
has_many :article_homepages, :dependent => :destroy
has_many :competition_lists, :dependent => :destroy
has_one :user_source
## end
# default_scope -> { includes(:user_extensions, :user_score) }

@ -82,6 +82,20 @@ class CnmoocsService
end
def source_url(params)
if session[:third_party_user_id].blank?
user = User.find(params[:userId])
session[:third_party_user_id] = user.user_source.id
end
shixun = Shixun.find_by_identifier(params[:resouceId])
if shixun.blank?
return { error: -1, messages: '资源不存在' }
end
{ error: 0, messages: '成功', accessUrl: "#{Redmine::Configuration['educoder_domain']}/shixuns/#{shixun.id}" }
end
private
def shixun_data shixuns

Loading…
Cancel
Save