毕设任务的题库

dev_aliyun_beta
cxt 6 years ago
parent bb2f8c67ac
commit 2dace6763a

@ -8,8 +8,11 @@ class GtopicBanksController < ApplicationController
end end
def update def update
@bank.update_attributes(gtopic_bank_params) ActiveRecord::Base.transaction do
Attachment.associate_container(params[:attachment_ids], @bank.id, @bank.class) if params[:attachment_ids] @bank.update_attributes(gtopic_bank_params)
Attachment.associate_container(params[:attachment_ids], @bank.id, @bank.class) if params[:attachment_ids]
normal_status(0, "更新成功")
end
end end
private private

@ -8,8 +8,17 @@ class TaskBanksController < ApplicationController
end end
def update def update
@bank.update_attributes(gtask_bank_params) ActiveRecord::Base.transaction do
Attachment.associate_container(params[:attachment_ids], @graduation_topic.id, @graduation_topic.class) if params[:attachment_ids] begin
@bank.update_attributes(gtask_bank_params)
Attachment.associate_container(params[:attachment_ids], @bank.id, @bank.class) if params[:attachment_ids]
normal_status(0, "更新成功")
rescue Exception => e
uid_logger(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
end end
private private
@ -24,9 +33,16 @@ class TaskBanksController < ApplicationController
end end
def gtask_bank_params def gtask_bank_params
tip_exception("name参数不能为空") if params[:gtopic_bank][:name].blank? tip_exception("name参数不能为空") if params[:gtask_bank][:name].blank?
tip_exception("description参数不能为空") if params[:gtopic_bank][:description].blank? tip_exception("description参数不能为空") if params[:gtask_bank][:description].blank?
params.require(:gtopic_bank).permit(:name, :topic_type, :topic_source, :topic_property_first, :description, if @bank.homework_type == 3
:topic_property_second, :source_unit, :topic_repeat, :province, :city) tip_exception("base_on_project参数不能为空") if params[:gtask_bank][:base_on_project].nil?
tip_exception("min_num参数不能为空") if params[:gtask_bank][:min_num].blank?
tip_exception("max_num参数不能为空") if params[:gtask_bank][:max_num].blank?
tip_exception("最小人数不能小于1") if params[:gtask_bank][:min_num].to_i < 1
tip_exception("最大人数不能小于最小人数") if params[:gtask_bank][:max_num].to_i < params[:gtask_bank][:min_num].to_i
end
params.require(:gtask_bank).permit(:name, :description) if @bank.task_type == 1
params.require(:gtask_bank).permit(:name, :description, :min_num, :max_num, :base_on_project) if @bank.task_type == 2
end end
end end

@ -642,6 +642,7 @@ Rails.application.routes.draw do
end end
resources :gtopic_banks resources :gtopic_banks
resources :task_banks
resources :attachments resources :attachments

Loading…
Cancel
Save