Skip to content

Commit

Permalink
Merge pull request #260 from yg3630536/feature/get-weid-list
Browse files Browse the repository at this point in the history
Feature/get weid list
  • Loading branch information
junqizhang-dev committed Sep 18, 2020
2 parents 9ab66a1 + 35f9ed1 commit 40f1ea7
Show file tree
Hide file tree
Showing 11 changed files with 366 additions and 14 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.4
1.6.6
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ dependencies {
if (gradleVer.startsWith("4")) {
if (!gradle.startParameter.isOffline()) {
compile logger, lombok, apache_commons, json, mysql_driver, redisson, zxing, rpc, pdfbox, protobuf, caffeine, oval
compile("com.webank:weid-contract-java:1.2.22-rc.4-SNAPSHOT") {
compile("com.webank:weid-contract-java:1.2.24") {
exclude group: "org.slf4j", module: "slf4j-log4j12"
// exclude group: "org.fisco-bcos", module: "web3sdk"
// exclude group: "org.fisco-bcos", module: "web3sdk-weevent"
Expand All @@ -174,7 +174,7 @@ dependencies {
testAnnotationProcessor 'org.projectlombok:lombok:1.18.10'
testCompileOnly 'org.projectlombok:lombok:1.18.10'
compile logger, apache_commons, json, mysql_driver, redisson, zxing, rpc, pdfbox, protobuf, caffeine, oval
compile("com.webank:weid-contract-java:1.2.22-rc.4-SNAPSHOT") {
compile("com.webank:weid-contract-java:1.2.24") {
exclude group: "org.slf4j", module: "slf4j-log4j12"
// exclude group: "org.fisco-bcos", module: "web3sdk"
// exclude group: "org.fisco-bcos", module: "web3sdk-weevent"
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/com/webank/weid/protocol/base/WeIdBaseInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright© (2018-2020) WeBank Co., Ltd.
*
* This file is part of weid-java-sdk.
*
* weid-java-sdk is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* weid-java-sdk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with weid-java-sdk. If not, see <https://www.gnu.org/licenses/>.
*/

package com.webank.weid.protocol.base;

import lombok.Data;

@Data
public class WeIdBaseInfo {
/**
* Required: The id.
*/
private String id;

/**
* Required: The created.
*/
private Long created;
}
15 changes: 4 additions & 11 deletions src/main/java/com/webank/weid/protocol/base/WeIdDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.util.List;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -37,7 +39,8 @@
* @author tonychen 2018.9.29
*/
@Data
public class WeIdDocument implements JsonSerializer {
@EqualsAndHashCode(callSuper = true)
public class WeIdDocument extends WeIdBaseInfo implements JsonSerializer {

private static final Logger logger = LoggerFactory.getLogger(WeIdDocument.class);

Expand All @@ -46,16 +49,6 @@ public class WeIdDocument implements JsonSerializer {
*/
private static final long serialVersionUID = 411522771907189878L;

/**
* Required: The id.
*/
private String id;

/**
* Required: The created.
*/
private Long created;

/**
* Required: The updated.
*/
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/com/webank/weid/protocol/base/WeIdPojo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright© (2018-2020) WeBank Co., Ltd.
*
* This file is part of weid-java-sdk.
*
* weid-java-sdk is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* weid-java-sdk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with weid-java-sdk. If not, see <https://www.gnu.org/licenses/>.
*/

package com.webank.weid.protocol.base;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
* WeIdentity DID information for created.
* @author v_wbgyang
*
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class WeIdPojo extends WeIdBaseInfo {

/**
* the blockNum for the WeIdentity DID.
*/
private Integer currentBlockNum;

/**
* the index for the blockNum.
*/
private Integer index;

/**
* the previous blockNum.
*/
private Integer previousBlockNum;
}
19 changes: 19 additions & 0 deletions src/main/java/com/webank/weid/rpc/WeIdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@

package com.webank.weid.rpc;

import java.util.List;

import com.webank.weid.protocol.base.WeIdAuthentication;
import com.webank.weid.protocol.base.WeIdDocument;
import com.webank.weid.protocol.base.WeIdPojo;
import com.webank.weid.protocol.base.WeIdPrivateKey;
import com.webank.weid.protocol.base.WeIdPublicKey;
import com.webank.weid.protocol.request.AuthenticationArgs;
Expand Down Expand Up @@ -193,4 +196,20 @@ ResponseData<Boolean> revokeAuthentication(
String weId,
AuthenticationArgs authenticationArgs,
WeIdPrivateKey privateKey);

/**
* query data according to block height, index location and search direction.
*
* @param blockNumber the query blockNumber
* @param pageSize the page size
* @param indexInBlock the beginning (including) of the current block
* @param direction search direction: true means forward search, false means backward search
* @return return the WeIdPojo List
*/
ResponseData<List<WeIdPojo>> getWeIdList(
Integer blockNumber,
Integer pageSize,
Integer indexInBlock,
boolean direction
);
}
23 changes: 23 additions & 0 deletions src/main/java/com/webank/weid/service/impl/WeIdServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.webank.weid.protocol.base.PublicKeyProperty;
import com.webank.weid.protocol.base.WeIdAuthentication;
import com.webank.weid.protocol.base.WeIdDocument;
import com.webank.weid.protocol.base.WeIdPojo;
import com.webank.weid.protocol.base.WeIdPrivateKey;
import com.webank.weid.protocol.base.WeIdPublicKey;
import com.webank.weid.protocol.request.AuthenticationArgs;
Expand Down Expand Up @@ -923,4 +924,26 @@ public ResponseData<Boolean> delegateSetAuthentication(
weId,
true);
}

@Override
public ResponseData<List<WeIdPojo>> getWeIdList(
Integer blockNumber,
Integer pageSize,
Integer indexInBlock,
boolean direction
) {
try {
logger.info("[getWeIdList] begin get weIdList, blockNumber = {}, pageSize = {}, "
+ "indexInBlock = {}, direction = {}",
blockNumber,
pageSize,
indexInBlock,
direction
);
return weIdServiceEngine.getWeIdList(blockNumber, pageSize, indexInBlock, direction);
} catch (Exception e) {
logger.error("[getWeIdList] get weIdList failed with exception. ", e);
return new ResponseData<>(null, ErrorCode.UNKNOW_ERROR);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

package com.webank.weid.service.impl.engine;

import java.util.List;

import com.webank.weid.protocol.base.WeIdDocument;
import com.webank.weid.protocol.base.WeIdPojo;
import com.webank.weid.protocol.response.ResponseData;

/**
Expand Down Expand Up @@ -79,4 +82,21 @@ ResponseData<Boolean> setAttribute(
* @return weid document
*/
ResponseData<WeIdDocument> getWeIdDocument(String weId);

/**
* query data according to block height, index location and search direction.
*
* @param blockNumber the query blockNumber
* @param pageSize the page size
* @param indexInBlock the beginning (including) of the current block
* @param direction search direction: true means forward search, false means backward search
* @return return the WeIdPojo List
* @throws Exception unknown exception
*/
ResponseData<List<WeIdPojo>> getWeIdList(
Integer blockNumber,
Integer pageSize,
Integer indexInBlock,
boolean direction
) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import com.webank.weid.protocol.base.PublicKeyProperty;
import com.webank.weid.protocol.base.ServiceProperty;
import com.webank.weid.protocol.base.WeIdDocument;
import com.webank.weid.protocol.base.WeIdPojo;
import com.webank.weid.protocol.response.ResolveEventLogResult;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.protocol.response.TransactionInfo;
Expand Down Expand Up @@ -575,4 +576,14 @@ public ResponseData<Boolean> setAttribute(
return new ResponseData<Boolean>(false, ErrorCode.TRANSACTION_TIMEOUT);
}
}

@Override
public ResponseData<List<WeIdPojo>> getWeIdList(
Integer blockNumber,
Integer pageSize,
Integer indexInBlock,
boolean direction
) throws Exception {
return new ResponseData<>(null, ErrorCode.THIS_IS_UNSUPPORTED);
}
}

0 comments on commit 40f1ea7

Please sign in to comment.