From 9a53cebc60f0e305a50da8fcbcb3bab162b98ff4 Mon Sep 17 00:00:00 2001 From: jasder duan Date: Tue, 12 Mar 2019 11:05:11 +0800 Subject: [PATCH 01/10] Update .gitignore --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b6b5a571..22dd62ec 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,8 @@ config/oneapm.yml /public/react-mobile7/build/.project /public/npm-debug.log /vendor -/workspace/* \ No newline at end of file +/workspace/* + + +.ruby-gemset +.rvmrc \ No newline at end of file From c5150fd29bf45dbdd104c4813153f5e17bed8443 Mon Sep 17 00:00:00 2001 From: jasder duan Date: Tue, 12 Mar 2019 11:05:44 +0800 Subject: [PATCH 02/10] FIX bug --- db/migrate/20190311082918_create_ecloudusers.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/db/migrate/20190311082918_create_ecloudusers.rb b/db/migrate/20190311082918_create_ecloudusers.rb index 5d4698ae..c6e9af60 100644 --- a/db/migrate/20190311082918_create_ecloudusers.rb +++ b/db/migrate/20190311082918_create_ecloudusers.rb @@ -4,23 +4,23 @@ class CreateEcloudusers < ActiveRecord::Migration t.string :applyno t.string :ecordercoder t.string :string - t.int :opttype + t.integer :opttype t.boolean :trial t.string :bossorderid - t.int :custid + t.integer :custid t.string :custcod t.string :string - t.int :custtype - t.int :registersource + t.integer :custtype + t.integer :registersource t.string :custname - t.int :userid + t.integer :userid t.string :username t.string :useralias t.string :moblile t.string :email t.string :productcode - t.long :begintime - t.long :endtime + t.datetime :begintime + t.datetime :endtime t.string :productparas t.string :services From 265a92810946635b8dab5a97df5a55e72231b18d Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 12 Mar 2019 11:12:40 +0800 Subject: [PATCH 03/10] =?UTF-8?q?ecloud=E7=9B=B8=E5=85=B3=E8=A1=A8?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 55 +++++++++++++++++-- app/models/ecloud.rb | 5 ++ app/models/ecloud_service.rb | 3 + app/models/ecloud_users.rb | 3 + app/models/eclouduser.rb | 7 --- config/routes.rb | 1 + .../20190311082918_create_ecloudusers.rb | 30 ---------- .../20190312021600_create_ecloud_user.rb | 18 ++++++ db/migrate/20190312030525_create_eclouds.rb | 25 +++++++++ .../20190312030722_create_ecloud_services.rb | 13 +++++ spec/factories/ecloud_services.rb | 9 +++ spec/factories/ecloud_users.rb | 14 +++++ spec/factories/eclouds.rb | 23 ++++++++ spec/models/ecloud_service_spec.rb | 5 ++ spec/models/ecloud_spec.rb | 5 ++ spec/models/ecloud_users_spec.rb | 5 ++ 16 files changed, 178 insertions(+), 43 deletions(-) create mode 100644 app/models/ecloud.rb create mode 100644 app/models/ecloud_service.rb create mode 100644 app/models/ecloud_users.rb delete mode 100644 app/models/eclouduser.rb delete mode 100644 db/migrate/20190311082918_create_ecloudusers.rb create mode 100644 db/migrate/20190312021600_create_ecloud_user.rb create mode 100644 db/migrate/20190312030525_create_eclouds.rb create mode 100644 db/migrate/20190312030722_create_ecloud_services.rb create mode 100644 spec/factories/ecloud_services.rb create mode 100644 spec/factories/ecloud_users.rb create mode 100644 spec/factories/eclouds.rb create mode 100644 spec/models/ecloud_service_spec.rb create mode 100644 spec/models/ecloud_spec.rb create mode 100644 spec/models/ecloud_users_spec.rb diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index d88ec86a..c3406294 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -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 diff --git a/app/models/ecloud.rb b/app/models/ecloud.rb new file mode 100644 index 00000000..3c251d41 --- /dev/null +++ b/app/models/ecloud.rb @@ -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 diff --git a/app/models/ecloud_service.rb b/app/models/ecloud_service.rb new file mode 100644 index 00000000..cc227eb1 --- /dev/null +++ b/app/models/ecloud_service.rb @@ -0,0 +1,3 @@ +class EcloudService < ActiveRecord::Base + attr_accessible :begintime, :code, :endtime, :opttype +end diff --git a/app/models/ecloud_users.rb b/app/models/ecloud_users.rb new file mode 100644 index 00000000..9266adb7 --- /dev/null +++ b/app/models/ecloud_users.rb @@ -0,0 +1,3 @@ +class EcloudUser < ActiveRecord::Base + attr_accessible :begintime, :email, :endtime, :mobile, :opttype, :paras, :useralias, :userid, :username, :custid +end diff --git a/app/models/eclouduser.rb b/app/models/eclouduser.rb deleted file mode 100644 index d472e3f3..00000000 --- a/app/models/eclouduser.rb +++ /dev/null @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 8e414caa..e94cb41d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/db/migrate/20190311082918_create_ecloudusers.rb b/db/migrate/20190311082918_create_ecloudusers.rb deleted file mode 100644 index 5d4698ae..00000000 --- a/db/migrate/20190311082918_create_ecloudusers.rb +++ /dev/null @@ -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 diff --git a/db/migrate/20190312021600_create_ecloud_user.rb b/db/migrate/20190312021600_create_ecloud_user.rb new file mode 100644 index 00000000..b4be20d4 --- /dev/null +++ b/db/migrate/20190312021600_create_ecloud_user.rb @@ -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 diff --git a/db/migrate/20190312030525_create_eclouds.rb b/db/migrate/20190312030525_create_eclouds.rb new file mode 100644 index 00000000..4a3b88b0 --- /dev/null +++ b/db/migrate/20190312030525_create_eclouds.rb @@ -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 diff --git a/db/migrate/20190312030722_create_ecloud_services.rb b/db/migrate/20190312030722_create_ecloud_services.rb new file mode 100644 index 00000000..32a58506 --- /dev/null +++ b/db/migrate/20190312030722_create_ecloud_services.rb @@ -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 diff --git a/spec/factories/ecloud_services.rb b/spec/factories/ecloud_services.rb new file mode 100644 index 00000000..0beea4d1 --- /dev/null +++ b/spec/factories/ecloud_services.rb @@ -0,0 +1,9 @@ +FactoryGirl.define do + factory :ecloud_service do + opttype 1 +code "MyString" +begintime "MyString" +endtime "MyString" + end + +end diff --git a/spec/factories/ecloud_users.rb b/spec/factories/ecloud_users.rb new file mode 100644 index 00000000..3494494c --- /dev/null +++ b/spec/factories/ecloud_users.rb @@ -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 diff --git a/spec/factories/eclouds.rb b/spec/factories/eclouds.rb new file mode 100644 index 00000000..38573918 --- /dev/null +++ b/spec/factories/eclouds.rb @@ -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 diff --git a/spec/models/ecloud_service_spec.rb b/spec/models/ecloud_service_spec.rb new file mode 100644 index 00000000..3e163414 --- /dev/null +++ b/spec/models/ecloud_service_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe EcloudService, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/ecloud_spec.rb b/spec/models/ecloud_spec.rb new file mode 100644 index 00000000..1e1d812f --- /dev/null +++ b/spec/models/ecloud_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Ecloud, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/ecloud_users_spec.rb b/spec/models/ecloud_users_spec.rb new file mode 100644 index 00000000..37a7a7a4 --- /dev/null +++ b/spec/models/ecloud_users_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe EcloudUsers, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 784172afcb299c52c1adf6c22bf10e42372cd038 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 12 Mar 2019 11:14:46 +0800 Subject: [PATCH 04/10] .. --- app/controllers/ecloud_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index c3406294..3d025b15 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -41,8 +41,9 @@ class EcloudController < ApplicationController 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, + 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 From 6517ee418fe2680598ba1726d599c7e2109601ad Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 12 Mar 2019 11:17:14 +0800 Subject: [PATCH 05/10] .. --- db/migrate/20190311082918_create_ecloudusers.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/db/migrate/20190311082918_create_ecloudusers.rb b/db/migrate/20190311082918_create_ecloudusers.rb index 5d4698ae..755275be 100644 --- a/db/migrate/20190311082918_create_ecloudusers.rb +++ b/db/migrate/20190311082918_create_ecloudusers.rb @@ -3,17 +3,15 @@ class CreateEcloudusers < ActiveRecord::Migration create_table :ecloudusers do |t| t.string :applyno t.string :ecordercoder - t.string :string - t.int :opttype + t.integer :opttype t.boolean :trial t.string :bossorderid - t.int :custid - t.string :custcod - t.string :string - t.int :custtype - t.int :registersource + t.integer :custid + t.string :custcode + t.integer :registersource + t.integer :custtype t.string :custname - t.int :userid + t.integer :userid t.string :username t.string :useralias t.string :moblile From a6445b85f13d10c51c772ee1c28aac81fa75d0bd Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 12 Mar 2019 11:22:00 +0800 Subject: [PATCH 06/10] .. --- db/migrate/20190312021600_create_ecloud_user.rb | 2 +- db/migrate/20190312030525_create_eclouds.rb | 2 +- ...loud_services.rb => 20190312030722_create_ecloud_service.rb} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename db/migrate/{20190312030722_create_ecloud_services.rb => 20190312030722_create_ecloud_service.rb} (80%) diff --git a/db/migrate/20190312021600_create_ecloud_user.rb b/db/migrate/20190312021600_create_ecloud_user.rb index b4be20d4..83e0e552 100644 --- a/db/migrate/20190312021600_create_ecloud_user.rb +++ b/db/migrate/20190312021600_create_ecloud_user.rb @@ -1,4 +1,4 @@ -class CreateEcloudUsers < ActiveRecord::Migration +class EcloudUser < ActiveRecord::Migration def change create_table :ecloud_users do |t| t.integer :opttype diff --git a/db/migrate/20190312030525_create_eclouds.rb b/db/migrate/20190312030525_create_eclouds.rb index 4a3b88b0..306e73d0 100644 --- a/db/migrate/20190312030525_create_eclouds.rb +++ b/db/migrate/20190312030525_create_eclouds.rb @@ -1,4 +1,4 @@ -class CreateEclouds < ActiveRecord::Migration +class Ecloud < ActiveRecord::Migration def change create_table :eclouds do |t| t.string :applyno diff --git a/db/migrate/20190312030722_create_ecloud_services.rb b/db/migrate/20190312030722_create_ecloud_service.rb similarity index 80% rename from db/migrate/20190312030722_create_ecloud_services.rb rename to db/migrate/20190312030722_create_ecloud_service.rb index 32a58506..ed41f868 100644 --- a/db/migrate/20190312030722_create_ecloud_services.rb +++ b/db/migrate/20190312030722_create_ecloud_service.rb @@ -1,4 +1,4 @@ -class CreateEcloudServices < ActiveRecord::Migration +class EcloudService < ActiveRecord::Migration def change create_table :ecloud_services do |t| t.integer :opttype From 3afe376f94e91ab7a28989a9f6557347e9a3fd46 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 12 Mar 2019 11:30:23 +0800 Subject: [PATCH 07/10] =?UTF-8?q?ecloud=E8=A1=A8=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/ecloud.rb | 2 +- app/models/{ecloud_users.rb => ecloud_user.rb} | 0 db/migrate/20190312021600_create_ecloud_user.rb | 2 +- ...030525_create_eclouds.rb => 20190312030525_create_ecloud.rb} | 2 +- db/migrate/20190312030722_create_ecloud_service.rb | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename app/models/{ecloud_users.rb => ecloud_user.rb} (100%) rename db/migrate/{20190312030525_create_eclouds.rb => 20190312030525_create_ecloud.rb} (92%) diff --git a/app/models/ecloud.rb b/app/models/ecloud.rb index 3c251d41..dc14eddc 100644 --- a/app/models/ecloud.rb +++ b/app/models/ecloud.rb @@ -1,5 +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_users, destroy: :dependence has_many :ecloud_services, destroy: :dependence end diff --git a/app/models/ecloud_users.rb b/app/models/ecloud_user.rb similarity index 100% rename from app/models/ecloud_users.rb rename to app/models/ecloud_user.rb diff --git a/db/migrate/20190312021600_create_ecloud_user.rb b/db/migrate/20190312021600_create_ecloud_user.rb index 83e0e552..6a3221e3 100644 --- a/db/migrate/20190312021600_create_ecloud_user.rb +++ b/db/migrate/20190312021600_create_ecloud_user.rb @@ -1,4 +1,4 @@ -class EcloudUser < ActiveRecord::Migration +class CreateEcloudUser < ActiveRecord::Migration def change create_table :ecloud_users do |t| t.integer :opttype diff --git a/db/migrate/20190312030525_create_eclouds.rb b/db/migrate/20190312030525_create_ecloud.rb similarity index 92% rename from db/migrate/20190312030525_create_eclouds.rb rename to db/migrate/20190312030525_create_ecloud.rb index 306e73d0..989804bb 100644 --- a/db/migrate/20190312030525_create_eclouds.rb +++ b/db/migrate/20190312030525_create_ecloud.rb @@ -1,4 +1,4 @@ -class Ecloud < ActiveRecord::Migration +class CreateEcloud < ActiveRecord::Migration def change create_table :eclouds do |t| t.string :applyno diff --git a/db/migrate/20190312030722_create_ecloud_service.rb b/db/migrate/20190312030722_create_ecloud_service.rb index ed41f868..2c1c64d9 100644 --- a/db/migrate/20190312030722_create_ecloud_service.rb +++ b/db/migrate/20190312030722_create_ecloud_service.rb @@ -1,4 +1,4 @@ -class EcloudService < ActiveRecord::Migration +class CreateEcloudService < ActiveRecord::Migration def change create_table :ecloud_services do |t| t.integer :opttype From 9ed8741829d60b4de90d1002804ef5c169edd1d6 Mon Sep 17 00:00:00 2001 From: jasder duan Date: Tue, 12 Mar 2019 11:43:05 +0800 Subject: [PATCH 08/10] =?UTF-8?q?FIX=20=E8=A7=A3=E5=86=B3=E5=86=B2?= =?UTF-8?q?=E7=AA=81=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/ecloud.rb | 5 ++++ app/models/ecloud_service.rb | 3 +++ app/models/ecloud_users.rb | 3 +++ config/gitlab_config.rb | 9 +++++++ .../20190312021600_create_ecloud_user.rb | 18 +++++++++++++ db/migrate/20190312030525_create_eclouds.rb | 25 +++++++++++++++++++ .../20190312030722_create_ecloud_services.rb | 13 ++++++++++ spec/factories/ecloud_services.rb | 9 +++++++ spec/factories/ecloud_users.rb | 14 +++++++++++ spec/factories/eclouds.rb | 23 +++++++++++++++++ spec/models/ecloud_service_spec.rb | 5 ++++ spec/models/ecloud_spec.rb | 5 ++++ spec/models/ecloud_users_spec.rb | 5 ++++ 13 files changed, 137 insertions(+) create mode 100644 app/models/ecloud.rb create mode 100644 app/models/ecloud_service.rb create mode 100644 app/models/ecloud_users.rb create mode 100755 config/gitlab_config.rb create mode 100644 db/migrate/20190312021600_create_ecloud_user.rb create mode 100644 db/migrate/20190312030525_create_eclouds.rb create mode 100644 db/migrate/20190312030722_create_ecloud_services.rb create mode 100644 spec/factories/ecloud_services.rb create mode 100644 spec/factories/ecloud_users.rb create mode 100644 spec/factories/eclouds.rb create mode 100644 spec/models/ecloud_service_spec.rb create mode 100644 spec/models/ecloud_spec.rb create mode 100644 spec/models/ecloud_users_spec.rb diff --git a/app/models/ecloud.rb b/app/models/ecloud.rb new file mode 100644 index 00000000..3c251d41 --- /dev/null +++ b/app/models/ecloud.rb @@ -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 diff --git a/app/models/ecloud_service.rb b/app/models/ecloud_service.rb new file mode 100644 index 00000000..cc227eb1 --- /dev/null +++ b/app/models/ecloud_service.rb @@ -0,0 +1,3 @@ +class EcloudService < ActiveRecord::Base + attr_accessible :begintime, :code, :endtime, :opttype +end diff --git a/app/models/ecloud_users.rb b/app/models/ecloud_users.rb new file mode 100644 index 00000000..9266adb7 --- /dev/null +++ b/app/models/ecloud_users.rb @@ -0,0 +1,3 @@ +class EcloudUser < ActiveRecord::Base + attr_accessible :begintime, :email, :endtime, :mobile, :opttype, :paras, :useralias, :userid, :username, :custid +end diff --git a/config/gitlab_config.rb b/config/gitlab_config.rb new file mode 100755 index 00000000..0ec8f6e9 --- /dev/null +++ b/config/gitlab_config.rb @@ -0,0 +1,9 @@ +Gitlab.configure do |config| + # config.endpoint = 'http://192.168.41.130:3000/trustie/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT'] + # config.private_token = 'cK15gUDwvt8EEkzwQ_63' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN'] + config.endpoint = 'http://testbdgit.trustie.net/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT'] + config.private_token = 's89kqsMPtF8YLZSLyVmF' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN'] + # Optional + # config.user_agent = 'Custom User Agent' # user agent, default: 'Gitlab Ruby Gem [version]' + # config.sudo = 'user' # username for sudo mode, default: nil +end diff --git a/db/migrate/20190312021600_create_ecloud_user.rb b/db/migrate/20190312021600_create_ecloud_user.rb new file mode 100644 index 00000000..b4be20d4 --- /dev/null +++ b/db/migrate/20190312021600_create_ecloud_user.rb @@ -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 diff --git a/db/migrate/20190312030525_create_eclouds.rb b/db/migrate/20190312030525_create_eclouds.rb new file mode 100644 index 00000000..4a3b88b0 --- /dev/null +++ b/db/migrate/20190312030525_create_eclouds.rb @@ -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 diff --git a/db/migrate/20190312030722_create_ecloud_services.rb b/db/migrate/20190312030722_create_ecloud_services.rb new file mode 100644 index 00000000..32a58506 --- /dev/null +++ b/db/migrate/20190312030722_create_ecloud_services.rb @@ -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 diff --git a/spec/factories/ecloud_services.rb b/spec/factories/ecloud_services.rb new file mode 100644 index 00000000..0beea4d1 --- /dev/null +++ b/spec/factories/ecloud_services.rb @@ -0,0 +1,9 @@ +FactoryGirl.define do + factory :ecloud_service do + opttype 1 +code "MyString" +begintime "MyString" +endtime "MyString" + end + +end diff --git a/spec/factories/ecloud_users.rb b/spec/factories/ecloud_users.rb new file mode 100644 index 00000000..3494494c --- /dev/null +++ b/spec/factories/ecloud_users.rb @@ -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 diff --git a/spec/factories/eclouds.rb b/spec/factories/eclouds.rb new file mode 100644 index 00000000..38573918 --- /dev/null +++ b/spec/factories/eclouds.rb @@ -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 diff --git a/spec/models/ecloud_service_spec.rb b/spec/models/ecloud_service_spec.rb new file mode 100644 index 00000000..3e163414 --- /dev/null +++ b/spec/models/ecloud_service_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe EcloudService, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/ecloud_spec.rb b/spec/models/ecloud_spec.rb new file mode 100644 index 00000000..1e1d812f --- /dev/null +++ b/spec/models/ecloud_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Ecloud, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/ecloud_users_spec.rb b/spec/models/ecloud_users_spec.rb new file mode 100644 index 00000000..37a7a7a4 --- /dev/null +++ b/spec/models/ecloud_users_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe EcloudUsers, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 36b0e3d97fca08b728ec3be499d0fdf989e4653e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E7=94=B2=E7=94=9F?= Date: Tue, 12 Mar 2019 12:09:08 +0800 Subject: [PATCH 09/10] Delete --- db/migrate/20190312030525_create_ecloud.rb | 25 ------------------- .../20190312030722_create_ecloud_service.rb | 13 ---------- 2 files changed, 38 deletions(-) delete mode 100644 db/migrate/20190312030525_create_ecloud.rb delete mode 100644 db/migrate/20190312030722_create_ecloud_service.rb diff --git a/db/migrate/20190312030525_create_ecloud.rb b/db/migrate/20190312030525_create_ecloud.rb deleted file mode 100644 index 989804bb..00000000 --- a/db/migrate/20190312030525_create_ecloud.rb +++ /dev/null @@ -1,25 +0,0 @@ -class CreateEcloud < 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 diff --git a/db/migrate/20190312030722_create_ecloud_service.rb b/db/migrate/20190312030722_create_ecloud_service.rb deleted file mode 100644 index 2c1c64d9..00000000 --- a/db/migrate/20190312030722_create_ecloud_service.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateEcloudService < 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 From cb73a974250613507d646990d1eb0f7c8d869f05 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 12 Mar 2019 15:01:30 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 17 ++++++++++++++++- app/models/ecloud.rb | 4 ++-- config/routes.rb | 3 +++ .../20190312060516_add_index_to_ecloud.rb | 5 +++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20190312060516_add_index_to_ecloud.rb diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 3d025b15..5cc3d926 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -3,6 +3,11 @@ require 'net/http' class EcloudController < ApplicationController skip_before_filter :verify_authenticity_token + before_filter :user_setup + before_filter :require_login, only: [:authorize] + + + skip_before_filter :verify_authenticity_token, only: [:ps_new, :ps_edit] def index @@ -25,18 +30,28 @@ class EcloudController < ApplicationController end # 企业开通 + # ecordercode 唯一标志一个企业的订购关系 def bs_new + begin + Ecloud.create!(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'], trial: params['trial'], + bossorderid: params['bossorderid'], custid: params['custid'], custcode: params['custcode']) + render :json => {result: true, errmsg: ""} + rescue Exception => e + logger.error(e.message) + render :json => {code: 500, msg: "#{e.message}"} + end end # 企业更新 def bs_update - + end # 用户业务开通接口 def ps_new begin + logger.info("11111######params") ecloud_user = EcloudUser.where(:custid => params['custid'], :user_id => params['users']['userid']).first if ecloud_user.present? render :json => {code: 501, msg: "你已开通过该业务"} diff --git a/app/models/ecloud.rb b/app/models/ecloud.rb index dc14eddc..a089b6fd 100644 --- a/app/models/ecloud.rb +++ b/app/models/ecloud.rb @@ -1,5 +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_users, destroy: :dependence - has_many :ecloud_services, destroy: :dependence + has_many :ecloud_users + has_many :ecloud_services end diff --git a/config/routes.rb b/config/routes.rb index e94cb41d..525290a5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,9 @@ RedmineApp::Application.routes.draw do ## oauth相关 match 'ecloud/ecloud_login_callback', to: 'ecloud#ecloud_login_callback', :via => :get match 'ecloud/bs_new', to: 'ecloud#bs_new', :via => :post + match 'ecloud/bs_edit', to: 'ecloud#bs_edit', :via => :post + match 'ecloud/ps_new', to: 'ecloud#ps_new', :via => :post + match 'ecloud/ps_edit', to: 'ecloud#ps_edit', :via => :post resources :ec_course_evaluations do diff --git a/db/migrate/20190312060516_add_index_to_ecloud.rb b/db/migrate/20190312060516_add_index_to_ecloud.rb new file mode 100644 index 00000000..1a5db7c3 --- /dev/null +++ b/db/migrate/20190312060516_add_index_to_ecloud.rb @@ -0,0 +1,5 @@ +class AddIndexToEcloud < ActiveRecord::Migration + def change + add_index :eclouds, [:ecordercode, :custcode], :unique => true, :name => 'ecorder_cust_code' + end +end