This commit is contained in:
呱呱呱 2025-09-11 15:15:45 +08:00
parent 6a426b164d
commit 6dc84f1dd6
5 changed files with 19 additions and 5 deletions

View File

@ -1,10 +1,18 @@
class Api::V1::Projects::ScaController < Api::V1::BaseController
before_action :require_public_and_member_above
before_action :load_project
def index
def index
@result = Api::V1::Projects::Sca::ShowProjectService.call(@project)
end
def create
@result = Api::V1::Projects::Sca::CreateProjectService.call(@project)
result = Api::V1::Projects::Sca::CreateProjectService.call(@project)
if result
@result = Api::V1::Projects::Sca::ShowProjectService.call(@project)
else
{
auth_token: nil,
"url": nil,
}
end
end
end

View File

@ -1,7 +1,11 @@
class Api::V1::Projects::Sca::BaseService < ApplicationService
private
def base_url
Rails.application.config_for(:configuration)["sca"]["domain"] + Rails.application.config_for(:configuration)["sca"]["base_url"]
domain_url + Rails.application.config_for(:configuration)["sca"]["base_url"]
end
def domain_url
Rails.application.config_for(:configuration)["sca"]["domain"]
end
def auth_token

View File

@ -16,7 +16,9 @@ class Api::V1::Projects::Sca::CreateProjectService < Api::V1::Projects::Sca::Ba
}
data = sca_post_request("projects/", params)
if @project.update(sca_project_id:data[:json]["id"])
Api::V1::Projects::Sca::ShowProjectService.call(@project)
true
else
false
end
end

View File

@ -7,7 +7,7 @@ class Api::V1::Projects::Sca::ShowProjectService < Api::V1::Projects::Sca::Base
#projects/18748/list-branches/?branch_name_query=&page=1&limit=5
{
auth_token:login_token,
"url": base_url + "org/#{sca_user_info["default_org"]}/projects/#{@project.sca_project_id}?engine=sca" ,
"url": domain_url + "/org/#{sca_user_info["default_org"]}/projects/#{@project.sca_project_id}?engine=sca" ,
}
end