OrderTableShardingStrategy.java 607 B

123456789101112131415161718192021222324
  1. package com.yinjie.heating.business.dao;
  2. import com.dySweetFishPlugin.sql.dao.TableShardingStrategy;
  3. /**
  4. * Created by jlutt on 2020-08-11
  5. *
  6. * @author jlutt
  7. */
  8. public class OrderTableShardingStrategy implements TableShardingStrategy<String> {
  9. /**
  10. * 获得分表后的表名
  11. *
  12. */
  13. @Override
  14. public String getTargetTable(String table, String shardingParameter) {
  15. if (shardingParameter.contains("_")) {
  16. return table + shardingParameter.split("_")[0] + "_current";
  17. } else {
  18. return table + shardingParameter + "_current";
  19. }
  20. }
  21. }