修改了getJoinInfo的不同获取方式
This commit is contained in:
parent
e197f09bd5
commit
f26d5c6e59
|
@ -131,15 +131,34 @@ module Mobile
|
|||
requires :password, type: String
|
||||
requires :repo_url, type: String
|
||||
requires :node_id, type: String
|
||||
requires :ownername, type: String # 可以选择是通过repo_url来查询project,还是通过ownername, reponame定位project
|
||||
requires :reponame, type: String
|
||||
end
|
||||
post 'getJoinInfo' do
|
||||
authenticate!
|
||||
# 根据repo_git_url找到repository对应的项目
|
||||
rs = RepositoriesService.new
|
||||
status, project, reponame = rs.findProjectByRepoUrl(params[:repo_url])
|
||||
node_ids = BlockchainProjectClient.find_by_sql("select node_id from blockchain_project_clients where project_id='#{project.id}' and user_id='#{current_user.id}'").map(&:node_id)
|
||||
result = {:node_ids => node_ids, :status => status} # 定义变量记录返回值
|
||||
present result
|
||||
if params[:ownername] != nil and params[:reponame] != nil
|
||||
owner = User.find_by_login(params[:ownername])
|
||||
if owner
|
||||
project = Project.find_by_sql("select * from projects where user_id='#{owner.id}' and name='#{params[:reponame]}'")
|
||||
node_ids = BlockchainProjectClient.find_by_sql("select node_id from blockchain_project_clients where project_id='#{project.id}' and user_id='#{current_user.id}'").map(&:node_id)
|
||||
result = {:node_ids => node_ids, :status => status} # 定义变量记录返回值
|
||||
present result
|
||||
else
|
||||
# 表示没有查到用户信息
|
||||
{status:1, message: '用户不存在'}
|
||||
end
|
||||
else # 通过repo_url定位项目信息
|
||||
status, project, reponame = rs.findProjectByRepoUrl(params[:repo_url])
|
||||
if status != 0
|
||||
{status: status, message: '项目的git地址有误'}
|
||||
else
|
||||
node_ids = BlockchainProjectClient.find_by_sql("select node_id from blockchain_project_clients where project_id='#{project.id}' and user_id='#{current_user.id}'").map(&:node_id)
|
||||
result = {:node_ids => node_ids, :status => status} # 定义变量记录返回值
|
||||
present result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue