|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
#encoding=utf-8
|
|
|
|
|
require 'net/http'
|
|
|
|
|
|
|
|
|
|
class EcloudController < ApplicationController
|
|
|
|
|
skip_before_filter :verify_authenticity_token
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
|
|
|
|
|
render file: 'public/react-oschina/build/index.html', :layout => false
|
|
|
|
@ -21,12 +24,49 @@ class EcloudController < ApplicationController
|
|
|
|
|
redirect_to "https://gitee.com/oauth/authorize?client_id=#{CLIENT_ID}&redirect_uri=#{ROOT_URl}/oschina/login_cb&response_type=code"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def open_bs
|
|
|
|
|
Eclouduser.create(ecloudeuser_params)
|
|
|
|
|
# 企业开通
|
|
|
|
|
def bs_new
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 企业更新
|
|
|
|
|
def bs_update
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy_bs
|
|
|
|
|
# 用户业务开通接口
|
|
|
|
|
def ps_new
|
|
|
|
|
begin
|
|
|
|
|
ecloud_user = EcloudUser.where(:custid => params['custid'], :user_id => params['users']['userid']).first
|
|
|
|
|
if ecloud_user.present?
|
|
|
|
|
render :json => {code: 501, msg: "你已开通过该业务"}
|
|
|
|
|
else
|
|
|
|
|
EcloudUser.create!(custid: params['custid'], opttype: params['users']['opttype'], userid: params['users']['userid'],
|
|
|
|
|
username: params['users']['username'], useralias: params['users']['useralias'],
|
|
|
|
|
mobile: params['users']['mobile'], email: params['users']['email'], begintime: params['users']['begintime'].to_s,
|
|
|
|
|
endtime: params['users']['endtime'].to_s)
|
|
|
|
|
render :json => {success: true, errmsg: ""}
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
logger.error(e.message)
|
|
|
|
|
render :json => {code: 500, msg: "#{e.message}"}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 用户业务变更、销毁接口
|
|
|
|
|
def ps_update
|
|
|
|
|
begin
|
|
|
|
|
ecloud_user = EcloudUser.where(:custid => params['custid'], :user_id => params['users']['userid']).first
|
|
|
|
|
if ecloud_user.present?
|
|
|
|
|
ecloud_user.update_attributes(opttype: params['users']['opttype'])
|
|
|
|
|
render :json => {code: 501, msg: "你已开通过该业务"}
|
|
|
|
|
else
|
|
|
|
|
render :json => {code: 404, errmsg: ""}
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
logger.error(e.message)
|
|
|
|
|
render :json => {code: 500, msg: "#{e.message}"}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def ecloud_login_callback
|
|
|
|
@ -35,8 +75,8 @@ class EcloudController < ApplicationController
|
|
|
|
|
#
|
|
|
|
|
logger.debug params
|
|
|
|
|
url = "https://221.176.54.92:9081/restful/services/oauth2/authorization?grant_type=authorization_code" +
|
|
|
|
|
"&client_id=#{CLIENT_ID}&scope=&redirect_uri=&code=#{params[:code]}"
|
|
|
|
|
# url = "https://gitee.com/oauth/token?grant_type=authorization_code"+
|
|
|
|
|
"&client_id=#{CLIENT_ID}&scope=&redirect_uri=&code=#{params[:code]}"
|
|
|
|
|
# url = "https://gitee.com/oauth/token?grant_type=authorization_code"+
|
|
|
|
|
# "&code=#{params[:code]}&client_id=#{CLIENT_ID}&redirect_uri=#{ROOT_URl}/oschina/login_cb&client_secret=#{CLIENT_SECRET}"
|
|
|
|
|
|
|
|
|
|
res = post(url)
|
|
|
|
@ -101,4 +141,8 @@ class EcloudController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
def ecloudeuser_params
|
|
|
|
|
{}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|