7. updateCpt

基本信息

  1. 接口名称:com.webank.weid.rpc.CptService.updateCpt
  2. 接口定义:ResponseData<CptBaseInfo> updateCpt(CptStringArgs args, Integer cptId)
  3. 接口描述: 传入cptIdJsonSchema(String类型),WeIdentity DIDWeIdentity DID所属私钥,进行更新CPT信息,更新成功版本自动+1

接口入参: com.webank.weid.protocol.request.CptStringArgs,Integer

名称类型非空说明备注
argsCptStringArgsYCPT信息具体见下
cptIdIntegerY发布的CPT编号

com.webank.weid.protocol.request.CptStringArgs

名称类型非空说明备注
weIdAuthenticationWeIdAuthenticationY认证信息,包含WeIdentity DID和私钥用于WeIdentity DID的身份认证
cptJsonSchemaStringY字符串类型的JsonSchema信息基本使用见调用示例

com.webank.weid.protocol.base.WeIdAuthentication

名称类型非空说明备注
weIdStringYCPT发布者的WeIdentity DIDWeIdentity DID的格式传入
weIdPublicKeyIdStringN公钥Id
weIdPrivateKeyWeIdPrivateKeyY 交易私钥,见下

com.webank.weid.protocol.base.WeIdPrivateKey

名称类型非空说明备注
privateKeyStringY私钥值使用十进制数字表示

接口返回: com.webank.weid.protocol.response.ResponseData<CptBaseInfo>;

名称类型说明备注
errorCodeInteger返回结果码此接口返回的code
errorMessageString返回结果描述
resultCptBaseInfo CPT基础数据,见下
transactionInfoTransactionInfo交易信息

com.webank.weid.protocol.response.TransactionInfo

名称类型说明备注
blockNumberBigInteger交易块高
transactionHashString交易hash
transactionIndexBigInteger交易索引

com.webank.weid.protocol.base.CptBaseInfo

名称类型说明备注
cptIdIntegercpId编号
cptVersionInteger版本号

此方法返回code

enumcodedesc
SUCCESS0成功
WEID_INVALID100101WeIdentity DID无效
WEID_PRIVATEKEY_INVALID100103私钥无效
WEID_PRIVATEKEY_DOES_NOT_MATCH100106私钥与WeIdentity DID不匹配
WEID_AUTHORITY_INVALID100109授权信息无效
CPT_JSON_SCHEMA_INVALID100301schema无效
CPT_ID_ILLEGAL100303cptId无效
CPT_EVENT_LOG_NULL100304交易日志异常
TRANSACTION_TIMEOUT160001超时
TRANSACTION_EXECUTE_ERROR160002交易错误
UNKNOW_ERROR160003未知异常
ILLEGAL_INPUT160004参数为空
CPT_NOT_EXISTS500301CPT不存在
CPT_ID_AUTHORITY_ISSUER_EXCEED_MAX500302为权威机构生成的cptId超过上限
CPT_PUBLISHER_NOT_EXIST500303CPT发布者的WeIdentity DID不存在
CPT_ALREADY_EXIST500304CPT已经存在
CPT_NO_PERMISSION500305CPT无权限

调用示例

  1. CptService cptService = new CptServiceImpl();
  2.  
  3. String jsonSchema = "{\"properties\" : {\"name\": {\"type\": \"string\",\"description\": \"the name of certificate owner\"},\"gender\": {\"enum\": [\"F\", \"M\"],\"type\": \"string\",\"description\": \"the gender of certificate owner\"}, \"age\": {\"type\": \"number\", \"description\": \"the age of certificate owner\"}},\"required\": [\"name\", \"age\"]}";
  4.  
  5. WeIdPrivateKey weIdPrivateKey = new WeIdPrivateKey();
  6. weIdPrivateKey.setPrivateKey("60866441986950167911324536025850958917764441489874006048340539971987791929772");
  7.  
  8. WeIdAuthentication weIdAuthentication = new WeIdAuthentication();
  9. weIdAuthentication.setWeId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7");
  10. weIdAuthentication.setWeIdPrivateKey(weIdPrivateKey);
  11.  
  12. CptStringArgs cptStringArgs = new CptStringArgs();
  13. cptStringArgs.setCptJsonSchema(jsonSchema);
  14. cptStringArgs.setWeIdAuthentication(weIdAuthentication);
  15.  
  16. Integer cptId = Integer.valueOf(1017);
  17.  
  18. ResponseData<CptBaseInfo> response = cptService.updateCpt(cptStringArgs, cptId);
  1. 返回数据如下:
  2. result:(com.webank.weid.protocol.base.CptBaseInfo)
  3. cptId: 1017
  4. cptVersion: 3
  5. errorCode: 0
  6. errorMessage: success
  7. transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
  8. blockNumber: 29991
  9. transactionHash: 0x8ed8113dd1772ae74e6f12de3d3716d76a410190c3d564d5d5842b85c7005aee
  10. transactionIndex: 0