ecloud相关表结构

dev_SaaS
huang 6 years ago
parent 528996f57d
commit 265a928109

@ -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,48 @@ 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 +74,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 +140,8 @@ class EcloudController < ApplicationController
end
end
private
def ecloudeuser_params
{}
end
end

@ -0,0 +1,5 @@
class Ecloud < ActiveRecord::Base
attr_accessible :applyno, :begintime, :bossorderid, :custcode, :custid, :custname, :custtype, :ecordercode, :endtime, :mobile, :opttype, :productcode, :registersource, :string, :trial, :useralias, :userid, :username
has_many :ecloud_userses, destroy: :dependence
has_many :ecloud_services, destroy: :dependence
end

@ -0,0 +1,3 @@
class EcloudService < ActiveRecord::Base
attr_accessible :begintime, :code, :endtime, :opttype
end

@ -0,0 +1,3 @@
class EcloudUser < ActiveRecord::Base
attr_accessible :begintime, :email, :endtime, :mobile, :opttype, :paras, :useralias, :userid, :username, :custid
end

@ -1,7 +0,0 @@
class Eclouduser < ActiveRecord::Base
attr_accessible :applyno, :begintime, :bossorderid, :code, :custcod, :custid, :custname, :custtype, :ecordercoder, :email,
:endtime, :key, :moblile, :opttype, :productcode, :registersource, :trial,
:useralias, :userid, :username, :productparas, :services
serialize :productparas, Hash
serialize :services, Hash
end

@ -34,6 +34,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
match 'oauth/userinfo', to: 'oauth#get_userinfo', :via => :get
match 'ecloud/ecloud_login_callback', to: 'ecloud#ecloud_login_callback', :via => :get
match 'ecloud/bs_new', to: 'ecloud#bs_new', :via => :post
resources :ec_course_evaluations do

@ -1,30 +0,0 @@
class CreateEcloudusers < ActiveRecord::Migration
def change
create_table :ecloudusers do |t|
t.string :applyno
t.string :ecordercoder
t.string :string
t.int :opttype
t.boolean :trial
t.string :bossorderid
t.int :custid
t.string :custcod
t.string :string
t.int :custtype
t.int :registersource
t.string :custname
t.int :userid
t.string :username
t.string :useralias
t.string :moblile
t.string :email
t.string :productcode
t.long :begintime
t.long :endtime
t.string :productparas
t.string :services
t.timestamps
end
end
end

@ -0,0 +1,18 @@
class CreateEcloudUsers < ActiveRecord::Migration
def change
create_table :ecloud_users do |t|
t.integer :opttype
t.integer :userid
t.string :username
t.string :useralias
t.string :mobile
t.string :email
t.string :begintime
t.string :endtime
t.string :paras
t.integer :custid
t.timestamps
end
end
end

@ -0,0 +1,25 @@
class CreateEclouds < ActiveRecord::Migration
def change
create_table :eclouds do |t|
t.string :applyno
t.string :ecordercode
t.integer :opttype
t.boolean :trial
t.string :bossorderid
t.integer :custid
t.string :custcode
t.integer :registersource
t.integer :custtype
t.string :custname
t.integer :userid
t.string :username
t.string :useralias
t.string :mobile
t.string :productcode
t.string :begintime
t.string :endtime
t.timestamps
end
end
end

@ -0,0 +1,13 @@
class CreateEcloudServices < ActiveRecord::Migration
def change
create_table :ecloud_services do |t|
t.integer :opttype
t.string :code
t.string :begintime
t.string :endtime
t.integer :ecloud_id
t.timestamps
end
end
end

@ -0,0 +1,9 @@
FactoryGirl.define do
factory :ecloud_service do
opttype 1
code "MyString"
begintime "MyString"
endtime "MyString"
end
end

@ -0,0 +1,14 @@
FactoryGirl.define do
factory :ecloud_user, :class => 'EcloudUsers' do
opttype 1
userid 1
username "MyString"
useralias "MyString"
mobile "MyString"
email "MyString"
begintime 1
endtime 1
paras "MyString"
end
end

@ -0,0 +1,23 @@
FactoryGirl.define do
factory :ecloud do
applyno "MyString"
string "MyString"
ecordercode "MyString"
opttype 1
trial false
bossorderid "MyString"
custid 1
custcode "MyString"
registersource 1
custtype 1
custname "MyString"
userid 1
username "MyString"
useralias "MyString"
mobile "MyString"
productcode "MyString"
begintime "MyString"
endtime "MyString"
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe EcloudService, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Ecloud, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe EcloudUsers, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save