forked from Trustie/forgeplus
update sca response
This commit is contained in:
parent
594be13d7e
commit
479c39b5db
|
|
@ -33,12 +33,7 @@ class Api::V1::Projects::Sca::BaseService < ApplicationService
|
|||
request["Authorization"] = auth_token if auth_token
|
||||
|
||||
response = http.request(request)
|
||||
|
||||
{
|
||||
code: response.code.to_i,
|
||||
body: response.body,
|
||||
json: (JSON.parse(response.body) rescue nil)
|
||||
}
|
||||
JSON.parse(response.body) rescue nil
|
||||
rescue
|
||||
raise Error, "SCA服务器错误,请联系系统管理员!"
|
||||
end
|
||||
|
|
@ -58,11 +53,8 @@ class Api::V1::Projects::Sca::BaseService < ApplicationService
|
|||
|
||||
response = http.request(request)
|
||||
|
||||
{
|
||||
code: response.code.to_i,
|
||||
body: response.body,
|
||||
json: (JSON.parse(response.body) rescue nil)
|
||||
}
|
||||
JSON.parse(response.body) rescue nil
|
||||
|
||||
rescue
|
||||
raise Error, "SCA服务器错误,请联系系统管理员!"
|
||||
end
|
||||
|
|
@ -72,8 +64,8 @@ class Api::V1::Projects::Sca::BaseService < ApplicationService
|
|||
def sca_user_info
|
||||
if Rails.cache.fetch("sca_user").nil?
|
||||
data = sca_get_request("user/", params = {})
|
||||
Rails.cache.write("sca_user",data[:body], expires_in: 1.day, force: true)
|
||||
data[:json]
|
||||
Rails.cache.write("sca_user",data, expires_in: 1.day, force: true)
|
||||
data
|
||||
else
|
||||
JSON.parse Rails.cache.fetch("sca_user")
|
||||
end
|
||||
|
|
@ -81,7 +73,7 @@ class Api::V1::Projects::Sca::BaseService < ApplicationService
|
|||
|
||||
def sca_team_id
|
||||
data = sca_get_request("orgs/#{sca_user_info["default_org"]}/teams/", params = {})
|
||||
default_team = data[:json]["results"].find { |team| team["is_default"] }
|
||||
default_team = data["results"].find { |team| team["is_default"] }
|
||||
default_team ? default_team["id"] : nil
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Api::V1::Projects::Sca::CreateProjectService < Api::V1::Projects::Sca::Ba
|
|||
"description": @project.description
|
||||
}
|
||||
data = sca_post_request("projects/", params)
|
||||
if @project.update(sca_project_id:data[:json]["id"])
|
||||
if @project.update(sca_project_id:data["id"])
|
||||
true
|
||||
else
|
||||
false
|
||||
|
|
|
|||
Loading…
Reference in New Issue