| | |
| | | props1.setProperty("algorithm-expression", "t_user_coupon$->{userId % 5 + 1}"); |
| | | result1.getShardingAlgorithms().put("t_user_coupon-inline", new AlgorithmConfiguration("INLINE", props1)); |
| | | result1.getKeyGenerators().put("t_user_coupon-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | linkedList.add(result1); |
| | | |
| | | //分片规则配置 |
| | | ShardingRuleConfiguration result2 = new ShardingRuleConfiguration(); |
| | | result2.getTables().add(getUserPointsMerchandiseTableRuleConfiguration()); |
| | | result1.getTables().add(getUserPointsMerchandiseTableRuleConfiguration()); |
| | | Properties props2 = new Properties(); |
| | | props2.setProperty("algorithm-expression", "t_user_points_merchandise$->{userId % 5 + 1}"); |
| | | result2.getShardingAlgorithms().put("t_user_points_merchandise-inline", new AlgorithmConfiguration("INLINE", props2)); |
| | | result2.getKeyGenerators().put("t_user_points_merchandise-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | linkedList.add(result2); |
| | | result1.getShardingAlgorithms().put("t_user_points_merchandise-inline", new AlgorithmConfiguration("INLINE", props2)); |
| | | result1.getKeyGenerators().put("t_user_points_merchandise-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | |
| | | //分片规则配置 |
| | | ShardingRuleConfiguration result3 = new ShardingRuleConfiguration(); |
| | | result3.getTables().add(getUserBenefitsVideosTableRuleConfiguration()); |
| | | result1.getTables().add(getUserBenefitsVideosTableRuleConfiguration()); |
| | | Properties props3 = new Properties(); |
| | | props3.setProperty("algorithm-expression", "t_user_benefits_videos$->{appUserId % 5 + 1}"); |
| | | result3.getShardingAlgorithms().put("t_user_benefits_videos-inline", new AlgorithmConfiguration("INLINE", props3)); |
| | | result3.getKeyGenerators().put("t_user_benefits_videos-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | linkedList.add(result3); |
| | | result1.getShardingAlgorithms().put("t_user_benefits_videos-inline", new AlgorithmConfiguration("INLINE", props3)); |
| | | result1.getKeyGenerators().put("t_user_benefits_videos-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | linkedList.add(result1); |
| | | |
| | | return linkedList; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | private ShardingTableRuleConfiguration getUserCouponTableRuleConfiguration() { |
| | | ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_user_coupon", "m_$->{0}.t_user_coupon->{1..5}");//50 |
| | | ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_user_coupon", "m_$->{0}.t_user_coupon$->{1..5}");//50 |
| | | result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("userId", "t_user_coupon-inline")); |
| | | result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "t_user_coupon-snowflake")); |
| | | return result; |