From 04cd427c5f88424611f69ac44c813871c3ec466a Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 12 Aug 2022 18:15:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=BA=AF=E6=BA=90=E9=9C=80=E6=8F=90=E5=89=8D=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=98=AF=E5=90=A6=E5=9C=A8=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/traces/base_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/traces/base_controller.rb b/app/controllers/traces/base_controller.rb index 2b857d232..3a59ad08f 100644 --- a/app/controllers/traces/base_controller.rb +++ b/app/controllers/traces/base_controller.rb @@ -1,7 +1,7 @@ class Traces::BaseController < ApplicationController helper_method :observed_logged_user?, :observed_user - + before_action :check_trace_system def observed_user @_observed_user ||= (User.find_by_login(params[:user_id]) || User.find_by_id(params[:user_id])) @@ -15,4 +15,12 @@ class Traces::BaseController < ApplicationController def check_auth return render_forbidden unless current_user.admin? || observed_logged_user? end + + def check_trace_system + code, data, error = Trace::SystemInfoService.call(current_user.trace_token) + return render_ok({status: 501, data: {operate_time: data['operate_time']}, message: '系统维护中'}) if data['status'] === 0 + rescue + # 这里根据需求跳转到404 + return render_not_found + end end \ No newline at end of file