//package com.jwipc.sharding;
//
//import cn.hutool.extra.spring.SpringUtil;
//import com.jwipc.sharding.mapper.DataShardingMapper;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.data.redis.core.StringRedisTemplate;
//
//import java.util.concurrent.TimeUnit;
//
///**
// * <p> @Title ShardingAlgorithmTool
// * <p> @Description 分片算法工具
// */
//@Slf4j
//public class ShardingAlgorithmTool {
//    public static String SHARDING_TABLE = "SHARDING_TABLE_";
//
//    private static final DataShardingMapper dataShardingMapper = SpringUtil.getBean(DataShardingMapper.class);
//    private static final StringRedisTemplate redisTemplate = SpringUtil.getBean(StringRedisTemplate.class);
//
//    public static Integer getTable(String table) {
//        String tableCatch = redisTemplate.opsForValue().get(SHARDING_TABLE + table);
//        if (StringUtils.isNotEmpty(tableCatch)){
//            return 1;
//        }
//        return dataShardingMapper.getTablesNumByName(table);
//    }
//
//    public static void copyTable(String originalTable, String newTable) {
//        redisTemplate.opsForValue().set(SHARDING_TABLE + newTable, newTable);
//        dataShardingMapper.copyTables(originalTable, newTable);
//    }
//}
