diff --git a/script/webase-ddl.sql b/script/webase-ddl.sql
index f1ac90562..a2af9bf64 100644
--- a/script/webase-ddl.sql
+++ b/script/webase-ddl.sql
@@ -113,6 +113,8 @@ CREATE TABLE IF NOT EXISTS tb_contract (
description text COMMENT '描述',
create_time datetime DEFAULT NULL COMMENT '创建时间',
modify_time datetime DEFAULT NULL COMMENT '修改时间',
+ deploy_address varchar(64) DEFAULT NULL COMMENT '合约部署者地址',
+ deploy_user_name varchar(64) DEFAULT NULL COMMENT '合约部署者用戶名',
PRIMARY KEY (contract_id),
UNIQUE KEY uk_group_path_name (group_id,contract_path,contract_name,account)
) ENGINE=InnoDB AUTO_INCREMENT=200001 DEFAULT CHARSET=utf8 COMMENT='合约表';
diff --git a/script/webase-dml.sql b/script/webase-dml.sql
index 562c0d43b..66280c900 100644
--- a/script/webase-dml.sql
+++ b/script/webase-dml.sql
@@ -99,5 +99,5 @@ INSERT INTO `tb_mail_server_config`(`server_name`,`host`,`port`,`username`,`pass
-- ----------------------------
-- 8、init tb_config
-- ----------------------------
-INSERT INTO `tb_config`(`config_name`, `config_type`, `config_value`, `create_time`, `modify_time`) VALUES ('docker 镜像版本', 1, 'v2.5.0', '2020-07-22 17:14:23', '2020-07-22 17:14:23');
-INSERT INTO `tb_config`(`config_name`, `config_type`, `config_value`, `create_time`, `modify_time`) VALUES ('docker 镜像版本', 1, 'v2.5.0-gm', '2020-07-22 17:14:23', '2020-07-22 17:14:23');
+INSERT INTO `tb_config`(`config_name`, `config_type`, `config_value`, `create_time`, `modify_time`) VALUES ('docker 镜像版本', 1, 'v2.6.0', '2020-09-22 17:14:23', '2020-09-22 17:14:23');
+INSERT INTO `tb_config`(`config_name`, `config_type`, `config_value`, `create_time`, `modify_time`) VALUES ('docker 镜像版本', 1, 'v2.6.0-gm', '2020-09-22 17:14:23', '2020-09-22 17:14:23');
diff --git a/src/main/java/com/webank/webase/node/mgr/contract/ContractService.java b/src/main/java/com/webank/webase/node/mgr/contract/ContractService.java
index c1db70e4b..dac064b57 100644
--- a/src/main/java/com/webank/webase/node/mgr/contract/ContractService.java
+++ b/src/main/java/com/webank/webase/node/mgr/contract/ContractService.java
@@ -13,6 +13,7 @@
*/
package com.webank.webase.node.mgr.contract;
+import com.webank.webase.node.mgr.user.entity.TbUser;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
@@ -253,9 +254,13 @@ public TbContract deployContract(DeployInputParam inputParam) throws NodeMgrExce
throw new NodeMgrException(ConstantCode.CONTRACT_DEPLOY_FAIL);
}
+ // get deploy user name
+ String userName = userService.getUserNameByAddress(groupId, inputParam.getUser());
//save contract
TbContract tbContract = new TbContract();
BeanUtils.copyProperties(inputParam, tbContract);
+ tbContract.setDeployAddress(inputParam.getUser());
+ tbContract.setDeployUserName(userName);
tbContract.setContractAddress(contractAddress);
tbContract.setContractStatus(ContractStatus.DEPLOYED.getValue());
//tbContract.setContractVersion(version);
diff --git a/src/main/java/com/webank/webase/node/mgr/contract/entity/ContractParam.java b/src/main/java/com/webank/webase/node/mgr/contract/entity/ContractParam.java
index 792f33e00..4f6f16f15 100644
--- a/src/main/java/com/webank/webase/node/mgr/contract/entity/ContractParam.java
+++ b/src/main/java/com/webank/webase/node/mgr/contract/entity/ContractParam.java
@@ -36,6 +36,7 @@ public class ContractParam extends BaseQueryParam {
private Integer contractStatus;
private Integer contractType;
private String partOfBytecodeBin;
+ private String deployAddress;
/**
* init by contractId.
diff --git a/src/main/java/com/webank/webase/node/mgr/contract/entity/TbContract.java b/src/main/java/com/webank/webase/node/mgr/contract/entity/TbContract.java
index 28d7a68cd..1561de5b2 100644
--- a/src/main/java/com/webank/webase/node/mgr/contract/entity/TbContract.java
+++ b/src/main/java/com/webank/webase/node/mgr/contract/entity/TbContract.java
@@ -43,7 +43,8 @@ public class TbContract {
private String description;
private LocalDateTime createTime;
private LocalDateTime modifyTime;
-
+ private String deployAddress;
+ private String deployUserName;
/**
* init by contractId、contractName、groupId、contractPath.
*/
diff --git a/src/main/java/com/webank/webase/node/mgr/user/UserService.java b/src/main/java/com/webank/webase/node/mgr/user/UserService.java
index 171bc2522..7a96c99f6 100644
--- a/src/main/java/com/webank/webase/node/mgr/user/UserService.java
+++ b/src/main/java/com/webank/webase/node/mgr/user/UserService.java
@@ -282,6 +282,14 @@ public String getSignUserIdByAddress(int groupId, String address) throws NodeMgr
return user.getSignUserId();
}
+ public String getUserNameByAddress(int groupId, String address) throws NodeMgrException {
+ TbUser user = queryUser(null, groupId, null, address, null);
+ if (user == null) {
+ throw new NodeMgrException(ConstantCode.USER_NOT_EXIST);
+ }
+ return user.getUserName();
+ }
+
/**
* update user info.
*/
diff --git a/src/main/resources/mapper/ContractMapper.xml b/src/main/resources/mapper/ContractMapper.xml
index ee699568e..9153e2851 100644
--- a/src/main/resources/mapper/ContractMapper.xml
+++ b/src/main/resources/mapper/ContractMapper.xml
@@ -38,13 +38,17 @@
property="createTime"/>
+
+
insert into
- tb_contract(group_id,contract_path,contract_version,contract_name,account,contract_source,contract_abi,contract_bin,bytecodeBin,contract_address,description,deploy_time,create_time,modify_time)
- values(#{groupId},#{contractPath},#{contractVersion},#{contractName},#{account},#{contractSource},#{contractAbi},#{contractBin},#{bytecodeBin},#{contractAddress},#{description},#{deployTime},NOW(),NOW())
+ tb_contract(group_id,contract_path,contract_version,contract_name,account,contract_source,contract_abi,contract_bin,bytecodeBin,contract_address,description,deploy_time,create_time,modify_time,deploy_address,deploy_user_name)
+ values(#{groupId},#{contractPath},#{contractVersion},#{contractName},#{account},#{contractSource},#{contractAbi},#{contractBin},#{bytecodeBin},#{contractAddress},#{description},#{deployTime},NOW(),NOW(),#{deployAddress},#{deployUserName})
SELECT LAST_INSERT_ID()
@@ -91,6 +95,12 @@
,description = #{description}
+
+ ,deploy_address = #{deployAddress}
+
+
+ ,deploy_user_name = #{deployUserName}
+
where contract_id = #{contractId}
@@ -133,6 +143,9 @@
and contract_status = #{contractStatus}
+
+ and deploy_address = #{deployAddress}
+
@@ -160,6 +173,9 @@
and contract_address = #{contractAddress}
+
+ and deploy_address = #{deployAddress}
+
order by modify_time ${flagSortedByTime}
@@ -193,6 +209,9 @@
and contract_address = #{contractAddress}
+
+ and deploy_address = #{deployAddress}
+
and contract_status = #{contractStatus}
diff --git a/src/test/java/node/mgr/test/contract/ContractServiceTest.java b/src/test/java/node/mgr/test/contract/ContractServiceTest.java
index 8cdab5d48..732c1597e 100644
--- a/src/test/java/node/mgr/test/contract/ContractServiceTest.java
+++ b/src/test/java/node/mgr/test/contract/ContractServiceTest.java
@@ -16,6 +16,7 @@
package node.mgr.test.contract;
+import com.webank.webase.node.mgr.contract.entity.ContractParam;
import java.util.Arrays;
import java.util.List;
@@ -79,4 +80,10 @@ public void sendTransactionTest(){
assert (transRsp!=null);
}
+ @Test
+ public void testGetContractList() {
+ List resList = contractService.qureyContractList(new ContractParam());
+ System.out.println("list:");
+ System.out.println(resList);
+ }
}