forked from Trustie/forgeplus
38 lines
1.0 KiB
Ruby
38 lines
1.0 KiB
Ruby
class SonarTasksController < ApplicationController
|
|
before_action :require_login
|
|
before_action :load_project
|
|
before_action :authenticate_user!
|
|
|
|
def index
|
|
@sonar_task = SonarTask.find_by(project_id: @project.id)
|
|
tip_exception(-1, "代码未检测,请点击开始检测按钮检测!") if @sonar_task.blank?
|
|
if @sonar_task.complete_status == 0
|
|
service = Sonar::ApiService.new(@project.id)
|
|
service.task_result(@sonar_task.task_id)
|
|
end
|
|
end
|
|
|
|
def create
|
|
Sonar::ApiService.call(@project.id)
|
|
render_ok
|
|
end
|
|
|
|
def type_detail
|
|
service = Sonar::ApiService.new(@project.id)
|
|
@data = service.type_detail(params[:task_id], params[:type])
|
|
end
|
|
|
|
def code_source
|
|
service = Sonar::ApiService.new(@project.id)
|
|
@data = service.source_code(params[:task_id], params[:component])
|
|
Rails.logger.info "data=======#{@data}"
|
|
end
|
|
|
|
private
|
|
|
|
def authenticate_user!
|
|
return if @project.member?(current_user) || current_user.admin?
|
|
render_forbidden('你没有权限操作')
|
|
end
|
|
end
|