|
|
|
@@ -24,6 +24,26 @@ class ApplicationQuery |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
# find one repo that a user has tokens |
|
|
|
def find_one_balance_with_token(user_id, project_id) |
|
|
|
# return 3 statuses: UnknownErr/ResUserNotExisted/Success |
|
|
|
params = { |
|
|
|
"request-type": "query user balance of single repo", |
|
|
|
"username": user_id.to_s, |
|
|
|
"token_name": project_id.to_s |
|
|
|
}.to_json |
|
|
|
Rails.logger.info "query user balance of single repo params======= #{params}" |
|
|
|
resp_body = Blockchain::InvokeBlockchainApi.call(params) |
|
|
|
Rails.logger.info "resp_body======= #{resp_body}" |
|
|
|
if resp_body['status'] == 0 |
|
|
|
return resp_body |
|
|
|
elsif resp_body['status'] == 100 |
|
|
|
return 0 # 找不到用户返回0 |
|
|
|
else |
|
|
|
raise "区块链接口请求失败." |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# find one repo that a user has tokens |
|
|
|
def find_one_balance(user_id, project_id) |
|
|
|
|