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