From 2b28b608283a3fac3eeb72116423c07da72a9910 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 13 Mar 2019 18:27:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E4=BA=91=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E5=BC=80=E9=80=9A=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 42 +++++++++++++++++-- app/models/ecloud.rb | 6 ++- app/models/ecloud_productpara.rb | 4 ++ app/models/ecloud_service.rb | 2 + app/models/ecloud_serviece_servicepara.rb | 4 ++ ...0190313090326_create_ecloud_productpara.rb | 11 +++++ ...0416_create_ecloud_serviece_servicepara.rb | 11 +++++ spec/factories/ecloud_productparas.rb | 7 ++++ .../factories/ecloud_serviece_serviceparas.rb | 7 ++++ spec/models/ecloud_productparas_spec.rb | 5 +++ .../ecloud_serviece_servicepara_spec.rb | 5 +++ 11 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 app/models/ecloud_productpara.rb create mode 100644 app/models/ecloud_serviece_servicepara.rb create mode 100644 db/migrate/20190313090326_create_ecloud_productpara.rb create mode 100644 db/migrate/20190313090416_create_ecloud_serviece_servicepara.rb create mode 100644 spec/factories/ecloud_productparas.rb create mode 100644 spec/factories/ecloud_serviece_serviceparas.rb create mode 100644 spec/models/ecloud_productparas_spec.rb create mode 100644 spec/models/ecloud_serviece_servicepara_spec.rb diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 096275bb..54a97aa6 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -1,4 +1,16 @@ #encoding=utf-8 +# 云启训练场(EduCoder)个人版 产品编码(appId) 9200108 +# 产品名称 计费类型 套餐编码 +# 云启训练场(EduCoder)个人版 固定包月 9200108001 +# 固定包月 9200108002 +# 固定包月 9200108003 +# --------------------------------------------------- +# 产品名称 计费类型 套餐编码 +# 云启训练场(EduCoder))院校版 包月+按license 9200109001 +# 包月+按license 9200109002 + +# 云启训练场(EduCoder))院校版 产品编码(appId) 9200109 + require 'net/http' require 'digest' @@ -45,9 +57,32 @@ class EcloudController < ApplicationController userid: params['userid'], username: params['username'], useralias: params['useralias'], mobile: params['mobile'], email: params['email'], productcode: params['productcode'], begintime: params['begintime'], endtime: params['endtime']) - services = params['services'].first - EcloudService.create(opttype: services['opttype'], code: services['code'], begintime: services['begintime'], - endtime: services['endtime'], ecloud_id: ecloud.try(:id)) + # 业务列表 + services = params['services'] + if services.present? + services.each do |service| + es = EcloudService.create(opttype: service['opttype'], code: service['code'], begintime: service['begintime'], + endtime: service['endtime'], ecloud_id: ecloud.try(:id)) + if service['serviceparas'].present? + service['serviceparas'].each do |servicepara| + EcloudServieceServicepara.create!(ecloud_service_id: es.id, key: servicepara['key'], value: servicepara['value']) + end + end + end + end + + # 应用开通参数 + productparas = params['productparas'] + if productparas.present? + productparas.each do |productpara| + EcloudProductpara.create!(key: productpara['key'], value: productpara['value'], ecloud_id: ecloud.try(:id)) + end + end + + # 为管理员单独创建一条账号,企业账号 + EcloudUser.create!(ecloud_id: ecloud.try(:id), opttype: params['opttype'], userid: params['userid'], + username: params['username'], useralias: params['useralias'], + mobile: params['mobile'], email: params['email']) render :json => {result: true, errmsg: ""} rescue Exception => e @@ -79,6 +114,7 @@ class EcloudController < ApplicationController end # 用户业务开通与变更接口 + # 授权statu为1,取消授权status为0 def ps_new begin user_params = params['users'] diff --git a/app/models/ecloud.rb b/app/models/ecloud.rb index fc23d00a..b9f81d5b 100644 --- a/app/models/ecloud.rb +++ b/app/models/ecloud.rb @@ -1,7 +1,11 @@ +#encoding=utf-8 class Ecloud < ActiveRecord::Base attr_accessible :applyno, :begintime, :bossorderid, :custcode, :custid, :custname, :custtype, :ecordercode, :endtime, :mobile, :opttype, :productcode, :registersource, :string, :trial, :useralias, :userid, :username, :email, :effecttime, :operatime + + has_many :ecloud_service # 业务列表 + has_many :ecloud_productparas # 开通参数列表 + has_one :ecloud_user - has_one :ecloud_service end diff --git a/app/models/ecloud_productpara.rb b/app/models/ecloud_productpara.rb new file mode 100644 index 00000000..ec1b94bc --- /dev/null +++ b/app/models/ecloud_productpara.rb @@ -0,0 +1,4 @@ +class EcloudProductpara < ActiveRecord::Base + attr_accessible :key, :value, :ecloud_id + belongs_to :ecloud +end diff --git a/app/models/ecloud_service.rb b/app/models/ecloud_service.rb index 596ad684..4a388ed4 100644 --- a/app/models/ecloud_service.rb +++ b/app/models/ecloud_service.rb @@ -1,3 +1,5 @@ class EcloudService < ActiveRecord::Base attr_accessible :begintime, :code, :endtime, :opttype, :ecloud_id, :packagecode, :bossorderid + belongs_to :ecloud + has_many :ecloud_serviece_serviceparas end diff --git a/app/models/ecloud_serviece_servicepara.rb b/app/models/ecloud_serviece_servicepara.rb new file mode 100644 index 00000000..91bb0a0d --- /dev/null +++ b/app/models/ecloud_serviece_servicepara.rb @@ -0,0 +1,4 @@ +class EcloudServieceServicepara < ActiveRecord::Base + attr_accessible :key, :value, :ecloud_service_id + belongs_to :ecloud_service +end diff --git a/db/migrate/20190313090326_create_ecloud_productpara.rb b/db/migrate/20190313090326_create_ecloud_productpara.rb new file mode 100644 index 00000000..df1271d6 --- /dev/null +++ b/db/migrate/20190313090326_create_ecloud_productpara.rb @@ -0,0 +1,11 @@ +class CreateEcloudProductpara < ActiveRecord::Migration + def change + create_table :ecloud_productparas do |t| + t.string :key + t.string :value + t.integer :ecloud_id + + t.timestamps + end + end +end diff --git a/db/migrate/20190313090416_create_ecloud_serviece_servicepara.rb b/db/migrate/20190313090416_create_ecloud_serviece_servicepara.rb new file mode 100644 index 00000000..22da21dd --- /dev/null +++ b/db/migrate/20190313090416_create_ecloud_serviece_servicepara.rb @@ -0,0 +1,11 @@ +class CreateEcloudServieceServicepara < ActiveRecord::Migration + def change + create_table :ecloud_serviece_serviceparas do |t| + t.string :key + t.string :value + t.integer :ecloud_service_id + + t.timestamps + end + end +end diff --git a/spec/factories/ecloud_productparas.rb b/spec/factories/ecloud_productparas.rb new file mode 100644 index 00000000..c206a57f --- /dev/null +++ b/spec/factories/ecloud_productparas.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :ecloud_productpara, :class => 'EcloudProductparas' do + key "MyString" +value "MyString" + end + +end diff --git a/spec/factories/ecloud_serviece_serviceparas.rb b/spec/factories/ecloud_serviece_serviceparas.rb new file mode 100644 index 00000000..5a1f5e7d --- /dev/null +++ b/spec/factories/ecloud_serviece_serviceparas.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :ecloud_serviece_servicepara, :class => 'EcloudServieceServicepara' do + key "MyString" +value "MyString" + end + +end diff --git a/spec/models/ecloud_productparas_spec.rb b/spec/models/ecloud_productparas_spec.rb new file mode 100644 index 00000000..ec9a177f --- /dev/null +++ b/spec/models/ecloud_productparas_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe EcloudProductparas, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/ecloud_serviece_servicepara_spec.rb b/spec/models/ecloud_serviece_servicepara_spec.rb new file mode 100644 index 00000000..0ea7e787 --- /dev/null +++ b/spec/models/ecloud_serviece_servicepara_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe EcloudServieceServicepara, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end