| | |
| | | |
| | | //分片规则配置 |
| | | ShardingRuleConfiguration result1 = new ShardingRuleConfiguration(); |
| | | |
| | | result1.getTables().add(getCoursePackagePaymentTableRuleConfiguration()); |
| | | Properties props1 = new Properties(); |
| | | props1.setProperty("algorithm-expression", "t_course_package_payment$->{appUserId % 5 + 1}"); |
| | |
| | | //分片规则配置 |
| | | result1.getTables().add(getCoursePackageOrderTableRuleConfiguration()); |
| | | Properties props6 = new Properties(); |
| | | props1.setProperty("algorithm-expression", "t_course_package_order$->{appUserId % 5 + 1}"); |
| | | props6.setProperty("algorithm-expression", "t_course_package_order$->{appUserId % 5 + 1}"); |
| | | result1.getShardingAlgorithms().put("t_course_package_order-inline", new AlgorithmConfiguration("INLINE", props6)); |
| | | result1.getKeyGenerators().put("t_course_package_order-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | |
| | |
| | | * @return |
| | | */ |
| | | private ShardingTableRuleConfiguration getCoursePackageOrderTableRuleConfiguration() { |
| | | ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_course_package_order", "m_$->{0}.t_course_package_order$->{1..5}");//30 |
| | | // 兼容分表前写入基础表的历史购课记录;新订单仍按 appUserId 路由至后缀分表。 |
| | | ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_course_package_order", "m_$->{0}.t_course_package_order,m_$->{0}.t_course_package_order$->{1..5}");//30 |
| | | result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("appUserId", "t_course_package_order-inline")); |
| | | result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "t_course_package_order-snowflake")); |
| | | return result; |