diff --git a/app/controllers/ec_years_controller.rb b/app/controllers/ec_years_controller.rb index c2563867..e07e8804 100644 --- a/app/controllers/ec_years_controller.rb +++ b/app/controllers/ec_years_controller.rb @@ -387,6 +387,14 @@ class EcYearsController < ApplicationController new_egs.save! # 记录新旧对应关系,为之后的中间表做记录 egs_record << [pre_egs.id, new_egs.id] + prev_ersvss = EcRequireSubVsStandard.where(:ec_graduation_subitem_id => pre_egs.id) + prev_ersvss.each do |prev_ersvs| + new_ersvss = EcRequireSubVsStandard.new + new_ersvss.attributes = prev_ersvs.attributes.dup.except("id", "ec_graduation_subitem_id") + new_ersvss.ec_graduation_subitem_id = new_egs.id + new_ersvss.save! + end + end end @@ -398,28 +406,29 @@ class EcYearsController < ApplicationController new_eto.ec_year_id = ec_year.id new_eto.save! - # 复制 "毕业要去 vs 培养目标" - pre_ervsos = EcRequirementVsObjective.where(:ec_training_objective_id => pre_eto.id) - pre_ervsos.each do |ervso| - new_ervso = EcRequirementVsObjective.new - new_ervso.attributes = ervso.attributes.dup.except("id", "ec_training_objective_id", "ec_graduation_requirement_id") - new_ervso.ec_training_objective_id = new_eto.id - new_egr_id = -1 - egr_record.each do |egr_id| - if egr_id[0] == ervso.id - new_egr_id = egr_id[1] - end - end - raise("找不对应的毕业要求") if new_egr_id == -1 - new_ervso.ec_graduation_requirement_id = new_egr_id - end - # 复制 "培养目标分项" pre_eto.ec_training_subitems.try(:each) do |pre_ets| new_ets = EcTrainingSubitem.new new_ets.attributes = pre_ets.attributes.dup.except("id", "ec_training_objective_id") new_ets.ec_training_objective_id = new_eto.id new_ets.save! + + # 复制 "毕业要去 vs 培养目标" + pre_ervsos = EcRequirementVsObjective.where(:ec_training_objective_id => pre_ets.id) + pre_ervsos.each do |ervso| + new_ervso = EcRequirementVsObjective.new + new_ervso.attributes = ervso.attributes.dup.except("id", "ec_training_objective_id", "ec_graduation_requirement_id") + new_ervso.ec_training_objective_id = new_ets.id + new_egr_id = -1 + egr_record.each do |egr_id| + if egr_id[0] == ervso.ec_graduation_requirement_id + new_egr_id = egr_id[1] + end + end + raise("找不对应的毕业要求") if new_egr_id == -1 + new_ervso.ec_graduation_requirement_id = new_egr_id + new_ervso.save! + end end end diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 47b0ca52..c1c6a564 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -5,6 +5,7 @@ require 'digest' class EcloudController < ApplicationController skip_before_filter :verify_authenticity_token + before_filter check_sign before_filter :user_setup before_filter :require_login, only: [:authorize] @@ -35,31 +36,44 @@ class EcloudController < ApplicationController # 企业开通 # ecordercode 唯一标志一个企业的订购关系 def bs_new - begin - ecloud = Ecloud.create!(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'], - trial: params['trial'], bossorderid: params['bossorderid'], custid: params['custid'], - custcode: params['custcode'], registersource: params['registersource'], custname: params['custname'], - userid: params['userid'], username: params['username'], useralias: params['useralias'], mobile: params['mobile'], - email: params['email'], productcode: params['productcode'], begintime: params['begintime'], - endtime: params['endtime']) - EcloudService.create(opttype: params['services']['opttype'], code: params['services']['code'], begintime: params['services']['begintime'], - endtime: params['services']['endtime'], ecloud_id: ecloud.try(:id)) - - render :json => {result: true, errmsg: ""} - rescue Exception => e - logger.error(e.message) - render :json => {code: 500, msg: "#{e.message}"} + ActiveRecord::Base.transaction do + begin + ecloud = Ecloud.create!(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'], + trial: params['trial'], bossorderid: params['bossorderid'], custid: params['custid'], custtype: params['custtype'], + custcode: params['custcode'], registersource: params['registersource'], custname: params['custname'], + 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)) + + render :json => {result: true, errmsg: ""} + rescue Exception => e + logger.error(e.message) + render :json => {code: 500, msg: "#{e.message}"} + raise ActiveRecord::Rollback + end end end # 企业更新 def bs_update - ecloud = Ecloud.where(custid: params['custid']).first - ecloud.update_attribute(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'], - custid: params['custid'], custcode: params['custcode'], productcode: params['productcode'], - operatime: params['operatime'], effecttime: params['effecttime']) - ecloud.ecloud_services.update_attributes(packagecode: params['services']['packagecode'], bossorderid: params['services']['bossorderid']) - + ActiveRecord::Base.transaction do + begin + ecloud = Ecloud.where(custid: params['custid']).first + ecloud.update_attribute(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'], + custid: params['custid'], custcode: params['custcode'], productcode: params['productcode'], + operatime: params['operatime'], effecttime: params['effecttime']) + services = params['ervices'].first + ecloud.ecloud_services.update_attributes(packagecode: services['packagecode'], bossorderid: services['bossorderid']) + + rescue Exception => e + logger.error(e.message) + render :json => {code: 500, msg: "#{e.message}"} + raise ActiveRecord::Rollback + end + end end # 用户业务开通接口 @@ -171,7 +185,10 @@ class EcloudController < ApplicationController end private - def ecloudeuser_params - {} + def check_sign + public_key = '1022' + secret_key = '2112037a-6d7a-432b-9081-feb1153d8668' + timestamp = params['timestamp'] + end end diff --git a/app/controllers/oauth_controller.rb b/app/controllers/oauth_controller.rb index bcc12856..54f15c43 100644 --- a/app/controllers/oauth_controller.rb +++ b/app/controllers/oauth_controller.rb @@ -1,6 +1,6 @@ #encoding: utf-8 class OauthController < ApplicationController - + require include ApplicationHelper before_filter :user_setup diff --git a/app/models/ecloud_service.rb b/app/models/ecloud_service.rb index cc227eb1..596ad684 100644 --- a/app/models/ecloud_service.rb +++ b/app/models/ecloud_service.rb @@ -1,3 +1,3 @@ class EcloudService < ActiveRecord::Base - attr_accessible :begintime, :code, :endtime, :opttype + attr_accessible :begintime, :code, :endtime, :opttype, :ecloud_id, :packagecode, :bossorderid end diff --git a/public/react/src/modules/ec/graduatesRequirement/GraduatesRequirement.js b/public/react/src/modules/ec/graduatesRequirement/GraduatesRequirement.js index 827144b5..d6765e72 100644 --- a/public/react/src/modules/ec/graduatesRequirement/GraduatesRequirement.js +++ b/public/react/src/modules/ec/graduatesRequirement/GraduatesRequirement.js @@ -538,6 +538,7 @@ class GraduatesRequirement extends Component { daChengYuZhi: response.data.calculation_value, daChengYuZhiSaved: response.data.calculation_value, course_ids: response.data.course_ids, + is_manager: response.data.is_manager, calculating: false, }) } @@ -583,13 +584,14 @@ class GraduatesRequirement extends Component { } render() { const { match, history, current_user } = this.props - const { daChengYuZhiEditableMode, daChengYuZhi, daChengYuZhiSaved } = this.state + const { daChengYuZhiEditableMode, daChengYuZhi, daChengYuZhiSaved, is_manager } = this.state let { schooldata } =this.state; let { example_major, template_major } = schooldata; - let showCalculateButton = false; - if (example_major && current_user.admin || !example_major && template_major) { - showCalculateButton = true; - } + let showCalculateButton = is_manager; + // let showCalculateButton = false; + // if (example_major && current_user.admin || !example_major && template_major) { + // showCalculateButton = true; + // } return (