From 528996f57d64b25fc76fe532bb90070d33473647 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 11 Mar 2019 16:51:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E5=BC=80=E9=80=9A=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 9 +++++- app/models/eclouduser.rb | 7 +++++ .../20190311082918_create_ecloudusers.rb | 30 +++++++++++++++++++ spec/factories/ecloudusers.rb | 28 +++++++++++++++++ spec/models/eclouduser_spec.rb | 5 ++++ 5 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 app/models/eclouduser.rb create mode 100644 db/migrate/20190311082918_create_ecloudusers.rb create mode 100644 spec/factories/ecloudusers.rb create mode 100644 spec/models/eclouduser_spec.rb diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index a8f9a32a..d88ec86a 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -21,6 +21,13 @@ 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) + end + + def destroy_bs + + end def ecloud_login_callback #获取code @@ -42,7 +49,7 @@ class EcloudController < ApplicationController #获取此用户信息 - res = get("https://gitee.com/api/v5/user?access_token=#{body["access_token"]}") + # res = get("https://gitee.com/api/v5/user?access_token=#{body["access_token"]}") res = get("https://221.176.54.92:9081/restful/services/user/info?access_token=#{body["access_token"]}&userid=%7bUSERID%7d") logger.debug res diff --git a/app/models/eclouduser.rb b/app/models/eclouduser.rb new file mode 100644 index 00000000..d472e3f3 --- /dev/null +++ b/app/models/eclouduser.rb @@ -0,0 +1,7 @@ +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 diff --git a/db/migrate/20190311082918_create_ecloudusers.rb b/db/migrate/20190311082918_create_ecloudusers.rb new file mode 100644 index 00000000..5d4698ae --- /dev/null +++ b/db/migrate/20190311082918_create_ecloudusers.rb @@ -0,0 +1,30 @@ +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 diff --git a/spec/factories/ecloudusers.rb b/spec/factories/ecloudusers.rb new file mode 100644 index 00000000..2222901e --- /dev/null +++ b/spec/factories/ecloudusers.rb @@ -0,0 +1,28 @@ +FactoryGirl.define do + factory :eclouduser do + applyno "MyString" + ecordercoder "MyString" + string "MyString" + opttype "" + trial false + bossorderid "MyString" + custid "" + custcod "MyString" + string "MyString" + custtype "" + registersource "" + custname "MyString" + userid "" + username "MyString" + useralias "MyString" + moblile "MyString" + email "MyString" + productcode "MyString" + begintime "" + endtime "" + key "MyString" + value "MyString" + opttype "" + code "MyString" + end +end diff --git a/spec/models/eclouduser_spec.rb b/spec/models/eclouduser_spec.rb new file mode 100644 index 00000000..2c63612a --- /dev/null +++ b/spec/models/eclouduser_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Eclouduser, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end