dev_jupyter
cxt 5 years ago
parent 2ac99588ac
commit 58482e5f9e

@ -23,19 +23,21 @@ class ApplicationController < ActionController::Base
# 所有请求必须合法签名
def check_sign
Rails.logger.info("66666 #{params}")
suffix = request.url.split(".").last.split("?").first
suffix_arr = ["xls", "xlsx", "pdf"] # excel文件先注释
unless suffix_arr.include?(suffix)
if params[:client_key].present?
randomcode = params[:randomcode]
# tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5)
sign = Digest::MD5.hexdigest("#{OPENKEY}#{randomcode}")
Rails.logger.info("2222 #{sign}")
tip_exception(501, "请求不合理") if sign != params[:client_key]
else
tip_exception(501, "请求不合理")
unless Rails.env.development?
Rails.logger.info("66666 #{params}")
suffix = request.url.split(".").last.split("?").first
suffix_arr = ["xls", "xlsx", "pdf"] # excel文件先注释
unless suffix_arr.include?(suffix)
if params[:client_key].present?
randomcode = params[:randomcode]
# tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5)
sign = Digest::MD5.hexdigest("#{OPENKEY}#{randomcode}")
Rails.logger.info("2222 #{sign}")
tip_exception(501, "请求不合理") if sign != params[:client_key]
else
tip_exception(501, "请求不合理")
end
end
end
end

@ -61,7 +61,7 @@ class HacksController < ApplicationController
hack_codes = hack.hack_codes.new(hack_code_params)
hack_codes.modify_time = Time.now
hack_codes.save!
new_item_params = item_params.merge({container: hack, item_type: 'PROGRAM', difficulty: params[:difficult], user_id: current_user.id})
new_item_params = item_params.merge({container: hack, item_type: 'PROGRAM', difficulty: params[:hack][:difficult], user_id: current_user.id})
ItemBank.create!(new_item_params)
end
render_ok({identifier: hack.identifier})
@ -95,7 +95,7 @@ class HacksController < ApplicationController
# 更新题库相关记录
if @hack.item_bank.present?
update_item_params = item_params.merge({difficulty: params[:difficult]})
update_item_params = item_params.merge({difficulty: params[:hack][:difficult]})
@hack.item_bank.update!(update_item_params)
end
end

@ -7,7 +7,7 @@ class ItemBanksController < ApplicationController
def index
items = ItemBankQuery.call(params)
@items_count = items.size
@items = paginate items.includes(:item_analysis, :user)
@items = paginate items.includes(:item_analysis, :user, :container)
@item_basket_ids = current_user.item_baskets.pluck(:item_bank_id)
end

@ -3,4 +3,9 @@ json.analysis item.analysis
json.choices item.item_choices do |choice|
json.choice_text choice.choice_text
json.is_answer choice.is_answer
end
if item.item_type == "PROGRAM"
json.program_attr do
json.(item.container, :description, :language, :difficult)
end
end
Loading…
Cancel
Save