Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_daiao
cxt 5 years ago
commit 727befb53f

@ -48,7 +48,9 @@ class HacksController < ApplicationController
hack.save!
# 创建测试集与代码
hack.hack_sets.create!(hack_sets_params)
hack.hack_codes.create!(hack_code_params.merge(modify_time: Time.now))
hack_codes = hack.hack_codes.new(hack_code_params)
hack_codes.modify_time = Time.now
hack_codes.save!
end
render_ok({identifier: hack.identifier})
rescue Exception => e
@ -67,10 +69,8 @@ class HacksController < ApplicationController
# 新建
@hack.hack_sets.create!(hack_sets_params)
# 更新代码
if params[:hack_codes][:code] != @hack.code
hack_code_params = hack_code_params.merge(modify_time: Time.now)
end
@hack.hack_codes.create!(hack_code_params)
code_params = params[:hack_codes][:code] != @hack.code ? hack_code_params.merge(modify_time: Time.now) : hack_code_params
@hack.hack_codes.first.update_attributes!(code_params)
end
render_ok
rescue Exception => e

@ -0,0 +1,6 @@
class AddIndexForHackCodes < ActiveRecord::Migration[5.2]
def change
HackCode.destroy_all
add_index :hack_codes, [:hack_id, :language], unique: true
end
end
Loading…
Cancel
Save