cn.echo.sharding.strategy.SerialDataNode Maven / Gradle / Ivy
The newest version!
package cn.echo.sharding.strategy;
/**
* 序列号节点分配策略
* @author lonyee
*
*/
public class SerialDataNode {
/**
* 获取按ID取模分表结构
*/
public static String getSerialNoDataNodes(String tablePrefix, int startNo, int endNo) {
StringBuilder stringBuilder = new StringBuilder(20);
for(int i=startNo; i<=endNo; i++) {
stringBuilder.append(tablePrefix);
stringBuilder.append(String.format("%02d", i));
stringBuilder.append(",");
}
if (stringBuilder.length()>0) {
stringBuilder.deleteCharAt(stringBuilder.length()-1);
}
return stringBuilder.toString();
}
}