use of com.jd.blockchain.ledger.ContractInfo in project jdchain-core by blockchain-jd-com.
the class DataSearchController method dataQuery.
private WebResponse dataQuery(String uri, HashDigest ledgerHash, String keyword) {
if (StringUtils.isEmpty(keyword)) {
return WebResponse.createFailureResult(new WebResponse.ErrorMessage(-1, "empty keywords"));
}
String ledger = ledgerHash.toString();
String type = uri.substring(uri.indexOf(ledger) + ledger.length(), uri.lastIndexOf("search"));
Object data = null;
switch(type) {
case // 综合查询
"/all/":
data = dataSearchService.searchAll(ledgerHash, keyword);
break;
case // 数据账户数
"/accounts/count/":
data = dataSearchService.searchDataAccountCount(ledgerHash, keyword);
break;
case // 数据账户
"/accounts/":
DataAccountInfo dataAccount = dataSearchService.searchDataAccount(ledgerHash, keyword);
data = null != dataAccount ? new DataAccountInfo[] { dataAccount } : new DataAccountInfo[] {};
break;
case // 事件账户账户数
"/events/accounts/count/":
data = dataSearchService.searchEventAccountCount(ledgerHash, keyword);
break;
case // 事件账户
"/events/accounts/":
BlockchainIdentity eventAccount = dataSearchService.searchEventAccount(ledgerHash, keyword);
data = null != eventAccount ? new BlockchainIdentity[] { eventAccount } : new BlockchainIdentity[] {};
break;
case // 合约账户数
"/contracts/count/":
data = dataSearchService.searchContractAccountCount(ledgerHash, keyword);
break;
case // 合约
"/contracts/":
ContractInfo contract = dataSearchService.searchContractAccount(ledgerHash, keyword);
data = null != contract ? new ContractInfo[] { contract } : new ContractInfo[] {};
break;
case // 用户账户数
"/users/count/":
data = dataSearchService.searchUserCount(ledgerHash, keyword);
break;
case // 用户
"/users/":
UserInfo user = dataSearchService.searchUser(ledgerHash, keyword);
data = null != user ? new UserInfo[] { user } : new UserInfo[] {};
break;
default:
return WebResponse.createFailureResult(new WebResponse.ErrorMessage(-1, "404"));
}
return WebResponse.createSuccessResult(data);
}
use of com.jd.blockchain.ledger.ContractInfo in project jdchain-core by blockchain-jd-com.
the class DataSearchServiceHandler method searchAll.
@Override
public Map<String, Object> searchAll(HashDigest ledgerHash, String keyword) {
Map<String, Object> data = new HashMap<>();
data.put("combine", true);
// 区块
LedgerBlock block = searchBlock(ledgerHash, keyword);
if (null != block) {
data.put("blocks", new LedgerBlock[] { block });
}
// 交易
Transaction tx = searchTransaction(ledgerHash, keyword);
if (null != tx) {
data.put("txs", new Transaction[] { tx });
}
// 数据账户
DataAccountInfo dataAccount = searchDataAccount(ledgerHash, keyword);
if (null != dataAccount) {
data.put("accounts", new DataAccountInfo[] { dataAccount });
}
// 事件账户
BlockchainIdentity eventAccount = searchEventAccount(ledgerHash, keyword);
if (null != eventAccount) {
data.put("event_accounts", new BlockchainIdentity[] { eventAccount });
}
// 合约
ContractInfo contract = searchContractAccount(ledgerHash, keyword);
if (null != contract) {
data.put("contracts", new ContractInfo[] { contract });
}
// 用户
UserInfo user = searchUser(ledgerHash, keyword);
if (null != user) {
data.put("users", new UserInfo[] { user });
}
return data;
}
Aggregations