From 5113d5cb3643108dfd705f36e6543a24db2cbfb6 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 13 Mar 2019 14:31:54 +0800 Subject: [PATCH] =?UTF-8?q?ecloud=5Fuser=E6=B7=BB=E5=8A=A0status=E6=A0=87?= =?UTF-8?q?=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 14 +++++++------- app/models/ecloud_user.rb | 2 +- .../20190313062414_add_status_to_ecloud_user.rb | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20190313062414_add_status_to_ecloud_user.rb diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index f5e97720..04d0050b 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -86,11 +86,11 @@ class EcloudController < ApplicationController # if ecloud_user.present? # render :json => {code: 500, msg: "你已开通过该业务"} # else - EcloudUser.create!(custid: params['custid'], opttype: user_param['opttype'], userid: user_param['userid'], - username: user_param['username'], useralias: user_param['useralias'], - mobile: user_param['mobile'], email: user_param['email'], begintime: user_param['begintime'].to_s, - endtime: user_param['endtime'].to_s) - render :json => {success: true, errmsg: ""} + EcloudUser.create!(custid: params['custid'], opttype: user_param['opttype'], userid: user_param['userid'], + username: user_param['username'], useralias: user_param['useralias'], + mobile: user_param['mobile'], email: user_param['email'], begintime: user_param['begintime'].to_s, + endtime: user_param['endtime'].to_s, status: 1) + render :json => {success: true, errmsg: ""} # end rescue Exception => e logger.error(e.message) @@ -103,9 +103,9 @@ class EcloudController < ApplicationController begin ecloud = Ecloud.where(applyno: params['applyno']).first user_param = params['users'].first - ecloud_user = EcloudUser.where(ecloud_id: ecloud.id).first + ecloud_user = EcloudUser.where(userid: user_param['userid'], status: 0).first - ecloud_user.update_attributes(opttype: user_param['opttype'], userid: user_param['userid']) + ecloud_user.update_attributes(opttype: user_param['opttype'], userid: user_param['userid'], status: 0) render :json => {success: true, errmsg: ""} # else # render :json => {code: 404, msg: "企业ID不存在"} diff --git a/app/models/ecloud_user.rb b/app/models/ecloud_user.rb index 9266adb7..dd4a5584 100644 --- a/app/models/ecloud_user.rb +++ b/app/models/ecloud_user.rb @@ -1,3 +1,3 @@ class EcloudUser < ActiveRecord::Base - attr_accessible :begintime, :email, :endtime, :mobile, :opttype, :paras, :useralias, :userid, :username, :custid + attr_accessible :begintime, :email, :endtime, :mobile, :opttype, :paras, :useralias, :userid, :username, :custid, :status, :ecloud_id end diff --git a/db/migrate/20190313062414_add_status_to_ecloud_user.rb b/db/migrate/20190313062414_add_status_to_ecloud_user.rb new file mode 100644 index 00000000..bedecfb3 --- /dev/null +++ b/db/migrate/20190313062414_add_status_to_ecloud_user.rb @@ -0,0 +1,5 @@ +class AddStatusToEcloudUser < ActiveRecord::Migration + def change + add_column :ecloud_users, :status, :integer, :limit => 1 + end +end