add join service for blockchain
This commit is contained in:
parent
9a6456afdc
commit
cc0fc188c2
app
|
@ -54,23 +54,26 @@ module Mobile
|
|||
params do
|
||||
requires :username, type: String
|
||||
requires :password, type: String
|
||||
requires :ownername, type: String
|
||||
requires :reponame, type: String
|
||||
requires :repo_url, type: String
|
||||
end
|
||||
post 'join' do
|
||||
authenticate!
|
||||
owner = User.find_by_login(params[:ownername])
|
||||
if owner
|
||||
project = Project.find_by_user_id_name(owner.id, params[:reponame])
|
||||
if project
|
||||
blockchain = Blockchain.find_by_project_id(project.id)
|
||||
{status:0, genesis_content:blockchain.genesis_content, network_id:blockchain.network_id, connect_ip:blockchain.connect_ip, port:blockchain.port, enode:blockchain.enode}
|
||||
else
|
||||
{status:-1, message: '该项目不存在' }
|
||||
end
|
||||
else
|
||||
{status:-1, message: '该项目不存在或已被删除' }
|
||||
end
|
||||
# 根据repo_git_url找到repository对应的项目
|
||||
|
||||
rs = RepositoriesService.new
|
||||
rs.findProjectByRepoUrl(repo_url)
|
||||
# owner = User.find_by_login(params[:ownername])
|
||||
# if owner
|
||||
# project = Project.find_by_user_id_name(owner.id, params[:reponame])
|
||||
# if project
|
||||
# blockchain = Blockchain.find_by_project_id(project.id)
|
||||
# {status:0, genesis_content:blockchain.genesis_content, network_id:blockchain.network_id, connect_ip:blockchain.connect_ip, port:blockchain.port, enode:blockchain.enode}
|
||||
# else
|
||||
# {status:-1, message: '该项目不存在' }
|
||||
# end
|
||||
# else
|
||||
# {status:-1, message: '该项目不存在或已被删除' }
|
||||
# end
|
||||
end
|
||||
|
||||
desc "获取两次代码提交之间的区别"
|
||||
|
|
|
@ -2,6 +2,12 @@
|
|||
|
||||
class BlockchainsService
|
||||
|
||||
# 判断用户名密码是否匹配且正确
|
||||
def judge_user_password(user)
|
||||
|
||||
end
|
||||
|
||||
|
||||
# 获取用户使用过的东西
|
||||
def get_already_things(user)
|
||||
result = get_networkids_ports(user)
|
||||
|
|
|
@ -42,4 +42,15 @@ class RepositoriesService
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
# 根据repo_url,找到所属project
|
||||
def findProjectByRepoUrl repo_url
|
||||
# 解析ownername
|
||||
repo_url = repo_url[Redmine::Configuration['gitlab_address'].to_s.length + 1..repo_url.length - 1]
|
||||
index_split = repo_url.index("/")
|
||||
owner_name = repo_url[0..index_split - 1]
|
||||
puts "!!!!!!!!!!this is the owner name"
|
||||
puts owner_name
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue