Skip to content

Commit

Permalink
Merge pull request #41 from WeBankFinTech/dev
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
mingzhenliu committed Oct 24, 2019
2 parents aa56b6b + 178301f commit 53683dd
Show file tree
Hide file tree
Showing 51 changed files with 591 additions and 365 deletions.
38 changes: 37 additions & 1 deletion Changelog.md
@@ -1,8 +1,44 @@
### V1.2.0

(2019-09-30)

**Add**

- 分库分表
- 支持删除数据

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



### V1.1.0

(2019-09-12)

**Fix**

- bugfix:调用WeBASE-Sign时签名用户地址不一致
- bugfix:方法调用时校验方法名是否存在
- 优化:调用WeBASE-Sign时支持传入用户编号
- 优化:启停脚本通过程序名和端口校验进程

**兼容性**

- 支持FISCO-BCOS v2.0.0-rc1 版本
- 支持FISCO-BCOS v2.0.0-rc2 版本
- 支持FISCO-BCOS v2.0.0-rc3 版本
- 支持FISCO-BCOS v2.0.0 版本
- WeBASE-Sign V1.1.0

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



### V1.0.0

(2019-06-27)

- Add
**Add**

1. 适配FISCO-BCOS 2.0.0版本
2. 支持多群组功能
Expand Down
7 changes: 6 additions & 1 deletion build.gradle
Expand Up @@ -84,7 +84,8 @@ dependencies {
compile "org.apache.commons:commons-lang3:3.6"
compile "commons-io:commons-io:2.4"
compile "commons-fileupload:commons-fileupload:1.4"
compile "com.alibaba:fastjson:1.2.58"
compile "com.alibaba:fastjson:1.2.60"
compile "io.shardingsphere:sharding-jdbc-spring-boot-starter:3.1.0"
compile 'org.projectlombok:lombok:1.18.2'
annotationProcessor 'org.projectlombok:lombok:1.18.2'
}
Expand Down Expand Up @@ -125,6 +126,10 @@ jar {
from file('src/main/resources/')
into 'dist/conf_template'
}
copy {
from file('script/')
into 'dist/script'
}
copy {
from configurations.runtime
into 'dist/lib'
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand All @@ -20,16 +20,14 @@ public interface ConstantCode {

// paramaters check
String GROUP_ID_IS_EMPTY = "{\"code\":203001,\"msg\":\"group id cannot be empty\"}";
String UUID_DEPLOY_IS_EMPTY = "{\"code\":203002,\"msg\":\"deploy uuid cannot be empty\"}";
String UUID_TRANS_IS_EMPTY = "{\"code\":203002,\"msg\":\"trans uuid cannot be empty\"}";
String UUID_IS_EMPTY = "{\"code\":203002,\"msg\":\"uuid cannot be empty\"}";
String SIGN_TYPE_IS_EMPTY = "{\"code\":203003,\"msg\":\"sign type cannot be empty\"}";
String CONTRACT_BIN_IS_EMPTY = "{\"code\":203004,\"msg\":\"contract bin cannot be empty\"}";
String CONTRACT_ABI_IS_EMPTY = "{\"code\":203005,\"msg\":\"contract abi cannot be empty\"}";
String CONTRACT_ADDRESS_IS_EMPTY = "{\"code\":203006,\"msg\":\"contract address cannot be empty\"}";
String FUNCTION_NAME_IS_EMPTY = "{\"code\":203007,\"msg\":\"function name cannot be empty\"}";

// general error
RetCode UUID_DEPLOY_IS_EXISTS = RetCode.mark(303001, "deploy uuid is already exists");
RetCode UUID_IS_EXISTS = RetCode.mark(303001, "uuid is already exists");
RetCode GET_SIGN_DATA_ERROR = RetCode.mark(303002, "get sign data from sign service error");
RetCode IN_FUNCPARAM_ERROR = RetCode.mark(303003, "contract funcParam is error");
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down Expand Up @@ -76,5 +76,8 @@ public class ConstantProperties {
private int intervalTime = 600;
private int sleepTime = 30;
private int transMaxWait = 20;
private boolean ifDeleteData = false;
private String cronDeleteData = "0 0 1 * * ?";
private int keepDays = 360;
private boolean ifDistributedTask = false;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down
@@ -0,0 +1,84 @@
/*
* Copyright 2014-2019 the original author or authors.
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.transaction.config;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import com.alibaba.fastjson.JSON;
import io.shardingsphere.api.algorithm.sharding.ListShardingValue;
import io.shardingsphere.api.algorithm.sharding.ShardingValue;
import io.shardingsphere.api.algorithm.sharding.complex.ComplexKeysShardingAlgorithm;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class MyComplexShardingAlgorithm implements ComplexKeysShardingAlgorithm {
@Override
public Collection<String> doSharding(Collection<String> collection, Collection<ShardingValue> shardingValues) {
log.debug("collection:" + JSON.toJSONString(collection) + ",shardingValues:" + JSON.toJSONString(shardingValues));
// 根据id和gmt_create双分片键来进行分表
Collection<Long> idValues = getLongShardingValue(shardingValues, "id");
Collection<Date> gmtValues = getDateShardingValue(shardingValues, "gmt_create");
List<String> shardingSuffix = new ArrayList<>();
for (Long idValue : idValues) {
for (Date gmtValue : gmtValues) {
Calendar cld = Calendar.getInstance();
cld.setTime(gmtValue);
int year = cld.get(Calendar.YEAR);
String suffix = "_" + year + "_" + idValue % 2;
collection.forEach(x -> {
if (x.endsWith(suffix)) {
shardingSuffix.add(x);
}
});
}
}

return shardingSuffix;
}

private Collection<Long> getLongShardingValue(Collection<ShardingValue> shardingValues, final String key) {
Collection<Long> valueSet = new ArrayList<>();
Iterator<ShardingValue> iterator = shardingValues.iterator();
while (iterator.hasNext()) {
ShardingValue next = iterator.next();
if (next instanceof ListShardingValue) {
ListShardingValue value = (ListShardingValue) next;
if (value.getColumnName().equals(key)) {
return value.getValues();
}
}
}
return valueSet;
}

private Collection<Date> getDateShardingValue(Collection<ShardingValue> shardingValues, final String key) {
Collection<Date> valueSet = new ArrayList<>();
Iterator<ShardingValue> iterator = shardingValues.iterator();
while (iterator.hasNext()) {
ShardingValue next = iterator.next();
if (next instanceof ListShardingValue) {
ListShardingValue value = (ListShardingValue) next;
if (value.getColumnName().equals(key)) {
return value.getValues();
}
}
}
return valueSet;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down
Expand Up @@ -31,7 +31,7 @@ public class TableInitConfig implements InitializingBean {

@Override
public void afterPropertiesSet() throws Exception {
contractMapper.createTbDeployTrans();;
transMapper.createTbStatelessTrans();;
contractMapper.createTbDeployTrans();
transMapper.createTbStatelessTrans();
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down Expand Up @@ -53,15 +53,16 @@ public HashMap<Integer, Web3j> web3j() throws Exception {

Service service = new Service();
service.setOrgID(orgName);
service.setGroupId(1);
service.setThreadPool(sdkThreadPool());
service.setAllChannelConnections(groupConfig);
service.run();

List<ChannelConnections> channelConnectList = groupConfig.getAllChannelConnections();
for (ChannelConnections connect : channelConnectList) {
int groupId = connect.getGroupId();
log.info("init groupId:{}", groupId);
// set groupId
service.setGroupId(groupId);
service.run();
ChannelEthereumService channelEthereumService = new ChannelEthereumService();
channelEthereumService.setTimeout(timeout);
channelEthereumService.setChannelService(service);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* 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
Expand All @@ -14,6 +14,7 @@

package com.webank.webase.transaction.contract;

import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
Expand All @@ -29,6 +30,9 @@ public interface ContractMapper {

void insertDeployInfo(DeployInfoDto deployInfoDto);

DeployInfoDto selectDeployInfo(@Param("groupId") int groupId,
@Param("uuidDeploy") String uuidDeploy);

String selectContractAddress(@Param("groupId") int groupId,
@Param("uuidDeploy") String uuidDeploy);

Expand All @@ -46,7 +50,9 @@ List<DeployInfoDto> selectUnStatTransByJob(@Param("requestCountMax") int request
@Param("shardingTotalCount") int shardingTotalCount,
@Param("shardingItem") int shardingItem);

void updateRequestCount(@Param("id") Long id, @Param("requestCount") int requestCount);
void updateRequestCount(@Param("id") Long id, @Param("requestCount") int requestCount, @Param("gmtCreate") Date gmtCreate);

void updateHandleStatus(DeployInfoDto deployInfoDto);

void deletePartData(@Param(value = "keepDays") int keepDays);
}

0 comments on commit 53683dd

Please sign in to comment.