diff --git a/app/api/mobile/apis/blockchains.rb b/app/api/mobile/apis/blockchains.rb index 19ab1e74b..aaf4e5d6d 100644 --- a/app/api/mobile/apis/blockchains.rb +++ b/app/api/mobile/apis/blockchains.rb @@ -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 "获取两次代码提交之间的区别" diff --git a/app/services/blockchains_service.rb b/app/services/blockchains_service.rb index a6646f996..b114655fc 100644 --- a/app/services/blockchains_service.rb +++ b/app/services/blockchains_service.rb @@ -2,6 +2,12 @@ class BlockchainsService + # 判断用户名密码是否匹配且正确 + def judge_user_password(user) + + end + + # 获取用户使用过的东西 def get_already_things(user) result = get_networkids_ports(user) diff --git a/app/services/repositories_service.rb b/app/services/repositories_service.rb index 433f8d98f..8ec9acc9d 100644 --- a/app/services/repositories_service.rb +++ b/app/services/repositories_service.rb @@ -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 \ No newline at end of file