dev_jupyter
cxt 5 years ago
parent 2ac99588ac
commit 58482e5f9e

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

@ -61,7 +61,7 @@ class HacksController < ApplicationController
hack_codes = hack.hack_codes.new(hack_code_params) hack_codes = hack.hack_codes.new(hack_code_params)
hack_codes.modify_time = Time.now hack_codes.modify_time = Time.now
hack_codes.save! 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) ItemBank.create!(new_item_params)
end end
render_ok({identifier: hack.identifier}) render_ok({identifier: hack.identifier})
@ -95,7 +95,7 @@ class HacksController < ApplicationController
# 更新题库相关记录 # 更新题库相关记录
if @hack.item_bank.present? 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) @hack.item_bank.update!(update_item_params)
end end
end end

@ -7,7 +7,7 @@ class ItemBanksController < ApplicationController
def index def index
items = ItemBankQuery.call(params) items = ItemBankQuery.call(params)
@items_count = items.size @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) @item_basket_ids = current_user.item_baskets.pluck(:item_bank_id)
end end

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