From 93a7a8da21c568c8d88aae0a6a85f2bc33eb76bc Mon Sep 17 00:00:00 2001
From: CodingCattwo <847701726@qq.com>
Date: Wed, 30 Sep 2020 10:34:45 +0800
Subject: [PATCH 1/5] add deploy address in contract
---
script/webase-ddl.sql | 1 +
.../node/mgr/contract/ContractService.java | 1 +
.../mgr/contract/entity/ContractParam.java | 1 +
.../node/mgr/contract/entity/TbContract.java | 2 +-
src/main/resources/mapper/ContractMapper.xml | 18 ++++++++++++++++--
5 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/script/webase-ddl.sql b/script/webase-ddl.sql
index f1ac90562..993f9c800 100644
--- a/script/webase-ddl.sql
+++ b/script/webase-ddl.sql
@@ -113,6 +113,7 @@ 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 '合约部署者地址',
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/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..6038f53f2 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
@@ -256,6 +256,7 @@ public TbContract deployContract(DeployInputParam inputParam) throws NodeMgrExce
//save contract
TbContract tbContract = new TbContract();
BeanUtils.copyProperties(inputParam, tbContract);
+ tbContract.setDeployAddress(inputParam.getUser());
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..e1c15c46b 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,7 @@ public class TbContract {
private String description;
private LocalDateTime createTime;
private LocalDateTime modifyTime;
-
+ private String deployAddress;
/**
* init by contractId、contractName、groupId、contractPath.
*/
diff --git a/src/main/resources/mapper/ContractMapper.xml b/src/main/resources/mapper/ContractMapper.xml
index ee699568e..f9287dd55 100644
--- a/src/main/resources/mapper/ContractMapper.xml
+++ b/src/main/resources/mapper/ContractMapper.xml
@@ -38,13 +38,15 @@
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)
+ values(#{groupId},#{contractPath},#{contractVersion},#{contractName},#{account},#{contractSource},#{contractAbi},#{contractBin},#{bytecodeBin},#{contractAddress},#{description},#{deployTime},NOW(),NOW(),deployAddress)
SELECT LAST_INSERT_ID()
@@ -91,6 +93,9 @@
,description = #{description}
+
+ ,deploy_address = #{deployAddress}
+
where contract_id = #{contractId}
@@ -133,6 +138,9 @@
and contract_status = #{contractStatus}
+
+ and deploy_address = #{deployAddress}
+
@@ -160,6 +168,9 @@
and contract_address = #{contractAddress}
+
+ and deploy_address = #{deployAddress}
+
order by modify_time ${flagSortedByTime}
@@ -193,6 +204,9 @@
and contract_address = #{contractAddress}
+
+ and deploy_address = #{deployAddress}
+
and contract_status = #{contractStatus}
From 9ca50cbc4d41aa9230bf7e708a34f7601375bc34 Mon Sep 17 00:00:00 2001
From: CodingCattwo <847701726@qq.com>
Date: Wed, 30 Sep 2020 10:46:43 +0800
Subject: [PATCH 2/5] add deploy user name
---
script/webase-ddl.sql | 1 +
.../webank/webase/node/mgr/contract/ContractService.java | 4 ++++
.../webase/node/mgr/contract/entity/TbContract.java | 1 +
.../com/webank/webase/node/mgr/user/UserService.java | 8 ++++++++
src/main/resources/mapper/ContractMapper.xml | 9 +++++++--
5 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/script/webase-ddl.sql b/script/webase-ddl.sql
index 993f9c800..a2af9bf64 100644
--- a/script/webase-ddl.sql
+++ b/script/webase-ddl.sql
@@ -114,6 +114,7 @@ CREATE TABLE IF NOT EXISTS tb_contract (
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/src/main/java/com/webank/webase/node/mgr/contract/ContractService.java b/src/main/java/com/webank/webase/node/mgr/contract/ContractService.java
index 6038f53f2..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,10 +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/TbContract.java b/src/main/java/com/webank/webase/node/mgr/contract/entity/TbContract.java
index e1c15c46b..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
@@ -44,6 +44,7 @@ public class TbContract {
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 23b35cbff..659c9b5b2 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
@@ -270,6 +270,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 f9287dd55..b4199a583 100644
--- a/src/main/resources/mapper/ContractMapper.xml
+++ b/src/main/resources/mapper/ContractMapper.xml
@@ -40,13 +40,15 @@
property="modifyTime"/>
+
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,deploy_address)
- values(#{groupId},#{contractPath},#{contractVersion},#{contractName},#{account},#{contractSource},#{contractAbi},#{contractBin},#{bytecodeBin},#{contractAddress},#{description},#{deployTime},NOW(),NOW(),deployAddress)
+ 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()
@@ -96,6 +98,9 @@
,deploy_address = #{deployAddress}
+
+ ,deploy_user_name = #{deployUserName}
+
where contract_id = #{contractId}
From d0a5f09607103b9eed1e6522924c1742cc986026 Mon Sep 17 00:00:00 2001
From: CodingCattwo <847701726@qq.com>
Date: Wed, 30 Sep 2020 11:13:47 +0800
Subject: [PATCH 3/5] add list test
---
.../java/node/mgr/test/contract/ContractServiceTest.java | 7 +++++++
1 file changed, 7 insertions(+)
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);
+ }
}
From 67d777c850df1ab9119d9cac28f8419d35c54642 Mon Sep 17 00:00:00 2001
From: CodingCattwo <847701726@qq.com>
Date: Wed, 30 Sep 2020 13:00:05 +0800
Subject: [PATCH 4/5] fix mapper xml
---
src/main/resources/mapper/ContractMapper.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/resources/mapper/ContractMapper.xml b/src/main/resources/mapper/ContractMapper.xml
index b4199a583..9153e2851 100644
--- a/src/main/resources/mapper/ContractMapper.xml
+++ b/src/main/resources/mapper/ContractMapper.xml
@@ -48,7 +48,7 @@
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,deploy_address,deploy_user_name)
- values(#{groupId},#{contractPath},#{contractVersion},#{contractName},#{account},#{contractSource},#{contractAbi},#{contractBin},#{bytecodeBin},#{contractAddress},#{description},#{deployTime},NOW(),NOW(),deployAddress,deployUserName)
+ values(#{groupId},#{contractPath},#{contractVersion},#{contractName},#{account},#{contractSource},#{contractAbi},#{contractBin},#{bytecodeBin},#{contractAddress},#{description},#{deployTime},NOW(),NOW(),#{deployAddress},#{deployUserName})
SELECT LAST_INSERT_ID()
From 821d95bc1b3ead88b290ccad7e42a97ddd2194c1 Mon Sep 17 00:00:00 2001
From: CodingCattwo <847701726@qq.com>
Date: Fri, 9 Oct 2020 18:03:53 +0800
Subject: [PATCH 5/5] update visual docker version 2.6.0
---
script/webase-dml.sql | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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');