change services and blockchain.rb

This commit is contained in:
nigel007 2019-05-24 11:30:18 +08:00
parent 46bafc9d35
commit 81842d4ba5
3 changed files with 34 additions and 0 deletions

View File

@ -50,6 +50,29 @@ module Mobile
present result_hash
end
desc "加入已经创建的项目"
params do
requires :username, type: String
requires :password, type: String
requires :ownername, type: String
requires :reponame, type: String
end
post 'join' do
authenticate!
owner = User.find_by_login(ownername)
if owner
project = Project.where(:user_id => owner.id, :name => 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
end
end
end

View File

@ -41,4 +41,9 @@ class BlockchainsService
return status, nil
end
# 读取配置信息
def get_repo_config(project, user, params)
end
end

View File

@ -498,4 +498,10 @@ class ProjectsService
return project_names
end
# 获取对应name和user_id的项目
def get_project_by_name_user_id user
end
end