|
|
|
@@ -56,13 +56,12 @@ class Traces::ProjectsController < Traces::BaseController |
|
|
|
|
|
|
|
def task_pdf |
|
|
|
return render_error("task_id错误") if params[:task_id].blank? |
|
|
|
code, data, error = Trace::PdfReportService.call(current_user.trace_token, params[:task_id]) |
|
|
|
domain = Trace.trace_config[:domain] |
|
|
|
base_url = Trace.trace_config[:base_url] |
|
|
|
url = "/user/pdfreport?task_id=#{params[:task_id]}" |
|
|
|
file_path = [domain, base_url, url].join |
|
|
|
request.headers["Authorization"] = current_user.trace_token |
|
|
|
redirect_to file_path |
|
|
|
result = Trace::PdfReportService.call(current_user.trace_token, params[:task_id]) |
|
|
|
if result.is_a?(Hash) && result[:code] == 200 |
|
|
|
redirect_to result[:download_url] |
|
|
|
else |
|
|
|
render_error("下载报告失败!") |
|
|
|
end |
|
|
|
rescue Exception => exception |
|
|
|
puts exception.message |
|
|
|
normal_status(-1, exception.message) |
|
|
|
|