|
|
|
@ -329,6 +329,7 @@ class ApplicationController < ActionController::Base
|
|
|
|
|
def current_user
|
|
|
|
|
# User.current
|
|
|
|
|
User.find_by_id 36401
|
|
|
|
|
# nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
## 默认输出json
|
|
|
|
@ -355,21 +356,21 @@ class ApplicationController < ActionController::Base
|
|
|
|
|
|
|
|
|
|
# 通关后,把最后一次成功的代码存到数据库
|
|
|
|
|
# type 0 创始内容, 1 最新内容
|
|
|
|
|
def game_passed_code(path, myshixun, game_id)
|
|
|
|
|
# 如果代码窗口是隐藏的,则不用保存代码
|
|
|
|
|
return if myshixun.shixun.hide_code || myshixun.shixun.vnc
|
|
|
|
|
file_content = git_fle_content myshixun.repo_path, path
|
|
|
|
|
#unless file_content.present?
|
|
|
|
|
# raise("获取文件代码异常")
|
|
|
|
|
#end
|
|
|
|
|
logger.info("#######game_id:#{game_id}, file_content:#{file_content}")
|
|
|
|
|
game_code = GameCode.where(:game_id => game_id, :path => path).first
|
|
|
|
|
if game_code.nil?
|
|
|
|
|
GameCode.create!(:game_id => game_id, :new_code => file_content, :path => path)
|
|
|
|
|
else
|
|
|
|
|
game_code.update_attributes!(:new_code => file_content)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
# def game_passed_code(path, myshixun, game_id)
|
|
|
|
|
# # 如果代码窗口是隐藏的,则不用保存代码
|
|
|
|
|
# return if myshixun.shixun.hide_code || myshixun.shixun.vnc
|
|
|
|
|
# file_content = git_fle_content myshixun.repo_path, path
|
|
|
|
|
# #unless file_content.present?
|
|
|
|
|
# # raise("获取文件代码异常")
|
|
|
|
|
# #end
|
|
|
|
|
# logger.info("#######game_id:#{game_id}, file_content:#{file_content}")
|
|
|
|
|
# game_code = GameCode.where(:game_id => game_id, :path => path).first
|
|
|
|
|
# if game_code.nil?
|
|
|
|
|
# GameCode.create!(:game_id => game_id, :new_code => file_content, :path => path)
|
|
|
|
|
# else
|
|
|
|
|
# game_code.update_attributes!(:new_code => file_content)
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
# Post请求
|
|
|
|
|
def uri_post(uri, params)
|
|
|
|
@ -647,19 +648,20 @@ class ApplicationController < ActionController::Base
|
|
|
|
|
render_not_found("未找到’#{params[:id]}’相关的项目") unless @project
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def find_project_with_identifier
|
|
|
|
|
@project = Project.find_by_identifier! params[:id]
|
|
|
|
|
render_not_found("未找到’#{params[:id]}’相关的项目") unless @project
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def find_project_with_id
|
|
|
|
|
@project = Project.find params[:project_id]
|
|
|
|
|
@project = Project.find(params[:project_id] || params[:id])
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
logger_error(e.message)
|
|
|
|
|
tip_exception(e.message)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def render_response(interactor)
|
|
|
|
|
if interactor.success?
|
|
|
|
|
render_ok
|
|
|
|
|
else
|
|
|
|
|
render_error(interactor.error)
|
|
|
|
|
end
|
|
|
|
|
interactor.success? ? render_ok : render_error(interactor.error)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|