Skip to content

Commit

Permalink
Merge pull request #193 from WeBankFinTech/dev
Browse files Browse the repository at this point in the history
v1.3.1 dev => master
  • Loading branch information
CodingCattwo authored Jun 4, 2020
2 parents c630f5a + b189a02 commit a9d3f20
Show file tree
Hide file tree
Showing 85 changed files with 3,359 additions and 466 deletions.
23 changes: 23 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
### v1.3.1(2020-06-01)

**Add**
- 新增动态管理群组接口,支持群组脏数据提醒,手动删除群组数据等
- 新增导入已部署合约的ABI接口,进行合约调用
- 新增导入.p12/.pem/.txt格式私钥接口,支持导入控制台与前置的私钥
- 新增节点前置状态,可查看前置运行状态

**Fix**
- 修复部署合约权限不足导致合约地址为0x0
- 移除自动删除无效群组数据的逻辑
- 修复公钥用户签名报空问题

**兼容性**
- 支持FISCO-BCOS v2.2.0 及以上版本
- WeBASE-Web v1.3.1+
- WeBASE-Front v1.3.1+
- WeBASE-Sign v1.3.1+
- WeBASE-Transaction v1.3.0+

详细了解,请阅读[**技术文档**](https://webasedoc.readthedocs.io/zh_CN/latest/)


### v1.3.0(2020-04-29)

**Add**
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ List jaxb = [
]

List web3jsdk = [
"org.fisco-bcos:web3sdk:2.2.0"
"org.fisco-bcos:web3sdk:2.4.0"
]

List lombok = [
Expand All @@ -63,7 +63,7 @@ dependencies {
compile springboot,jaxb,web3jsdk,jackson
compile "org.mybatis.spring.boot:mybatis-spring-boot-starter:2.0.0"
compile "org.apache.commons:commons-lang3:3.8.1"
compile "com.alibaba:fastjson:1.2.67"
compile "com.alibaba:fastjson:1.2.69"
compile "mysql:mysql-connector-java:8.0.13"
compile "com.zaxxer:HikariCP:3.2.0"
compile "com.github.sgroschupf:zkclient:0.1"
Expand Down
42 changes: 32 additions & 10 deletions script/webase-ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
-- Table structure for tb_group
-- ----------------------------
CREATE TABLE IF NOT EXISTS tb_group (
group_id int(11) NOT NULL COMMENT '群组ID',
group_name varchar(64) NOT NULL COMMENT '群组名字',
group_status int(1) DEFAULT '1' COMMENT '状态(1-正常 2-异常)',
node_count int DEFAULT '0' COMMENT '群组下节点数',
group_desc varchar(1024) COMMENT '群组描述',
create_time datetime DEFAULT NULL COMMENT '创建时间',
modify_time datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (group_id)
) COMMENT='群组信息表' ENGINE=InnoDB CHARSET=utf8;
group_id int(11) NOT NULL COMMENT '群组ID',
group_name varchar(64) NOT NULL COMMENT '群组名字',
group_status int(1) DEFAULT '1' COMMENT '状态(1-正常 2-异常)',
node_count int DEFAULT '0' COMMENT '群组下节点数',
description varchar(1024) COMMENT '群组描述',
group_type int COMMENT '群组类型(1-拉取,2-动态创建)',
group_timestamp varchar(64) COMMENT '群组创世块时间戳',
node_id_list text COMMENT '群组成员节点的ID',
create_time datetime DEFAULT NULL COMMENT '创建时间',
modify_time datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (group_id)
) COMMENT='群组信息表' ENGINE=InnoDB CHARSET=utf8;


-- ----------------------------
Expand All @@ -24,6 +27,7 @@ CREATE TABLE IF NOT EXISTS tb_front (
front_port int(11) DEFAULT NULL COMMENT '前置服务端口',
agency varchar(32) NOT NULL COMMENT '所属机构名称',
client_version varchar(32) NOT NULL COMMENT '节点版本(国密/非国密)',
status int(11) DEFAULT 1 COMMENT '前置服务状态',
create_time datetime DEFAULT NULL COMMENT '创建时间',
modify_time datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (front_id),
Expand All @@ -40,6 +44,7 @@ CREATE TABLE IF NOT EXISTS tb_front_group_map (
group_id int(11) NOT NULL COMMENT '群组编号',
create_time datetime DEFAULT NULL COMMENT '创建时间',
modify_time datetime DEFAULT NULL COMMENT '修改时间',
status int(11) DEFAULT 1 NOT NULL COMMENT '节点(前置)的群组状态',
PRIMARY KEY (map_id),
unique unique_front_group (front_id,group_id)
) ENGINE=InnoDB AUTO_INCREMENT=600001 DEFAULT CHARSET=utf8 COMMENT='前置群组映射表';
Expand Down Expand Up @@ -105,7 +110,7 @@ CREATE TABLE IF NOT EXISTS tb_method(
create_time datetime DEFAULT NULL COMMENT '创建时间',
modify_time datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (method_id,group_id)
) COMMENT='方法解析信息表' ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='方法解析信息表';



Expand Down Expand Up @@ -301,3 +306,20 @@ CREATE TABLE IF NOT EXISTS tb_alert_log (
PRIMARY KEY (log_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='告警日志表';

-- ----------------------------
-- Table structure for tb_abi, unrelated with tb_contract
-- ----------------------------
CREATE TABLE IF NOT EXISTS tb_abi (
abi_id int(11) NOT NULL AUTO_INCREMENT COMMENT '合约ABI的编号',
group_id int(11) NOT NULL COMMENT '合约ABI所属群组的编号',
contract_name varchar(120) NOT NULL COMMENT '合约ABI的合约名',
contract_address varchar(64) NOT NULL COMMENT '合约ABI的合约地址',
contract_abi text NOT NULL COMMENT '合约ABI的内容',
contract_bin text NOT NULL COMMENT '合约ABI的runtime-bin',
create_time datetime DEFAULT NULL COMMENT '合约ABI的创建时间',
modify_time datetime DEFAULT NULL COMMENT '合约ABI的修改时间',
PRIMARY KEY (abi_id),
UNIQUE KEY unique_address (group_id,contract_address),
UNIQUE KEY unique_name (group_id,contract_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合约ABI表';

127 changes: 127 additions & 0 deletions src/main/java/com/webank/webase/node/mgr/abi/AbiController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* Copyright 2014-2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.webank.webase.node.mgr.abi;

import com.alibaba.fastjson.JSON;
import com.webank.webase.node.mgr.abi.entity.AbiInfo;
import com.webank.webase.node.mgr.abi.entity.ReqAbiListParam;
import com.webank.webase.node.mgr.abi.entity.ReqImportAbi;
import com.webank.webase.node.mgr.base.code.ConstantCode;
import com.webank.webase.node.mgr.base.controller.BaseController;
import com.webank.webase.node.mgr.base.entity.BasePageResponse;
import com.webank.webase.node.mgr.base.entity.BaseResponse;
import com.webank.webase.node.mgr.base.enums.SqlSortType;
import com.webank.webase.node.mgr.base.properties.ConstantProperties;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.Optional;

@Log4j2
@RestController
@RequestMapping("abi")
public class AbiController extends BaseController {
@Autowired
AbiService abiService;

@GetMapping("/list/{groupId}/{pageNumber}/{pageSize}")
public Object listAbi(
@PathVariable("groupId") Integer groupId,
@PathVariable("pageNumber") Integer pageNumber,
@PathVariable("pageSize") Integer pageSize) {
Instant startTime = Instant.now();
if (pageNumber < 1 || pageSize <= 0) {
return new BaseResponse(ConstantCode.PARAM_EXCEPTION);
}
log.info("start listAbi. startTime:{},groupId:{},pageNumber:{},pageSize:{}",
startTime.toEpochMilli(), groupId, pageNumber, pageSize);

Integer start = Optional.ofNullable(pageNumber).map(page -> (page - 1) * pageSize)
.orElse(0);
ReqAbiListParam param = new ReqAbiListParam(start, pageSize,
SqlSortType.DESC.getValue());
param.setGroupId(groupId);
List<AbiInfo> resList = abiService.getListByGroupId(param);
// total count
int count = abiService.countOfAbi();

log.info("end listAbi. useTime:{}, resList:{}",
Duration.between(startTime, Instant.now()).toMillis(), resList);
return new BasePageResponse(ConstantCode.SUCCESS, resList, count);
}

@GetMapping("/{abiId}")
public Object getAbiById(@PathVariable("abiId") Integer abiId) {
Instant startTime = Instant.now();
log.info("start getAbiById. startTime:{} abiId:{}",
startTime.toEpochMilli(), abiId);
AbiInfo res = abiService.getAbiById(abiId);
log.info("end getAbiById. useTime:{}, res:{}",
Duration.between(startTime, Instant.now()).toMillis(), res);
return new BaseResponse(ConstantCode.SUCCESS, res);
}

@PostMapping("")
@PreAuthorize(ConstantProperties.HAS_ROLE_ADMIN)
public Object saveAbi(@Valid @RequestBody ReqImportAbi param, BindingResult result) {
checkBindResult(result);
Instant startTime = Instant.now();
log.info("start saveAbi. startTime:{} ReqImportAbi:{}",
startTime.toEpochMilli(), JSON.toJSONString(param));
abiService.saveAbi(param);
log.info("end saveAbi. useTime:{}",
Duration.between(startTime, Instant.now()).toMillis());
return new BaseResponse(ConstantCode.SUCCESS);
}

/**
* @param param abiId is not empty to update
* @return
*/
@PutMapping("")
@PreAuthorize(ConstantProperties.HAS_ROLE_ADMIN)
public Object updateAbi(@RequestBody ReqImportAbi param, BindingResult result) {
checkBindResult(result);
Instant startTime = Instant.now();
log.info("start updateAbi. startTime:{} ReqImportAbi:{}",
startTime.toEpochMilli(), JSON.toJSONString(param));
if(param.getAbiId() == null) {
return new BaseResponse(ConstantCode.PARAM_FAIL_ABI_ID_EMPTY);
}
abiService.saveAbi(param);
AbiInfo res = abiService.getAbiById(param.getAbiId());
log.info("end updateAbi. useTime:{}, res:{}",
Duration.between(startTime, Instant.now()).toMillis(), res);
return new BaseResponse(ConstantCode.SUCCESS, res);
}

@DeleteMapping("/{abiId}")
@PreAuthorize(ConstantProperties.HAS_ROLE_ADMIN)
public BaseResponse deleteAbi(@PathVariable("abiId") Integer abiId) {
log.debug("start deleteAbi. abiId:{}", abiId);
abiService.delete(abiId);
log.debug("end deleteAbi");
return new BaseResponse(ConstantCode.SUCCESS);
}
}
45 changes: 45 additions & 0 deletions src/main/java/com/webank/webase/node/mgr/abi/AbiMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright 2014-2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.webank.webase.node.mgr.abi;

import com.webank.webase.node.mgr.abi.entity.AbiInfo;
import com.webank.webase.node.mgr.abi.entity.ReqAbiListParam;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AbiMapper {

List<AbiInfo> listOfAbi(@Param("param") ReqAbiListParam param);

Integer countOfAbi();

AbiInfo queryByAbiId(@Param("abiId") int abiId);

AbiInfo queryByGroupIdAndAddress(@Param("groupId") int groupId,
@Param("contractAddress") String contractAddress);

AbiInfo queryByGroupIdAndContractName(@Param("groupId") int groupId,
@Param("contractName") String contractName);
void add(AbiInfo abiInfo);

void update(AbiInfo abiInfo);

void deleteByAbiId(@Param("abiId") int abiId);
}
Loading

0 comments on commit a9d3f20

Please sign in to comment.